} _output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Apply the dimension reduction learned on the train data.", "laleType": "Any", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.cross_decomposition.PLSRegression#sklearn-cross_decomposition-plsregression", "import_from": "sklearn.cross_decomposition", "type": "object", "tags": { "pre": [], "op": ["transformer", "estimator"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_transform": _input_transform_schema, "output_transform": _output_transform_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } PLSRegression = make_operator(_PLSRegressionImpl, _combined_schemas) set_docstrings(PLSRegression)
}] } _combined_schemas = { '$schema': 'http://json-schema.org/draft-04/schema#', 'description': 'Combined schema for expected data and hyperparameters for a transformer for' ' a text data transformer based on pre-trained BERT model ' '(https://github.com/huggingface/pytorch-pretrained-BERT).', 'type': 'object', 'tags': { 'pre': ['text'], 'op': ['transformer', '~interpretable'], 'post': ['embedding'] }, 'properties': { 'input_fit': _input_schema_fit, 'input_predict': _input_schema_predict, 'output': _output_schema, 'hyperparams': _hyperparams_schema } } if __name__ == "__main__": lale.helpers.validate_is_schema(_combined_schemas) BertPretrainedEncoder = make_operator(BertPretrainedEncoderImpl, _combined_schemas)
"$schema": "http://json-schema.org/draft-04/schema#", "description": "Returns predicted values.", "type": "array", "items": { "type": "number" }, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.OrthogonalMatchingPursuitCV#sklearn-linear_model-orthogonalmatchingpursuitcv", "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, }, } OrthogonalMatchingPursuitCV = make_operator(_OrthogonalMatchingPursuitCVImpl, _combined_schemas) set_docstrings(OrthogonalMatchingPursuitCV)
"laleType": "Any", "XXX TODO XXX": "array of shape = [n_samples, n_classes], or a list of n_outputs", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.neighbors.KNeighborsClassifier#sklearn-neighbors-kneighborsclassifier", "import_from": "sklearn.neighbors", "type": "object", "tags": { "pre": [], "op": ["estimator", "classifier"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, "input_predict_proba": _input_predict_proba_schema, "output_predict_proba": _output_predict_proba_schema, }, } KNeighborsClassifier = make_operator(_KNeighborsClassifierImpl, _combined_schemas) set_docstrings(KNeighborsClassifier)
"properties": { "X": { "type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": "New data, where n_samples in the number of samples and n_features is the number of features", } }, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Apply the approximate feature map to X.", "type": "array", "items": {"type": "array", "items": {"type": "number"}}, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.kernel_approximation.SkewedChi2Sampler#sklearn-kernel_approximation-skewedchi2sampler", "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, }, } set_docstrings(SkewedChi2SamplerImpl, _combined_schemas) SkewedChi2Sampler = make_operator(SkewedChi2SamplerImpl, _combined_schemas)
"description": "Copy the input X or not.", }, }, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Perform standardization by centering and scaling", "laleType": "Any", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.preprocessing.StandardScaler#sklearn-preprocessing-standardscaler", "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, }, } set_docstrings(StandardScalerImpl, _combined_schemas) StandardScaler = make_operator(StandardScalerImpl, _combined_schemas)
"laleType": "Any", "XXX TODO XXX": "array, shape=(n_samples,) if n_classes == 2 else (n_samples, n_classes)", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.LogisticRegression#sklearn-linear_model-logisticregression", "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, "input_predict_proba": _input_predict_proba_schema, "output_predict_proba": _output_predict_proba_schema, "input_decision_function": _input_decision_function_schema, "output_decision_function": _output_decision_function_schema, }, } set_docstrings(LogisticRegressionImpl, _combined_schemas) LogisticRegression = make_operator(LogisticRegressionImpl, _combined_schemas)
"type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": "Samples", } }, } _output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Returns predicted values.", "anyOf": [ {"type": "array", "items": {"type": "number"}}, {"type": "array", "items": {"type": "array", "items": {"type": "number"}}}, ], } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.kernel_ridge.KernelRidge#sklearn-kernel_ridge-kernelridge", "import_from": "sklearn.kernel_ridge", "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, }, } set_docstrings(KernelRidgeImpl, _combined_schemas) KernelRidge = make_operator(KernelRidgeImpl, _combined_schemas)
_output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Projected array.", "anyOf": [ { "type": "array", "items": {"laleType": "Any", "XXX TODO XXX": "item type"}, "XXX TODO XXX": "numpy array or scipy sparse of shape [n_samples, n_components]", }, {"type": "array", "items": {"type": "array", "items": {"type": "number"}}}, ], } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.random_projection.GaussianRandomProjection#sklearn-random_projection-gaussianrandomprojection", "import_from": "sklearn.random_projection", "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, }, } set_docstrings(GaussianRandomProjectionImpl, _combined_schemas) GaussianRandomProjection = make_operator( GaussianRandomProjectionImpl, _combined_schemas )
}, ], "description": "The input samples", } }, } _output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "The predicted values.", "anyOf": [ {"type": "array", "items": {"type": "number"}}, {"type": "array", "items": {"type": "array", "items": {"type": "number"}}}, ], } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.RandomForestRegressor#sklearn-ensemble-randomforestregressor", "import_from": "sklearn.ensemble", "type": "object", "tags": {"pre": [], "op": ["estimator", "regressor"], "post": []}, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } set_docstrings(RandomForestRegressorImpl, _combined_schemas) RandomForestRegressor = make_operator(RandomForestRegressorImpl, _combined_schemas)
_output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "The predicted values.", "type": "array", "items": { "type": "number" }, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.GradientBoostingRegressor#sklearn-ensemble-gradientboostingregressor", "import_from": "sklearn.ensemble", "type": "object", "tags": { "pre": [], "op": ["estimator", "regressor"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } set_docstrings(GradientBoostingRegressorImpl, _combined_schemas) GradientBoostingRegressor = make_operator(GradientBoostingRegressorImpl, _combined_schemas)
"such arrays if n_outputs > 1", "laleType": "Any", "XXX TODO XXX": "array of shape = [n_samples, n_classes], or a list of n_outputs", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.ensemble.ExtraTreesClassifier#sklearn-ensemble-extratreesclassifier", "import_from": "sklearn.ensemble", "type": "object", "tags": { "pre": [], "op": ["estimator", "classifier"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, "input_predict_proba": _input_predict_proba_schema, "output_predict_proba": _output_predict_proba_schema, }, } set_docstrings(ExtraTreesClassifierImpl, _combined_schemas) ExtraTreesClassifier = make_operator(ExtraTreesClassifierImpl, _combined_schemas)
"documentation_url": "https://lale.readthedocs.io/en/latest/modules/lale.lib.sklearn.k_means.html", "import_from": "sklearn.cluster", "type": "object", "tags": { "pre": [], "op": ["transformer", "clustering", "estimator"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_transform": _input_transform_schema, "output_transform": _output_transform_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } KMeans = make_operator(SKLModel, _combined_schemas) if sklearn.__version__ >= "1.0": # old: https://scikit-learn.org/0.24/modules/generated/sklearn.cluster.KMeans.html # new: https://scikit-learn.org/1.0/modules/generated/sklearn.cluster.KMeans.html KMeans = KMeans.customize_schema( precompute_distances=None, n_jobs=None, set_as_available=True, ) set_docstrings(KMeans)
}, ], } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis#sklearn-discriminant_analysis-quadraticdiscriminantanalysis", "import_from": "sklearn.discriminant_analysis", "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, "input_predict_proba": _input_predict_proba_schema, "output_predict_proba": _output_predict_proba_schema, "input_decision_function": _input_decision_function_schema, "output_decision_function": _output_decision_function_schema, }, } QuadraticDiscriminantAnalysis = make_operator( _QuadraticDiscriminantAnalysisImpl, _combined_schemas) set_docstrings(QuadraticDiscriminantAnalysis)
"X": { "type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": "Data matrix to be transformed by the model", } }, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Transformed data", "type": "array", "items": {"type": "array", "items": {"type": "number"}}, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.decomposition.NMF#sklearn-decomposition-nmf", "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 = make_operator(_NMFImpl, _combined_schemas) set_docstrings(NMF)
"properties": { "X": { "type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": "New data.", } }, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Reduced version of X", "type": "array", "items": {"type": "array", "items": {"type": "number"}}, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.decomposition.TruncatedSVD#sklearn-decomposition-truncatedsvd", "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, }, } set_docstrings(TruncatedSVDImpl, _combined_schemas) TruncatedSVD = make_operator(TruncatedSVDImpl, _combined_schemas)
"X": { "type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": "Input array.", }, "y": {"laleType": "Any", "XXX TODO XXX": "(ignored)", "description": ""}, }, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Transformed input.", "type": "array", "items": {"type": "array", "items": {"type": "number"}}, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.preprocessing.FunctionTransformer#sklearn-preprocessing-functiontransformer", "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, }, } set_docstrings(FunctionTransformerImpl, _combined_schemas) FunctionTransformer = make_operator(FunctionTransformerImpl, _combined_schemas)
"items": { "type": "array", "items": { "type": "number" } }, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.naive_bayes.GaussianNB#sklearn-naive_bayes-gaussiannb", "import_from": "sklearn.naive_bayes", "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, "input_predict_proba": _input_predict_proba_schema, "output_predict_proba": _output_predict_proba_schema, }, } set_docstrings(GaussianNBImpl, _combined_schemas) GaussianNB = make_operator(GaussianNBImpl, _combined_schemas)
"description": "Confidence scores per (sample, class) combination", "laleType": "Any", "XXX TODO XXX": "array, shape=(n_samples,) if n_classes == 2 else (n_samples, n_classes)", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.RidgeClassifierCV#sklearn-linear_model-ridgeclassifiercv", "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, "input_decision_function": _input_decision_function_schema, "output_decision_function": _output_decision_function_schema, }, } set_docstrings(RidgeClassifierCVImpl, _combined_schemas) RidgeClassifierCV = make_operator(RidgeClassifierCVImpl, _combined_schemas)
}, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Document topic distribution for X.", "laleType": "Any", "XXX TODO XXX": "shape=(n_samples, n_components)", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.decomposition.LatentDirichletAllocation#sklearn-decomposition-latentdirichletallocation", "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, }, } set_docstrings(LatentDirichletAllocationImpl, _combined_schemas) LatentDirichletAllocation = make_operator(LatentDirichletAllocationImpl, _combined_schemas)
_user_validate_combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "type": "object", "tags": {"pre": [], "op": [""], "post": []}, "properties": { "hyperparams": _user_validate_hyperparam_schema, # "input_fit": None, # "input_transform": , # "output_transform": _output_transform_schema, }, } UserValidatorOp = Ops.make_operator(UserValidatorImpl, _user_validate_combined_schemas) class TestUserValidator(unittest.TestCase): def test_validate_none(self): import re import jsonschema self.assertRaisesRegex( jsonschema.ValidationError, re.compile( r"invalid value validate=None.*boolean", re.MULTILINE | re.DOTALL ), UserValidatorOp, validate=None,
"http://json-schema.org/draft-04/schema#", "description": "Target values", "laleType": "Any", "XXX TODO XXX": "array of float, shape = [n_samples] or [n_samples, n_outputs]", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.neighbors.RadiusNeighborsRegressor#sklearn-neighbors-radiusneighborsregressor", "import_from": "sklearn.neighbors", "type": "object", "tags": { "pre": [], "op": ["estimator", "regressor"], "post": [] }, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } set_docstrings(RadiusNeighborsRegressorImpl, _combined_schemas) RadiusNeighborsRegressor = make_operator(RadiusNeighborsRegressorImpl, _combined_schemas)
"items": {"type": "array", "items": {"type": "number"}}, }, ], "description": "Samples.", } }, } _output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Returns predicted values.", "type": "array", "items": {"type": "number"}, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.LassoLarsCV#sklearn-linear_model-lassolarscv", "import_from": "sklearn.linear_model", "type": "object", "tags": {"pre": [], "op": ["estimator", "regressor"], "post": []}, "properties": { "hyperparams": _hyperparams_schema, "input_fit": _input_fit_schema, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } LassoLarsCV = make_operator(_LassoLarsCVImpl, _combined_schemas) set_docstrings(LassoLarsCV)
}, }, } _output_transform_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Binarize each element of X", "laleType": "Any", } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.preprocessing.Binarizer#sklearn-preprocessing-binarizer", "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, }, } Binarizer = make_operator(_BinarizerImpl, _combined_schemas) set_docstrings(Binarizer)
} _output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Returns predicted values.", "type": "array", "items": { "type": "number" }, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.ElasticNet#sklearn-linear_model-elasticnet", "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, }, } set_docstrings(ElasticNetImpl, _combined_schemas) ElasticNet = make_operator(ElasticNetImpl, _combined_schemas)
"description": "Apply dimensionality reduction to X.", "type": "array", "items": { "type": "array", "items": { "type": "number" } }, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.decomposition.PCA#sklearn-decomposition-pca", "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, }, } set_docstrings(PCAImpl, _combined_schemas) PCA = make_operator(PCAImpl, _combined_schemas)
_output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Returns predicted values.", "type": "array", "items": { "type": "number" }, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.linear_model.ElasticNetCV#sklearn-linear_model-elasticnetcv", "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, }, } ElasticNetCV = make_operator(_ElasticNetCVImpl, _combined_schemas) set_docstrings(ElasticNetCV)
"X": { "type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": 'For kernel="precomputed", the expected shape of X is (n_samples_test, n_samples_train).', } }, } _output_predict_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Perform regression on samples in X.", "type": "array", "items": {"type": "number"}, } _combined_schemas = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Combined schema for expected data and hyperparameters.", "documentation_url": "https://scikit-learn.org/0.20/modules/generated/sklearn.svm.NuSVR#sklearn-svm-nusvr", "import_from": "sklearn.svm", "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, }, } NuSVR = make_operator(_NuSVRImpl, _combined_schemas) set_docstrings(NuSVR)
"description": "Combined schema for expected data and hyperparameters.", "type": "object", "tags": { "pre": [], "op": ["estimator"], "post": [] }, "properties": { "hyperparams": _hyperparam_schema, "input_fit": _input_schema_fit, "input_predict": _input_predict_schema, "output_predict": _output_predict_schema, }, } MutatingOp = make_operator(MutatingOpImpl, _combined_schemas) def fit_clone_fit(op): op1 = make_sklearn_compat(op) op1.fit(X=[1, 2], y=[1, 2]) op2 = clone(op1) fit2 = op2.fit(X=[3, 4], y=[3, 4]) print(fit2) class TestClone(unittest.TestCase): def test_clone_clones_op(self): op = MutatingOp(k=1) fit_clone_fit(op)
'description': 'Combined schema for expected data and hyperparameters.', 'type': 'object', 'tags': { 'pre': [], 'op': ['estimator'], 'post': [] }, 'properties': { 'hyperparams': _hyperparam_schema, 'input_fit': _input_schema_fit, 'input_predict': _input_schema_predict, 'output': _output_schema } } IncreaseRows = make_operator(IncreaseRowsImpl, _combined_schemas) import sklearn.linear_model class MyLRImpl: def __init__(self, penalty='l2', solver='liblinear', C=1.0): self.penalty = penalty self.solver = solver self.C = C def fit(self, X, y): result = MyLRImpl(self.penalty, self.solver, self.C) result._sklearn_model = sklearn.linear_model.LogisticRegression( penalty=self.penalty, solver=self.solver, C=self.C) result._sklearn_model.fit(X, y)