How to use the lale.util.Visitor.accept function in lale

To help you get started, we’ve selected a few lale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / lale / lale / sklearn_compat.py View on Github external
def visitPipeline(self, op:Ops.PlannedPipeline)->Dict[str,Any]:

        defaults_list:Iterable[Dict[str,Any]] = (
            nest_HPparams(s.name(), accept(s, self)) for s in op.steps())

        defaults:Dict[str,Any] = {}
        for d in defaults_list:
            defaults.update(d)

        return defaults
github IBM / lale / lale / search / lale_hyperopt.py View on Github external
def array_single_str_(self, space:SearchSpaceArray, path:str, num, useCounter=True)->str:
        p = _mk_label(path, num, useCounter=useCounter) + "_"
        ret = "(" if space.is_tuple else "["
        items:Iterable[SearchSpace] = space.items()
        ret += ",".join((accept(sub, self, p, counter=x, useCounter=useCounter) for x,sub in enumerate(items)))
        ret += ")" if space.is_tuple else "]"
        return ret
github IBM / lale / lale / search / search_space_grid.py View on Github external
def visitSearchSpaceOperator(self, op:SearchSpaceOperator)->SearchSpaceGridInternalType:
        return accept(op.sub_space, self)
github IBM / lale / lale / search / lale_hyperopt.py View on Github external
def asexpr(key, e):
            nonlocal child_counter
            if e is None:
                return None
            else:
                ee = accept(e, self, path + "_" + key, counter=child_counter)
                if child_counter is None:
                    child_counter = 1
                else:
                    child_counter = child_counter + 1
                return ee
github IBM / lale / lale / search / lale_hyperopt.py View on Github external
def visitSearchSpaceProduct(self, prod:SearchSpaceProduct, path:str, counter=None, useCounter=True):
        search_spaces = (accept(space, self, self.get_unique_name(make_indexed_name(name, index))) for name, index, space in prod.get_indexed_spaces())
        return "[" + ",".join(search_spaces) + "]"
github IBM / lale / lale / search / search_space_grid.py View on Github external
def _searchSpaceList(self, space:SearchSpaceArray, *, size:int)->List[SearchSpaceGrid]:
        sub_spaces = space.items(max=size)

        param_grids:List[List[SearchSpaceGrid]] = \
            [nest_all_HPparams(str(index), self.fixupDegenerateSearchSpaces(accept(sub,self))) for index,sub in enumerate(sub_spaces)]

        param_grids_product:Iterable[Iterable[SearchSpaceGrid]] = itertools.product(*param_grids)
        chained_grids:List[SearchSpaceGrid] = [
            dict(ChainMap(*gridline,)) for gridline in param_grids_product]

        if space.is_tuple:
            st_val = structure_type_tuple
        else:
            st_val = structure_type_list

        discriminated_grids:List[SearchSpaceGrid]=[{**d, structure_type_name:SearchSpaceConstant(st_val)} for d in chained_grids]


        return discriminated_grids
github IBM / lale / lale / sklearn_compat.py View on Github external
def visitOperatorChoice(self, op:Ops.OperatorChoice)->Dict[str,Any]:

        defaults_list:Iterable[Dict[str,Any]] = (
            accept(s, self) for s in op.steps())

        defaults : Dict[str,Any] = {}
        for d in defaults_list:
            defaults.update(d)

        return defaults
github IBM / lale / lale / search / lale_hyperopt.py View on Github external
def cstr(key, x):
            nonlocal child_counter
            if x is None:
                return "None"
            else:
                s = accept(x, self, path + "_" + key, child_counter, useCounter=useCounter)
                if child_counter is None:
                    child_counter = 1
                else:
                    child_counter = child_counter + 1
                return s
github IBM / lale / lale / search / lale_hyperopt.py View on Github external
def visitSearchSpaceOperator(self, op:SearchSpaceOperator, path:str, counter=None):
        return scope.make_nested_hyperopt(accept(op.sub_space, self, path))
github IBM / lale / lale / search / lale_hyperopt.py View on Github external
def array_single_expr_(self, space:SearchSpaceArray, path:str, num):
        p = _mk_label(path, num) + "_"
        items:Iterable[SearchSpace] = space.items()
        ret = [accept(sub, self, p, counter=x) for x,sub in enumerate(items)]
        return tuple(ret) if space.is_tuple else ret