mojolearn.PolynomialFeatures#

class mojolearn.PolynomialFeatures(degree=2, *, interaction_only=False, include_bias=True, order='C')#

Generate polynomial and interaction features.

Follows scikit-learn’s PolynomialFeatures, with the same output column order: the bias column, then the products of input columns degree by degree (combinations with replacement, or without when interaction_only). Input and output are float32.

Parameters:
  • degree (int or tuple of (int, int), default 2) – Largest degree, or (min_degree, max_degree). Negative values or min_degree > max_degree raise ValueError.

  • interaction_only (bool, default False) – Only products of distinct columns (no powers of one column).

  • include_bias (bool, default True) – Include the constant column of ones.

  • order ({‘C’, ‘F’}, default ‘C’) – Memory order of the output array; 'F' returns the same values column-major.

Variables:
  • powers_ (array of shape (n_output_features_, n_features_in_)) – Exponent of each input column in each output column.

  • n_features_in_ (int) – Number of columns seen in fit.

  • n_output_features_ (int) – Number of output columns.

  • numeric_mode_ (str) – Numeric mode at fit time; transform runs in the same mode.

Examples

>>> import numpy as np, mojolearn
>>> X = np.arange(6, dtype=np.float32).reshape(3, 2)
>>> mojolearn.PolynomialFeatures(degree=2).fit_transform(X)

See also

User guide: Preprocessing

Choosing an estimator

Methods

fit(X[, y])

fit_transform(X[, y])

Fit to X, then transform X.

get_params([deep])

Return the constructor parameters as a dict.

set_params(**params)

Set constructor parameters.

transform(X)

fit_transform(X, y=None, **fit_params)#

Fit to X, then transform X.

Returns:

array – The transformed data.

get_params(deep=True)#

Return the constructor parameters as a dict.

Parameters:

deep (bool, default True) – Accepted for scikit-learn compatibility.

Returns:

dict – Parameter names mapped to their values.

set_params(**params)#

Set constructor parameters.

An unknown parameter name raises ValueError.

Returns:

self