module mlmodel.sklearn_transform_inv_fct#

Inheritance diagram of mlinsights.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.

source on GitHub

Classes#

class

truncated documentation

FunctionReciprocalTransformer

The transform is used to apply a function on a the target, predict, then transform the target back before scoring. …

PermutationReciprocalTransformer

The transform is used to permute targets, predict, then permute the target back before scoring. nan values remain …

Properties#

property

truncated documentation

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

Static Methods#

staticmethod

truncated documentation

available_fcts

Returns the list of predefined functions.

Methods#

method

truncated documentation

__init__

__init__

_check_is_fitted

_find_closest

fit

Just defines fct and fct_inv.

fit

Defines a random permutation over the targets.

get_fct_inv

Returns a trained transform which reverse the target after a predictor.

get_fct_inv

Returns a trained transform which reverse the target after a predictor.

transform

Transforms X and y. Returns transformed X and y. If y is None, the returned value for y

transform

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.

source on GitHub

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')}

source on GitHub

Parameters:
  • fct – function name of numerical function

  • fct_inv – optional if fct is a function name, reciprocal function otherwise

source on GitHub

__init__(fct, fct_inv=None)#
Parameters:
  • fct – function name of numerical function

  • fct_inv – optional if fct is a function name, reciprocal function otherwise

source on GitHub

static available_fcts()#

Returns the list of predefined functions.

source on GitHub

fit(X=None, y=None, sample_weight=None)#

Just defines fct and fct_inv.

source on GitHub

get_fct_inv()#

Returns a trained transform which reverse the target after a predictor.

source on GitHub

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.

source on GitHub

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.

source on GitHub

Parameters:
  • random_state – random state

  • closest – if True, finds the closest permuted element

source on GitHub

__init__(random_state=None, closest=False)#
Parameters:
  • random_state – random state

  • closest – if True, finds the closest permuted element

source on GitHub

_check_is_fitted()#
_find_closest(cl)#
fit(X=None, y=None, sample_weight=None)#

Defines a random permutation over the targets.

source on GitHub

get_fct_inv()#

Returns a trained transform which reverse the target after a predictor.

source on GitHub

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.

source on GitHub