Beispiel #1
0
                Null(forOptimizer=False),
            ],
            default=2,
            forOptimizer=False,
            desc="The number of clusters to find.",
        ),
        constraint=AnyOf(
            [Object(n_clusters=Null()),
             Object(distance_threshold=Null())],
            desc="n_clusters must be None if distance_threshold is not None.",
        ),
    )
    FeatureAgglomeration = FeatureAgglomeration.customize_schema(
        constraint=AnyOf(
            [
                Object(compute_full_tree=Enum(["True"])),
                Object(distance_threshold=Null()),
            ],
            desc=
            "compute_full_tree must be True if distance_threshold is not None.",
        ))

if sklearn.__version__ >= "0.24":
    # old: https://scikit-learn.org/0.21/modules/generated/sklearn.cluster.FeatureAgglomeration.html
    # new: https://scikit-learn.org/0.24/modules/generated/sklearn.cluster.FeatureAgglomeration.html
    from lale.schemas import Bool

    FeatureAgglomeration = FeatureAgglomeration.customize_schema(
        compute_distances=Bool(
            desc=
            "Computes distances between clusters even if distance_threshold is not used. This can be used to make dendrogram visualization, but introduces a computational and memory overhead.",
Beispiel #2
0
        "input_transform": _input_transform_schema,
        "output_transform": _output_transform_schema,
    },
}

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)
Beispiel #3
0
        "output_decision_function": _output_decision_function_schema,
    },
}

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,
        ),
Beispiel #4
0
        return self._wrapped_model.decision_function(X)


LogisticRegression = lale.operators.make_operator(
    LogisticRegressionImpl, _combined_schemas
)

if sklearn.__version__ >= "0.21":
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.LogisticRegression.html
    # new: https://scikit-learn.org/0.21/modules/generated/sklearn.linear_model.LogisticRegression.html
    LogisticRegression = typing.cast(
        lale.operators.PlannedIndividualOp,
        LogisticRegression.customize_schema(
            penalty=Enum(
                values=["l1", "l2", "elasticnet", "none"],
                desc="Norm used in the penalization.",
                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",
    },
}

GradientBoostingRegressor: lale.operators.PlannedIndividualOp
GradientBoostingRegressor = lale.operators.make_operator(
    sklearn.ensemble.GradientBoostingRegressor, _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.22/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html
    from lale.schemas import AnyOf, Bool, Enum, Float

    GradientBoostingRegressor = GradientBoostingRegressor.customize_schema(
        presort=AnyOf(
            types=[Bool(), Enum(["deprecated", "auto"])],
            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=False,
            min=0.0,
            maxForOptimizer=0.1,
        ),
    )

if sklearn.__version__ >= "0.24":
    # old: https://scikit-learn.org/0.22/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html
    # new: https://scikit-learn.org/0.24/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html
Beispiel #6
0
    "import_from": "sklearn.preprocessing",
    "type": "object",
    "tags": {"pre": [], "op": ["transformer"], "post": []},
    "properties": {
        "hyperparams": _hyperparams_schema,
        "input_fit": _input_fit_schema,
        "input_transform": _input_transform_schema,
        "output_transform": _output_transform_schema,
    },
}

PolynomialFeatures: lale.operators.IndividualOp
PolynomialFeatures = lale.operators.make_operator(
    PolynomialFeaturesImpl, _combined_schemas
)

if sklearn.__version__ >= "0.21":
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.preprocessing.PolynomialFeatures.html
    # new: https://scikit-learn.org/0.23/modules/generated/sklearn.preprocessing.PolynomialFeatures.html
    from lale.schemas import Enum

    PolynomialFeatures = PolynomialFeatures.customize_schema(
        order=Enum(
            values=["C", "F"],
            desc="Order of output array in the dense case. 'F' order is faster to compute, but may slow down subsequent estimators.",
            default="C",
        )
    )

lale.docstrings.set_docstrings(PolynomialFeaturesImpl, PolynomialFeatures._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)
Beispiel #8
0
        "op": ["estimator", "classifier"],
        "post": []
    },
    "properties": {
        "hyperparams": _hyperparams_schema,
        "input_fit": _input_fit_schema,
        "input_predict": _input_predict_schema,
        "output_predict": _output_predict_schema,
        "input_decision_function": _input_decision_function_schema,
        "output_decision_function": _output_decision_function_schema,
    },
}

SnapSVMClassifier = lale.operators.make_operator(_SnapSVMClassifierImpl,
                                                 _combined_schemas)

if snapml_installed and snapml.__version__ > "1.8.0":  # type: ignore # noqa
    from lale.schemas import Enum

    SnapSVMClassifier = SnapSVMClassifier.customize_schema(
        loss=Enum(
            desc="""The loss function that will be used for training.""",
            values=["hinge", "squared_hinge"],
            default="hinge",
            forOptimizer=True,
        ),
        set_as_available=True,
    )

lale.docstrings.set_docstrings(SnapSVMClassifier)
Beispiel #9
0
        "pre": [],
        "op": ["transformer"],
        "post": []
    },
    "properties": {
        "hyperparams": _hyperparams_schema,
        "input_fit": _input_fit_schema,
        "input_transform": _input_transform_schema,
        "output_transform": _output_transform_schema,
    },
}

PolynomialFeatures: lale.operators.PlannedIndividualOp
PolynomialFeatures = lale.operators.make_operator(PolynomialFeaturesImpl,
                                                  _combined_schemas)

if sklearn.__version__ >= "0.21":
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.preprocessing.PolynomialFeatures.html
    # new: https://scikit-learn.org/0.23/modules/generated/sklearn.preprocessing.PolynomialFeatures.html
    from lale.schemas import Enum

    PolynomialFeatures = PolynomialFeatures.customize_schema(order=Enum(
        values=["C", "F"],
        desc=
        "Order of output array in the dense case. 'F' order is faster to compute, but may slow down subsequent estimators.",
        default="C",
    ))

lale.docstrings.set_docstrings(PolynomialFeaturesImpl,
                               PolynomialFeatures._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', 'auto'])],
            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)
Beispiel #11
0
        "op": ["transformer", "interpretable"],
        "post": [],
    },
    "properties": {
        "hyperparams": min_max_scaler._hyperparams_schema,
        "input_fit": min_max_scaler._input_schema_fit,
        "input_transform": min_max_scaler._input_transform_schema,
        "output_transform": min_max_scaler._output_transform_schema,
    },
}

MinMaxScaler = lale.operators.make_operator(_MinMaxScalerImpl, _combined_schemas)

MinMaxScaler = typing.cast(
    lale.operators.PlannedIndividualOp,
    MinMaxScaler.customize_schema(
        copy=Enum(
            values=[True],
            desc="`copy=True` is the only value currently supported by this implementation",
            default=True,
        ),
        clip=Enum(
            values=[False],
            desc="`clip=False` is the only value currently supported by this implementation",
            default=False,
        ),
    ),
)

lale.docstrings.set_docstrings(MinMaxScaler)
Beispiel #12
0
        return self._wrapped_model.decision_function(X)


LogisticRegression = lale.operators.make_operator(LogisticRegressionImpl,
                                                  _combined_schemas)

if sklearn.__version__ >= '0.22':
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.LogisticRegression.html
    # new: https://scikit-learn.org/0.23/modules/generated/sklearn.linear_model.LogisticRegression.html
    from lale.schemas import AnyOf, Enum, Float, Null
    import typing
    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)
Beispiel #13
0
    "documentation_url": "https://lale.readthedocs.io/en/latest/modules/lale.lib.sklearn.nmf.html",
    "import_from": "sklearn.decomposition",
    "type": "object",
    "tags": {"pre": [], "op": ["transformer"], "post": []},
    "properties": {
        "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,
        )
    )

lale.docstrings.set_docstrings(NMF)
Beispiel #14
0
Datei: svc.py Projekt: lnxpy/lale
        '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)
    def predict_proba(self, X):
        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)
Beispiel #16
0
 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,
             ),
             fill_values=AnyOf(
                 types=[
                     Array(
                         items=AnyOf(
                             types=[Float(), String(), Enum(values=[np.nan]), Null()]
                         )
Beispiel #17
0
        "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

    def predict(self, X):
        return self._wrapped_model.predict(X)

    def predict_proba(self, X):
        return self._wrapped_model.predict_proba(X)

    def decision_function(self, X):
        return self._wrapped_model.decision_function(X)


LogisticRegression = lale.operators.make_operator(LogisticRegressionImpl,
                                                  _combined_schemas)

if sklearn.__version__ >= '0.22':
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.LogisticRegression.html
    # new: https://scikit-learn.org/0.23/modules/generated/sklearn.linear_model.LogisticRegression.html
    from lale.schemas import Enum
    import typing
    LogisticRegression = typing.cast(
        lale.operators.PlannedIndividualOp,
        LogisticRegression.customize_schema(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')))

lale.docstrings.set_docstrings(LogisticRegressionImpl,
                               LogisticRegression._schemas)