Example #1
0
if sklearn.__version__ >= "0.24":
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.LinearRegression.html
    # new: https://scikit-learn.org/0.24/modules/generated/sklearn.linear_model.LinearRegression.html
    from lale.schemas import JSON, Bool

    LinearRegression = LinearRegression.customize_schema(positive=Bool(
        desc="When set to True, forces the coefficients to be positive.",
        default=False,
        forOptimizer=False,
    ))
    LinearRegression = LinearRegression.customize_schema(constraint=JSON({
        "description":
        "Setting positive=True is only supported for dense arrays.",
        "anyOf": [
            {
                "type": "object",
                "properties": {
                    "positive": {
                        "enum": [False]
                    }
                }
            },
            {
                "type": "object",
                "laleNot": "X/isSparse"
            },
        ],
    }))

lale.docstrings.set_docstrings(LinearRegressionImpl, LinearRegression._schemas)
Example #2
0
            maxForOptimizer=0.1,
        ),
    )

if sklearn.__version__ >= "0.24":
    # old: https://scikit-learn.org/0.22/modules/generated/sklearn.tree.DecisionTreeRegressor.html
    # new: https://scikit-learn.org/0.24/modules/generated/sklearn.tree.DecisionTreeRegressor.html
    from lale.schemas import JSON

    DecisionTreeRegressor = DecisionTreeRegressor.customize_schema(
        criterion=JSON({
            "description":
            "Function to measure the quality of a split.",
            "anyOf": [
                {
                    "enum": ["mse", "friedman_mse", "poisson"]
                },
                {
                    "enum": ["mae"],
                    "forOptimizer": False
                },
            ],
            "default":
            "mse",
        }),
        presort=None,
    )

lale.docstrings.set_docstrings(DecisionTreeRegressorImpl,
                               DecisionTreeRegressor._schemas)
Example #3
0
Nystroem = lale.operators.make_operator(NystroemImpl, _combined_schemas)

if sklearn.__version__ >= "0.24":
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.kernel_approximation.Nystroem.html
    # new: https://scikit-learn.org/0.24/modules/generated/sklearn.kernel_approximation.Nystroem.html
    from lale.schemas import JSON

    Nystroem = Nystroem.customize_schema(n_jobs=JSON({
        "anyOf": [
            {
                "description": "1 unless in joblib.parallel_backend context.",
                "enum": [None],
            },
            {
                "description": "Use all processors.",
                "enum": [-1]
            },
            {
                "description": "Number of CPU cores.",
                "type": "integer",
                "minimum": 1,
            },
        ],
        "default":
        None,
        "description":
        "The number of jobs to use for the computation.",
    }))

lale.docstrings.set_docstrings(NystroemImpl, Nystroem._schemas)
Example #4
0
            ],
            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
    from lale.schemas import JSON

    ExtraTreesRegressor = ExtraTreesRegressor.customize_schema(criterion=JSON({
        "description":
        "Function to measure the quality of a split.",
        "anyOf": [
            {
                "enum": ["mse", "friedman_mse", "poisson"]
            },
            {
                "enum": ["mae"],
                "forOptimizer": False
            },
        ],
        "default":
        "mse",
    }), )

lale.docstrings.set_docstrings(ExtraTreesRegressorImpl,
                               ExtraTreesRegressor._schemas)
Example #5
0
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.VotingClassifier.html
    # new: https://scikit-learn.org/0.23/modules/generated/sklearn.ensemble.VotingClassifier.html
    from lale.schemas import JSON

    VotingClassifier = VotingClassifier.customize_schema(estimators=JSON({
        "type":
        "array",
        "items": {
            "type":
            "array",
            "laleType":
            "tuple",
            "items": [
                {
                    "type": "string"
                },
                {
                    "anyOf": [{
                        "laleType": "operator"
                    }, {
                        "enum": [None, "drop"]
                    }]
                },
            ],
        },
        "description":
        "List of (string, estimator) tuples. Invoking the ``fit`` method on the ``VotingClassifier`` will fit clones.",
    }))

lale.docstrings.set_docstrings(VotingClassifierImpl, VotingClassifier._schemas)
Example #6
0
VotingClassifier = lale.operators.make_operator(VotingClassifierImpl,
                                                _combined_schemas)

if sklearn.__version__ >= '0.21':
    # old: https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.VotingClassifier.html
    # new: https://scikit-learn.org/0.23/modules/generated/sklearn.ensemble.VotingClassifier.html
    from lale.schemas import JSON
    VotingClassifier = VotingClassifier.customize_schema(estimators=JSON({
        'type':
        'array',
        'items': {
            'type':
            'array',
            'laleType':
            'tuple',
            'items': [{
                'type': 'string'
            }, {
                'anyOf': [{
                    'laleType': 'operator'
                }, {
                    'enum': [None, 'drop']
                }]
            }]
        },
        'description':
        'List of (string, estimator) tuples. Invoking the ``fit`` method on the ``VotingClassifier`` will fit clones.'
    }))

lale.docstrings.set_docstrings(VotingClassifierImpl, VotingClassifier._schemas)
            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
    from lale.schemas import JSON

    GradientBoostingRegressor = GradientBoostingRegressor.customize_schema(
        presort=None,
        criterion=JSON(
            {
                "description": "Function to measure the quality of a split.",
                "anyOf": [
                    {"enum": ["mse", "friedman_mse"]},
                    {
                        "description": "Deprecated since version 0.24.",
                        "enum": ["mae"],
                        "forOptimizer": False,
                    },
                ],
                "default": "friedman_mse",
            }
        ),
    )

lale.docstrings.set_docstrings(
    GradientBoostingRegressorImpl, GradientBoostingRegressor._schemas
)