from sklearn.preprocessing._function_transformer import FunctionTransformer as SKLModel
import lale.helpers
import lale.operators
from numpy import nan, inf
_hyperparams_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'description': 'inherited docstring for FunctionTransformer Constructs a transformer from an arbitrary callable.',
'allOf': [{
'type': 'object',
'required': ['func', 'inverse_func', 'validate', 'accept_sparse', 'pass_y', 'check_inverse', 'kw_args', 'inv_kw_args'],
'relevantToOptimizer': ['accept_sparse', 'pass_y'],
'additionalProperties': False,
'properties': {
'func': {
'anyOf': [{
'type': 'object'}, {
'enum': [None]}],
'default': None,
'description': 'The callable to use for the transformation. This will be passed'},
'inverse_func': {
'anyOf': [{
'type': 'object'}, {
'enum': [None]}],
'default': None,
'description': 'The callable to use for the inverse transformation. This will be'},
'validate': {
'anyOf': [{
'type': 'boolean'}, {
'enum': [None]}],
'default': None,
'description': 'Indicate that the input X array should be checked before calling'},
'accept_sparse': {
'type': 'boolean',
'default': False,
'description': 'Indicate that func accepts a sparse matrix as input. If validate is'},
'pass_y': {
'anyOf': [{
'type': 'boolean'}, {
'enum': ['deprecated']}],
'default': 'deprecated',
'description': 'Indicate that transform should forward the y argument to the'},
'check_inverse': {
'type': 'boolean',
'default': True,
'description': 'Whether to check that or ``func`` followed by ``inverse_func`` leads to'},
'kw_args': {
'anyOf': [{
'type': 'object'}, {
'enum': [None]}],
'default': None,
'description': 'Dictionary of additional keyword arguments to pass to func.'},
'inv_kw_args': {
'anyOf': [{
'type': 'object'}, {
'enum': [None]}],
'default': None,
'description': 'Dictionary of additional keyword arguments to pass to inverse_func.'},
}}],
}
_input_fit_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'description': 'Fit transformer by checking X.',
'type': 'object',
'properties': {
'X': {
'type': 'array',
'items': {
'type': 'array',
'items': {
'type': 'number'},
},
'description': 'Input array.'},
},
}
_input_transform_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'description': 'Transform X using the forward function.',
'type': 'object',
'properties': {
'X': {
'type': 'array',
'items': {
'type': 'array',
'items': {
'type': 'number'},
},
'description': 'Input array.'},
'y': {
'XXX TODO XXX': '(ignored)',
'description': '.. deprecated::0.19'},
},
}
_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.',
'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},
}
if (__name__ == '__main__'):
lale.helpers.validate_is_schema(_combined_schemas)
FunctionTransformer = lale.operators.make_operator(FunctionTransformerImpl, _combined_schemas)