(self)
return autoai_ranges, autoai_cat_idx
Returns two dictionaries, ranges and cat_idx, for hyperparameters.

        The ranges dictionary has two kinds of entries. Entries for
        numeric and Boolean hyperparameters are tuples of the form
        (min, max, default). Entries for categorical hyperparameters
        are lists of their values.

        The cat_idx dictionary has (min, max, default) entries of indices
        into the corresponding list of values.

        Warning: ignores side constraints and unions.
Returns two dictionaries, ranges and cat_idx, for hyperparameters.
Returns two dictionaries ranges and cat_idx for hyperparameters .
def get_param_ranges(self) -> Tuple[Dict[str, Any], Dict[str, Any]]:
        """Returns two dictionaries, ranges and cat_idx, for hyperparameters.

        The ranges dictionary has two kinds of entries. Entries for
        numeric and Boolean hyperparameters are tuples of the form
        (min, max, default). Entries for categorical hyperparameters
        are lists of their values.

        The cat_idx dictionary has (min, max, default) entries of indices
        into the corresponding list of values.

        Warning: ignores side constraints and unions."""

        hyperparam_obj = next(iter(self.hyperparam_schema().get("allOf", [])))
        original = hyperparam_obj.get("properties")

        def is_relevant(hp, s):
            if "relevantToOptimizer" in hyperparam_obj:
                return hp in hyperparam_obj["relevantToOptimizer"]
            return True

        relevant = {hp: s for hp, s in original.items() if is_relevant(hp, s)}

        def pick_one_type(schema):
            if "anyOf" in schema:

                def by_type(typ):
                    for s in schema["anyOf"]:
                        if "type" in s and s["type"] == typ:
                            if ("forOptimizer" not in s) or s["forOptimizer"]:
                                return s
                    return None

                s = None
                for typ in ["number", "integer", "string"]:
                    s = by_type(typ)
                    if s:
                        return s
                if s is None:
                    enums = []
                    for s in schema["anyOf"]:
                        if "enum" in s:
                            if ("forOptimizer" not in s) or s["forOptimizer"]:
                                enums.append(s)
                        elif s.get("type", None) == "boolean":
                            if ("forOptimizer" not in s) or s["forOptimizer"]:
                                bool_s = {"enum": [False, True]}
                                d = s.get("default", None)
                                if d is not None:
                                    bool_s["default"] = d

                                enums.append(bool_s)
                    if len(enums) == 1:
                        return enums[0]
                    elif enums:
                        # combine them, and see if there is an anyOf default that we want to use as well
                        vals = [item for s in enums for item in s["enum"]]
                        new_s = {
                            "enum": vals,
                        }

                        if "default" in schema and schema["default"] in vals:
                            new_s["default"] = schema["default"]
                        else:
                            for s in enums:
                                if "default" in s:
                                    new_s["default"] = s["default"]
                                    break
                        return new_s

                return schema["anyOf"][0]
            return schema

        unityped = {hp: pick_one_type(relevant[hp]) for hp in relevant}

        def add_default(schema):
            if "type" in schema:
                minimum, maximum = 0.0, 1.0
                if "minimumForOptimizer" in schema:
                    minimum = schema["minimumForOptimizer"]
                elif "minimum" in schema:
                    minimum = schema["minimum"]
                if "maximumForOptimizer" in schema:
                    maximum = schema["maximumForOptimizer"]
                elif "maximum" in schema:
                    maximum = schema["maximum"]
                result = {**schema}
                if schema["type"] in ["number", "integer"]:
                    if "default" not in schema:
                        schema["default"] = None
                    if "minimumForOptimizer" not in schema:
                        result["minimumForOptimizer"] = minimum
                    if "maximumForOptimizer" not in schema:
                        result["maximumForOptimizer"] = maximum
                return result
            elif "enum" in schema:
                if "default" in schema:
                    return schema
                return {"default": schema["enum"][0], **schema}
            return schema

        defaulted = {hp: add_default(unityped[hp]) for hp in unityped}

        def get_range(hp, schema):
            if "enum" in schema:
                default = schema["default"]
                non_default = [v for v in schema["enum"] if v != default]
                return [*non_default, default]
            else:

                def get(schema, key):
                    return schema[key] if key in schema else None

                keys = ["minimumForOptimizer", "maximumForOptimizer", "default"]
                return tuple([get(schema, key) for key in keys])

        def get_cat_idx(schema):
            if "enum" not in schema:
                return None
            return (0, len(schema["enum"]) - 1, len(schema["enum"]) - 1)

        autoai_ranges = {hp: get_range(hp, s) for hp, s in defaulted.items()}
        if "min_samples_split" in autoai_ranges and "min_samples_leaf" in autoai_ranges:
            if self._name not in (
                "_GradientBoostingRegressorImpl",
                "_GradientBoostingClassifierImpl",
                "_ExtraTreesClassifierImpl",
            ):
                autoai_ranges["min_samples_leaf"] = (1, 5, 1)
                autoai_ranges["min_samples_split"] = (2, 5, 2)
        autoai_cat_idx = {
            hp: get_cat_idx(s) for hp, s in defaulted.items() if "enum" in s
        }
        return autoai_ranges, autoai_cat_idx
def get_param_ranges ( self ) -> Tuple [ Dict [ str , Any ] , Dict [ str , Any ] ] : hyperparam_obj = next ( iter ( self . hyperparam_schema ( ) . get ( "allOf" , [ ] ) ) ) original = hyperparam_obj . get ( "properties" ) def is_relevant ( hp , s ) : if "relevantToOptimizer" in hyperparam_obj : return hp in hyperparam_obj [ "relevantToOptimizer" ] return True relevant = { hp : s for hp , s in original . items ( ) if is_relevant ( hp , s ) } def pick_one_type ( schema ) : if "anyOf" in schema : def by_type ( typ ) : for s in schema [ "anyOf" ] : if "type" in s and s [ "type" ] == typ : if ( "forOptimizer" not in s ) or s [ "forOptimizer" ] : return s return None s = None for typ in [ "number" , "integer" , "string" ] : s = by_type ( typ ) if s : return s if s is None : enums = [ ] for s in schema [ "anyOf" ] : if "enum" in s : if ( "forOptimizer" not in s ) or s [ "forOptimizer" ] : enums . append ( s ) elif s . get ( "type" , None ) == "boolean" : if ( "forOptimizer" not in s ) or s [ "forOptimizer" ] : bool_s = { "enum" : [ False , True ] } d = s . get ( "default" , None ) if d is not None : bool_s [ "default" ] = d enums . append ( bool_s ) if len ( enums ) == 1 : return enums [ 0 ] elif enums : # combine them, and see if there is an anyOf default that we want to use as well vals = [ item for s in enums for item in s [ "enum" ] ] new_s = { "enum" : vals , } if "default" in schema and schema [ "default" ] in vals : new_s [ "default" ] = schema [ "default" ] else : for s in enums : if "default" in s : new_s [ "default" ] = s [ "default" ] break return new_s return schema [ "anyOf" ] [ 0 ] return schema unityped = { hp : pick_one_type ( relevant [ hp ] ) for hp in relevant } def add_default ( schema ) : if "type" in schema : minimum , maximum = 0.0 , 1.0 if "minimumForOptimizer" in schema : minimum = schema [ "minimumForOptimizer" ] elif "minimum" in schema : minimum = schema [ "minimum" ] if "maximumForOptimizer" in schema : maximum = schema [ "maximumForOptimizer" ] elif "maximum" in schema : maximum = schema [ "maximum" ] result = { * * schema } if schema [ "type" ] in [ "number" , "integer" ] : if "default" not in schema : schema [ "default" ] = None if "minimumForOptimizer" not in schema : result [ "minimumForOptimizer" ] = minimum if "maximumForOptimizer" not in schema : result [ "maximumForOptimizer" ] = maximum return result elif "enum" in schema : if "default" in schema : return schema return { "default" : schema [ "enum" ] [ 0 ] , * * schema } return schema defaulted = { hp : add_default ( unityped [ hp ] ) for hp in unityped } def get_range ( hp , schema ) : if "enum" in schema : default = schema [ "default" ] non_default = [ v for v in schema [ "enum" ] if v != default ] return [ * non_default , default ] else : def get ( schema , key ) : return schema [ key ] if key in schema else None keys = [ "minimumForOptimizer" , "maximumForOptimizer" , "default" ] return tuple ( [ get ( schema , key ) for key in keys ] ) def get_cat_idx ( schema ) : if "enum" not in schema : return None return ( 0 , len ( schema [ "enum" ] ) - 1 , len ( schema [ "enum" ] ) - 1 ) autoai_ranges = { hp : get_range ( hp , s ) for hp , s in defaulted . items ( ) } if "min_samples_split" in autoai_ranges and "min_samples_leaf" in autoai_ranges : if self . _name not in ( "_GradientBoostingRegressorImpl" , "_GradientBoostingClassifierImpl" , "_ExtraTreesClassifierImpl" , ) : autoai_ranges [ "min_samples_leaf" ] = ( 1 , 5 , 1 ) autoai_ranges [ "min_samples_split" ] = ( 2 , 5 , 2 ) autoai_cat_idx = { hp : get_cat_idx ( s ) for hp , s in defaulted . items ( ) if "enum" in s } return autoai_ranges , autoai_cat_idx