def test_bool_enum(self): from lale.lib.sklearn import SVR from lale.schemas import AnyOf, Bool, Null SVR = SVR.customize_schema(shrinking=AnyOf( types=[Bool(), Null()], default=None, desc="Whether to use the shrinking heuristic.", )) ranges, dists = SVR.get_param_ranges() expected_ranges = { "kernel": ["poly", "rbf", "sigmoid", "linear"], "degree": (2, 5, 3), "gamma": (3.0517578125e-05, 8, None), "tol": (0.0, 0.01, 0.001), "C": (0.03125, 32768, 1.0), "shrinking": [False, True, None], } self.maxDiff = None self.assertEqual(ranges, expected_ranges)
ccp_alpha=Float( desc= "Complexity parameter used for Minimal Cost-Complexity Pruning. The subtree with the largest cost complexity that is smaller than ccp_alpha will be chosen. By default, no pruning is performed.", default=0.0, forOptimizer=False, min=0.0, maxForOptimizer=0.1, ), max_samples=AnyOf( types=[ Null(desc="Draw X.shape[0] samples."), Int(desc="Draw max_samples samples.", min=1), Float( desc="Draw max_samples * X.shape[0] samples.", min=0.0, exclusiveMin=True, max=1.0, exclusiveMax=True, ), ], desc= "If bootstrap is True, the number of samples to draw from X to train each base estimator.", default=None, ), ) if sklearn.__version__ >= "0.24": # old: https://scikit-learn.org/0.22/modules/generated/sklearn.tree.ExtraTreesRegressor.html # new: https://scikit-learn.org/0.24/modules/generated/sklearn.tree.ExtraTreesRegressor.html ExtraTreesRegressor = ExtraTreesRegressor.customize_schema( criterion={ "description":
"hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_transform": _input_transform_schema, "output_transform": _output_transform_schema, }, } NMF: lale.operators.PlannedIndividualOp NMF = lale.operators.make_operator(SKLModel, _combined_schemas) if sklearn.__version__ >= "0.24": # old: https://scikit-learn.org/0.20/modules/generated/sklearn.decomposition.NMF.html # new: https://scikit-learn.org/0.24/modules/generated/sklearn.decomposition.NMF.html from lale.schemas import AnyOf, Enum, Null NMF = NMF.customize_schema( regularization=AnyOf( desc= "Select whether the regularization affects the components (H), the transformation (W), both or none of them.", types=[ Enum(values=["both", "components", "transformation"]), Null(), ], default="both", forOptimizer=True, ), set_as_available=True, ) lale.docstrings.set_docstrings(NMF)
return self._wrapped_model.predict_proba(X) DecisionTreeClassifier: lale.operators.IndividualOp DecisionTreeClassifier = lale.operators.make_operator( DecisionTreeClassifierImpl, _combined_schemas) if sklearn.__version__ >= "0.22": # old: https://scikit-learn.org/0.20/modules/generated/sklearn.tree.DecisionTreeClassifier.html # new: https://scikit-learn.org/0.23/modules/generated/sklearn.tree.DecisionTreeClassifier.html from lale.schemas import AnyOf, Bool, Enum, Float DecisionTreeClassifier = DecisionTreeClassifier.customize_schema( presort=AnyOf( types=[Bool(), Enum(["deprecated"])], desc="This parameter is deprecated and will be removed in v0.24.", default="deprecated", ), ccp_alpha=Float( desc= "Complexity parameter used for Minimal Cost-Complexity Pruning. The subtree with the largest cost complexity that is smaller than ccp_alpha will be chosen. By default, no pruning is performed.", default=0.0, forOptimizer=True, min=0.0, maxForOptimizer=0.1, ), ) lale.docstrings.set_docstrings(DecisionTreeClassifierImpl, DecisionTreeClassifier._schemas)
}, } FeatureAgglomeration: lale.operators.PlannedIndividualOp FeatureAgglomeration = lale.operators.make_operator( sklearn.cluster.FeatureAgglomeration, _combined_schemas) if sklearn.__version__ >= "0.21": # old: https://scikit-learn.org/0.20/modules/generated/sklearn.cluster.FeatureAgglomeration.html # new: https://scikit-learn.org/0.21/modules/generated/sklearn.cluster.FeatureAgglomeration.html from lale.schemas import AnyOf, Enum, Float, Int, Null, Object FeatureAgglomeration = FeatureAgglomeration.customize_schema( distance_threshold=AnyOf( types=[Float(), Null()], desc= "The linkage distance threshold above which, clusters will not be merged.", default=None, ), n_clusters=AnyOf( types=[ Int(minForOptimizer=2, maxForOptimizer=8, laleMaximum="X/maxItems"), Null(forOptimizer=False), ], default=2, forOptimizer=False, desc="The number of clusters to find.", ), constraint=AnyOf( [Object(n_clusters=Null()),
SVC: lale.operators.PlannedIndividualOp SVC = lale.operators.make_operator(sklearn.svm.SVC, _combined_schemas) if sklearn.__version__ >= "0.22": # old: https://scikit-learn.org/0.20/modules/generated/sklearn.svm.SVC.html # new: https://scikit-learn.org/0.23/modules/generated/sklearn.svm.SVC.html from lale.schemas import AnyOf, Bool, Enum, Float SVC = SVC.customize_schema( gamma=AnyOf( types=[ Enum(["scale", "auto"]), Float( minimum=0.0, exclusiveMinimum=True, minimumForOptimizer=3.0517578125e-05, maximumForOptimizer=8, distribution="loguniform", ), ], desc="Kernel coefficient for 'rbf', 'poly' and 'sigmoid'.", default="scale", ), break_ties=Bool( desc="If true, decision_function_shape='ovr', and number of classes > 2, predict will break ties according to the confidence values of decision_function; otherwise the first class among the tied classes is returned.", default=False, ), set_as_available=True, ) lale.docstrings.set_docstrings(SVC)
}, } OrdinalEncoder = lale.operators.make_operator(_OrdinalEncoderImpl, _combined_schemas) if sklearn.__version__ >= "0.24.1": OrdinalEncoder = typing.cast( lale.operators.PlannedIndividualOp, OrdinalEncoder.customize_schema( handle_unknown=Enum( desc="""When set to ‘error’ an error will be raised in case an unknown categorical feature is present during transform. When set to ‘use_encoded_value’, the encoded value of unknown categories will be set to the value given for the parameter unknown_value. In inverse_transform, an unknown category will be denoted as None. When this parameter is set to `ignore` and an unknown category is encountered during transform, the resulting encoding with be set to the value indicated by `encode_unknown_with` (this functionality is added by lale). """, values=["error", "ignore", "use_encoded_value"], default="error", ), unknown_value=AnyOf( desc="""When the parameter handle_unknown is set to ‘use_encoded_value’, this parameter is required and will set the encoded value of unknown categories. It has to be distinct from the values used to encode any of the categories in fit. """, default=None, types=[Int(), Enum(values=[np.nan]), Null()], ), ), ) lale.docstrings.set_docstrings(OrdinalEncoder)
default="l2", ), ), ) if sklearn.__version__ >= "0.22": # old: https://scikit-learn.org/0.21/modules/generated/sklearn.linear_model.LogisticRegression.html # new: https://scikit-learn.org/0.23/modules/generated/sklearn.linear_model.LogisticRegression.html LogisticRegression = typing.cast( lale.operators.PlannedIndividualOp, LogisticRegression.customize_schema( solver=Enum( values=["newton-cg", "lbfgs", "liblinear", "sag", "saga"], desc="Algorithm for optimization problem.", default="lbfgs", ), multi_class=Enum( values=["auto", "ovr", "multinomial"], desc="If the option chosen is `ovr`, then a binary problem is fit for each label. For `multinomial` the loss minimised is the multinomial loss fit across the entire probability distribution, even when the data is binary. `multinomial` is unavailable when solver=`liblinear`. `auto` selects `ovr` if the data is binary, or if solver=`liblinear`, and otherwise selects `multinomial`.", default="auto", ), l1_ratio=AnyOf( types=[Float(min=0.0, max=1.0), Null()], desc="The Elastic-Net mixing parameter.", default=None, ), ), ) lale.docstrings.set_docstrings(LogisticRegressionImpl, LogisticRegression._schemas)
'hyperparams': _hyperparams_schema, 'input_fit': _input_fit_schema, 'input_predict': _input_predict_schema, 'output_predict': _output_predict_schema } } GradientBoostingRegressor: lale.operators.IndividualOp GradientBoostingRegressor = lale.operators.make_operator( GradientBoostingRegressorImpl, _combined_schemas) if sklearn.__version__ >= '0.22': # old: https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html # new: https://scikit-learn.org/0.23/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html from lale.schemas import AnyOf, Bool, Enum, Float GradientBoostingRegressor = GradientBoostingRegressor.customize_schema( presort=AnyOf( types=[Bool(), Enum(['deprecated'])], desc='This parameter is deprecated and will be removed in v0.24.', default='deprecated'), ccp_alpha=Float( desc= 'Complexity parameter used for Minimal Cost-Complexity Pruning. The subtree with the largest cost complexity that is smaller than ccp_alpha will be chosen. By default, no pruning is performed.', default=0.0, forOptimizer=True, min=0.0, maxForOptimizer=0.1)) lale.docstrings.set_docstrings(GradientBoostingRegressorImpl, GradientBoostingRegressor._schemas)
from packaging import version from lale.schemas import AnyOf, Array, Enum, Float, Not, Null, Object, String autoai_libs_version = version.parse(autoai_libs_version_str) if autoai_libs_version >= version.Version("1.12.18"): NumImputer = typing.cast( lale.operators.PlannedIndividualOp, NumImputer.customize_schema( set_as_available=True, constraint=[ AnyOf( desc="fill_value and fill_values cannot both be specified", forOptimizer=False, types=[Object(fill_value=Null()), Object(fill_values=Null())], ), AnyOf( desc="if strategy=constants, the fill_values cannot be None", forOptimizer=False, types=[ Object(strategy=Not(Enum(["constants"]))), Not(Object(fill_values=Null())), ], ), ], fill_value=AnyOf( types=[Float(), String(), Enum(values=[np.nan]), Null()], desc="The placeholder for fill value used in constant strategy", default=None,
} NMF: lale.operators.PlannedIndividualOp NMF = lale.operators.make_operator(SKLModel, _combined_schemas) if sklearn.__version__ >= "0.24": # old: https://scikit-learn.org/0.20/modules/generated/sklearn.decomposition.NMF.html # new: https://scikit-learn.org/0.24/modules/generated/sklearn.decomposition.NMF.html from lale.schemas import AnyOf, Enum, Null NMF = NMF.customize_schema( regularization=AnyOf( desc="Select whether the regularization affects the components (H), the transformation (W), both or none of them.", types=[ Enum(values=["both", "components", "transformation"]), Null(), ], default="both", forOptimizer=True, ), set_as_available=True, ) if sklearn.__version__ >= "1.0": # old: https://scikit-learn.org/0.24/modules/generated/sklearn.decomposition.NMF.html # new: https://scikit-learn.org/1.0/modules/generated/sklearn.decomposition.NMF.html from lale.schemas import AnyOf, Enum, Float, Null NMF = NMF.customize_schema( alpha=Float( desc="""Constant that multiplies the regularization terms.
"op": ["transformer"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_transform": _input_transform_schema, "output_transform": _output_transform_schema, }, } FeatureAgglomeration: lale.operators.IndividualOp FeatureAgglomeration = lale.operators.make_operator(FeatureAgglomerationImpl, _combined_schemas) if sklearn.__version__ >= "0.21": # old: https://scikit-learn.org/0.20/modules/generated/sklearn.cluster.FeatureAgglomeration.html # new: https://scikit-learn.org/0.23/modules/generated/sklearn.cluster.FeatureAgglomeration.html from lale.schemas import AnyOf, Float, Null FeatureAgglomeration = FeatureAgglomeration.customize_schema( distance_threshold=AnyOf( types=[Float(), Null()], desc= "The linkage distance threshold above which, clusters will not be merged.", default=None, )) lale.docstrings.set_docstrings(FeatureAgglomerationImpl, FeatureAgglomeration._schemas)
'output_predict_proba': _output_predict_proba_schema, 'input_decision_function': _input_decision_function_schema, 'output_decision_function': _output_decision_function_schema } } SVC: lale.operators.IndividualOp SVC = lale.operators.make_operator(SVCImpl, _combined_schemas) if sklearn.__version__ >= '0.22': # old: https://scikit-learn.org/0.20/modules/generated/sklearn.svm.SVC.html # new: https://scikit-learn.org/0.23/modules/generated/sklearn.svm.SVC.html from lale.schemas import AnyOf, Bool, Enum, Float SVC = SVC.customize_schema( gamma=AnyOf(types=[ Enum(['scale', 'auto']), Float(min=0.0, exclusiveMin=True, minForOptimizer=3.0517578125e-05, maxForOptimizer=8, distribution='loguniform') ], desc="Kernel coefficient for 'rbf', 'poly' and 'sigmoid'.", default='scale'), break_ties=Bool( desc= "If true, decision_function_shape='ovr', and number of classes > 2, predict will break ties according to the confidence values of decision_function; otherwise the first class among the tied classes is returned.", default=False)) lale.docstrings.set_docstrings(SVCImpl, SVC._schemas)