module mlmodel.extended_features

Inheritance diagram of mlinsights.mlmodel.extended_features

Short summary

module mlinsights.mlmodel.extended_features

Implements new features such as polynomial features.

source on GitHub

Classes

class

truncated documentation

ExtendedFeatures

Generates extended features such as polynomial features.

Properties

property

truncated documentation

_repr_html_

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

Methods

method

truncated documentation

__init__

_fit_poly

Fitting method for the polynomial features.

_get_feature_names_poly

Returns feature names for output features for the polynomial features.

_transform_poly

Transforms data to polynomial features.

_transform_poly_slow

Transforms data to polynomial features.

fit

Compute number of output features.

get_feature_names

Returns feature names for output features.

transform

Transforms data to extended features.

Documentation

Implements new features such as polynomial features.

source on GitHub

class mlinsights.mlmodel.extended_features.ExtendedFeatures(kind='poly', poly_degree=2, poly_interaction_only=False, poly_include_bias=True)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

Generates extended features such as polynomial features.

Parameters
  • kind – string 'poly' for polynomial features, 'poly-slow' for polynomial features in scikit-learn 0.20.2

  • poly_degree – integer The degree of the polynomial features. Default = 2.

  • poly_interaction_only – boolean If true, only interaction features are produced: features that are products of at most degree distinct input features (so not x[1] ** 2, x[0] * x[2] ** 3, etc.).

  • poly_include_bias – boolean If True (default), then include a bias column, the feature in which all polynomial powers are zero (i.e. a column of ones - acts as an intercept term in a linear model).

Fitted attributes:

  • n_input_features_: int

    The total number of input features.

  • n_output_features_: int

    The total number of polynomial output features. The number of output features is computed by iterating over all suitably sized combinations of input features.

source on GitHub

__init__(kind='poly', poly_degree=2, poly_interaction_only=False, poly_include_bias=True)[source]

Initialize self. See help(type(self)) for accurate signature.

_fit_poly(X, y=None)[source]

Fitting method for the polynomial features.

source on GitHub

_get_feature_names_poly(input_features=None)[source]

Returns feature names for output features for the polynomial features.

source on GitHub

_transform_poly(X)[source]

Transforms data to polynomial features.

source on GitHub

_transform_poly_slow(X)[source]

Transforms data to polynomial features.

source on GitHub

fit(X, y=None)[source]

Compute number of output features.

Parameters

X – array-like, shape (n_samples, n_features) The data.

Returns

self : instance

source on GitHub

get_feature_names(input_features=None)[source]

Returns feature names for output features.

Parameters

input_features – list of string, length n_features, optional String names for input features if available. By default, “x0”, “x1”, … “xn_features” is used.

Returns

output_feature_names : list of string, length n_output_features

source on GitHub

transform(X)[source]

Transforms data to extended features.

Parameters
  • X – array-like, shape [n_samples, n_features] The data to transform, row by row. rns

  • XP – numpy.ndarray, shape [n_samples, NP] The matrix of features, where NP is the number of polynomial features generated from the combination of inputs.

source on GitHub