generalized_additive_models.Intercept#

class generalized_additive_models.Intercept#

An intercept term.

Examples

>>> intercept = Intercept()
>>> intercept.num_coefficients
1
>>> import numpy as np
>>> X = np.random.randn(5, 3)
>>> intercept.fit_transform(X)
array([[1.],
       [1.],
       [1.],
       [1.],
       [1.]])

Intercepts have no penalty:

>>> intercept.penalty_matrix()
array([[0.]])

Terms can yield themselves once, like so:

>>> list(intercept)
[Intercept()]
__init__()#

Initialize an Intercept.

Methods

__init__()

Initialize an Intercept.

fit(X)

Fit to data.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

is_redundant_with_respect_to(other)

Check if a Term is redundant with respect to another.

penalty_matrix()

Return the penalty matrix for the term.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Transform the input.

Attributes

by

Multiplicative feature, not used in Intercept.

feature

Feature name, not used in Intercept.

name

Name of the term.

num_coefficients

Number of coefficients for the term.

by = None#

Multiplicative feature, not used in Intercept.

feature = None#

Feature name, not used in Intercept.

fit(X)#

Fit to data.

Parameters:

X (np.ndarray or pd.DataFrame) – A dataset of shape (num_samples, num_features).

name = 'intercept'#

Name of the term.

property num_coefficients#

Number of coefficients for the term.

penalty_matrix()#

Return the penalty matrix for the term. Intercepts have no penalty.

transform(X)#

Transform the input.

Parameters:

X (np.ndarray or pd.DataFrame) – A dataset of shape (num_samples, num_features).

Returns:

X – An ndarray for the term.

Return type:

np.ndarray

Examples

>>> intercept = Intercept()
>>> X = np.eye(3)
>>> intercept.fit_transform(X)
array([[1.],
       [1.],
       [1.]])