module mlmodel.sklearn_transform_inv_fct
#
Short summary#
module mlinsights.mlmodel.sklearn_transform_inv_fct
Implements a transform which modifies the target and applies the reverse transformation on the target.
Classes#
class |
truncated documentation |
---|---|
The transform is used to apply a function on a the target, predict, then transform the target back before scoring. … |
|
The transform is used to permute targets, predict, then permute the target back before scoring. nan values remain … |
Properties#
property |
truncated documentation |
---|---|
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
Static Methods#
staticmethod |
truncated documentation |
---|---|
Returns the list of predefined functions. |
Methods#
method |
truncated documentation |
---|---|
Just defines fct and fct_inv. |
|
Defines a random permutation over the targets. |
|
Returns a trained transform which reverse the target after a predictor. |
|
Returns a trained transform which reverse the target after a predictor. |
|
Transforms X and y. Returns transformed X and y. If y is None, the returned value for y … |
|
Transforms X and y. Returns transformed X and y. If y is None, the returned value for y … |
Documentation#
Implements a transform which modifies the target and applies the reverse transformation on the target.
- class mlinsights.mlmodel.sklearn_transform_inv_fct.FunctionReciprocalTransformer(fct, fct_inv=None)#
Bases:
BaseReciprocalTransformer
The transform is used to apply a function on a the target, predict, then transform the target back before scoring. The transforms implements a series of predefined functions:
<<<
import pprint from mlinsights.mlmodel.sklearn_transform_inv_fct import FunctionReciprocalTransformer pprint.pprint(FunctionReciprocalTransformer.available_fcts())
>>>
{'exp': (<ufunc 'exp'>, 'log'), 'exp(x)-1': (<function FunctionReciprocalTransformer.available_fcts.<locals>.<lambda> at 0x7f0611fb00d0>, 'log'), 'expm1': (<ufunc 'expm1'>, 'log1p'), 'log': (<ufunc 'log'>, 'exp'), 'log(1+x)': (<function FunctionReciprocalTransformer.available_fcts.<locals>.<lambda> at 0x7f0611fb0040>, 'exp(x)-1'), 'log1p': (<ufunc 'log1p'>, 'expm1')}
- Parameters:
fct – function name of numerical function
fct_inv – optional if fct is a function name, reciprocal function otherwise
- __init__(fct, fct_inv=None)#
- Parameters:
fct – function name of numerical function
fct_inv – optional if fct is a function name, reciprocal function otherwise
- static available_fcts()#
Returns the list of predefined functions.
- fit(X=None, y=None, sample_weight=None)#
Just defines fct and fct_inv.
- get_fct_inv()#
Returns a trained transform which reverse the target after a predictor.
- transform(X, y)#
Transforms X and y. Returns transformed X and y. If y is None, the returned value for y is None as well.
- class mlinsights.mlmodel.sklearn_transform_inv_fct.PermutationReciprocalTransformer(random_state=None, closest=False)#
Bases:
BaseReciprocalTransformer
The transform is used to permute targets, predict, then permute the target back before scoring. nan values remain nan values. Once fitted, the transform has attribute
permutation_
which keeps track of the permutation to apply.- Parameters:
random_state – random state
closest – if True, finds the closest permuted element
- __init__(random_state=None, closest=False)#
- Parameters:
random_state – random state
closest – if True, finds the closest permuted element
- _check_is_fitted()#
- _find_closest(cl)#
- fit(X=None, y=None, sample_weight=None)#
Defines a random permutation over the targets.
- get_fct_inv()#
Returns a trained transform which reverse the target after a predictor.
- transform(X, y)#
Transforms X and y. Returns transformed X and y. If y is None, the returned value for y is None as well.