Skip to content
30 changes: 30 additions & 0 deletions lale/lib/sklearn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

* lale.lib.sklearn. `AdaBoostClassifier`_
* lale.lib.sklearn. `BaggingClassifier`_
* lale.lib.sklearn. `BernoulliNB`_
* lale.lib.sklearn. `CalibratedClassifierCV`_
* lale.lib.sklearn. `ComplementNB`_
* lale.lib.sklearn. `DecisionTreeClassifier`_
* lale.lib.sklearn. `DummyClassifier`_
* lale.lib.sklearn. `ExtraTreesClassifier`_
Expand All @@ -44,6 +47,8 @@
Regressors:

* lale.lib.sklearn. `AdaBoostRegressor`_
* lale.lib.sklearn. `ARDRegression`_
* lale.lib.sklearn. `BayesianRidge`_
* lale.lib.sklearn. `DecisionTreeRegressor`_
* lale.lib.sklearn. `DummyRegressor`_
* lale.lib.sklearn. `ExtraTreesRegressor`_
Expand All @@ -58,6 +63,11 @@

Transformers:

* lale.lib.sklearn. `AdditiveChi2Sampler`_
* lale.lib.sklearn. `BernoulliRBM`_
* lale.lib.sklearn. `Binarizer`_
* lale.lib.sklearn. `Birch`_
* lale.lib.sklearn. `CCA`_
* lale.lib.sklearn. `ColumnTransformer`_
* lale.lib.sklearn. `FeatureAgglomeration`_
* lale.lib.sklearn. `FunctionTransformer`_
Expand All @@ -83,8 +93,18 @@

.. _`AdaBoostClassifier`: lale.lib.sklearn.ada_boost_classifier.html
.. _`AdaBoostRegressor`: lale.lib.sklearn.ada_boost_regressor.html
.. _`AdditiveChi2Sampler`: lale.lib.sklearn.additive_chi2_sampler.html
.. _`ARDRegression`: lale.lib.sklearn.ard_regression.html
.. _`BaggingClassifier`: lale.lib.sklearn.bagging_classifier.html
.. _`BayesianRidge`: lale.lib.sklearn.bayesian_ridge.html
.. _`BernoulliNB`: lale.lib.sklearn.bernoulli_nb.html
.. _`BernoulliRBM`: lale.lib.sklearn.bernoulli_rbm.html
.. _`Binarizer`: lale.lib.sklearn.binarizer.html
.. _`Birch`: lale.lib.sklearn.birch.html
.. _`CCA`: lale.lib.sklearn.cca.html
.. _`CalibratedClassifierCV`: lale.lib.sklearn.calibrated_classifier_cv.html
.. _`ColumnTransformer`: lale.lib.sklearn.column_transformer.html
.. _`ComplementNB`: lale.lib.sklearn.complement_nb.html
.. _`DecisionTreeClassifier`: lale.lib.sklearn.decision_tree_classifier.html
.. _`DecisionTreeRegressor`: lale.lib.sklearn.decision_tree_regressor.html
.. _`DummyClassifier`: lale.lib.sklearn.dummy_classifier.html
Expand Down Expand Up @@ -137,8 +157,18 @@

from .ada_boost_classifier import AdaBoostClassifier
from .ada_boost_regressor import AdaBoostRegressor
from .additive_chi2_sampler import AdditiveChi2Sampler
from .ard_regression import ARDRegression
from .bagging_classifier import BaggingClassifier
from .bayesian_ridge import BayesianRidge
from .bernoulli_nb import BernoulliNB
from .bernoulli_rbm import BernoulliRBM
from .binarizer import Binarizer
from .birch import Birch
from .calibrated_classifier_cv import CalibratedClassifierCV
from .cca import CCA
from .column_transformer import ColumnTransformer
from .complement_nb import ComplementNB
from .decision_tree_classifier import DecisionTreeClassifier
from .decision_tree_regressor import DecisionTreeRegressor
from .dummy_classifier import DummyClassifier
Expand Down
93 changes: 93 additions & 0 deletions lale/lib/sklearn/additive_chi2_sampler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from sklearn.kernel_approximation import AdditiveChi2Sampler as Op

from lale.docstrings import set_docstrings
from lale.operators import make_operator

_hyperparams_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Approximate feature map for additive chi2 kernel.",
"allOf": [
{
"type": "object",
"required": ["sample_steps", "sample_interval"],
"relevantToOptimizer": ["sample_steps"],
"additionalProperties": False,
"properties": {
"sample_steps": {
"type": "integer",
"minimumForOptimizer": 1,
"maximumForOptimizer": 3,
"distribution": "uniform",
"default": 2,
"description": "Gives the number of (complex) sampling points.",
},
"sample_interval": {
"anyOf": [{"type": "number"}, {"enum": [None]}],
"default": None,
"description": "Sampling interval",
},
},
},
{
"description": "sample_interval must be specified when sample_steps not in {1,2,3}",
"anyOf": [
{
"type": "object",
"properties:": {"sample_steps": {"enum": [1, 2, 3]}},
},
{
"type": "object",
"properties:": {"sample_interval": {"type": "number"}},
},
],
},
],
}
_input_fit_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Set the parameters",
"type": "object",
"required": ["X"],
"properties": {
"X": {
"type": "array",
"items": {"type": "array", "items": {"type": "number"}},
"description": "Training data, where n_samples in the number of samples and n_features is the number of features.",
}
},
}
_input_transform_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Apply approximate feature map to X.",
"type": "object",
"required": ["X"],
"properties": {
"X": {"type": "array", "items": {"type": "array", "items": {"type": "number"}}}
},
}
_output_transform_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Whether the return value is an array of sparse matrix depends on the type of the input X.",
"laleType": "Any",
"XXX TODO XXX": "{array, sparse matrix}, shape = (n_samples, n_features * (2*sample_steps + 1))",
}
_combined_schemas = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": """`Approximate feature map for additive chi2 kernel`_ from sklearn

.. _`Approximate feature map for additive chi2 kernel.`: https://scikit-learn.org/stable/modules/generated/sklearn.kernel_approximation.AdditiveChi2Sampler
""",
"documentation_url": "https://lale.readthedocs.io/en/latest/modules/lale.lib.sklearn.additive_chi2_sampler.html",
"import_from": "sklearn.kernel_approximation",
"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,
},
}
AdditiveChi2Sampler = make_operator(Op, _combined_schemas)

set_docstrings(AdditiveChi2Sampler)
165 changes: 165 additions & 0 deletions lale/lib/sklearn/ard_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
from sklearn.linear_model import ARDRegression as Op

from lale.docstrings import set_docstrings
from lale.operators import make_operator

_hyperparams_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "ARDRegression Hyperparameter schema.",
"allOf": [
{
"type": "object",
"required": [
"n_iter",
"tol",
"alpha_1",
"alpha_2",
"lambda_1",
"lambda_2",
"compute_score",
"threshold_lambda",
"fit_intercept",
"normalize",
"copy_X",
"verbose",
],
"relevantToOptimizer": [
"n_iter",
"tol",
"compute_score",
"fit_intercept",
"normalize",
],
"additionalProperties": False,
"properties": {
"n_iter": {
"type": "integer",
"minimumForOptimizer": 5,
"maximumForOptimizer": 1000,
"distribution": "uniform",
"default": 300,
"description": "Maximum number of iterations",
},
"tol": {
"type": "number",
"minimumForOptimizer": 1e-08,
"maximumForOptimizer": 0.01,
"distribution": "loguniform",
"default": 0.001,
"description": "Stop the algorithm if w has converged",
},
"alpha_1": {
"type": "number",
"default": 1e-06,
"description": "Hyper-parameter : shape parameter for the Gamma distribution prior over the alpha parameter",
},
"alpha_2": {
"type": "number",
"default": 1e-06,
"description": "Hyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the alpha parameter",
},
"lambda_1": {
"type": "number",
"default": 1e-06,
"description": "Hyper-parameter : shape parameter for the Gamma distribution prior over the lambda parameter",
},
"lambda_2": {
"type": "number",
"default": 1e-06,
"description": "Hyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the lambda parameter",
},
"compute_score": {
"type": "boolean",
"default": False,
"description": "If True, compute the objective function at each step of the model",
},
"threshold_lambda": {
"type": "number",
"default": 10000.0,
"description": "threshold for removing (pruning) weights with high precision from the computation",
},
"fit_intercept": {
"type": "boolean",
"default": True,
"description": "whether to calculate the intercept for this model",
},
"normalize": {
"type": "boolean",
"default": False,
"description": "This parameter is ignored when ``fit_intercept`` is set to False",
},
"copy_X": {
"type": "boolean",
"default": True,
"description": "If True, X will be copied; else, it may be overwritten.",
},
"verbose": {
"type": "boolean",
"default": False,
"description": "Verbose mode when fitting the model.",
},
},
}
],
}
_input_fit_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Fit the ARDRegression model according to the given training data",
"type": "object",
"required": ["X", "y"],
"properties": {
"X": {
"type": "array",
"items": {"type": "array", "items": {"type": "number"}},
"description": "Training vector, where n_samples in the number of samples and n_features is the number of features.",
},
"y": {
"type": "array",
"items": {"type": "number"},
"description": "Target values (integers)",
},
},
}
_input_predict_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Predict using the linear model.",
"type": "object",
"required": ["X"],
"properties": {
"X": {
"type": "array",
"items": {"type": "array", "items": {"type": "number"}},
"description": "Samples.",
},
"return_std": {
"anyOf": [{"type": "boolean"}, {"enum": [None]}],
"default": None,
"description": "Whether to return the standard deviation of posterior prediction.",
},
},
}
_output_predict_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Predict using the linear model.",
"laleType": "Any",
}
_combined_schemas = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": """`ARDRegression`_ Bayesian ARD regression from sklearn.

.. _`ARDRegression`: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ARDRegression"
""",
"documentation_url": "https://lale.readthedocs.io/en/latest/modules/lale.lib.sklearn.ard_regression.html",
"import_from": "sklearn.linear_model",
"type": "object",
"tags": {"pre": [], "op": ["estimator"], "post": []},
"properties": {
"hyperparams": _hyperparams_schema,
"input_fit": _input_fit_schema,
"input_predict": _input_predict_schema,
"output_predict": _output_predict_schema,
},
}
ARDRegression = make_operator(Op, _combined_schemas)

set_docstrings(ARDRegression)
Loading