Example #1
0
        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)
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.ExtraTreesRegressor.html
    # new: https://scikit-learn.org/0.22/modules/generated/sklearn.ensemble.ExtraTreesRegressor.html
    from lale.schemas import AnyOf, Float, Int, Null

    ExtraTreesRegressor = ExtraTreesRegressor.customize_schema(
        n_estimators=Int(
            desc="The number of trees in the forest.",
            default=100,
            forOptimizer=True,
            minForOptimizer=10,
            maxForOptimizer=100,
        ),
        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,
                ),
            ],
Example #3
0
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,
    )

Example #4
0
        "output_transform": _output_transform_schema,
    },
}

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.",
        ),
Example #5
0
     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()]
             )
         ),
         Null(),
     ],
     desc="The placeholder for fill values used in constants strategy",
     default=None,
 ),
Example #6
0
                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)
Example #7
0
            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.
Set it to zero to have no regularization. When using alpha instead of alpha_W and alpha_H,
the regularization terms are not scaled by the n_features (resp. n_samples) factors for W (resp. H).""",
            default=0.0,
            forOptimizer=False,
        ),
        alpha_W=Float(
            desc="""Constant that multiplies the regularization terms of W. Set it to zero (default) to have no regularization on W.""",
            minimumForOptimizer=1e-10,
            maximumForOptimizer=1.0,
            distribution="loguniform",
            default=0.0,
            forOptimizer=True,
        ),
        alpha_H=AnyOf(
            types=[
                Enum(values=["same"]),
                Float(
Example #8
0
    )

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(minimum=0.0, maximum=1.0),
                       Null()],
                desc="The Elastic-Net mixing parameter.",
                default=None,
            ),
            set_as_available=True,
        ),
    )

lale.docstrings.set_docstrings(LogisticRegression)
Example #9
0
    )

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)
Example #10
0
             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()
         ])),
Example #11
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)
Example #12
0
    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 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)
Example #13
0
File: svc.py Project: 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)