f#

pygam.terms.f(feature, lam=0.6, penalties='auto', coding='one-hot', verbose=False)[source]#

Creates an instance of a FactorTerm.

Parameters:
featureint

Index of the feature to use for the feature function.

lamfloat or iterable of floats

Strength of smoothing penalty. Must be a positive float. Larger values enforce stronger smoothing.

If single value is passed, it will be repeated for every penalty.

If iterable is passed, the length of lam must be equal to the length of penalties

penalties{‘auto’, ‘derivative’, ‘l2’, None} or callable or iterable

Type of smoothing penalty to apply to the term.

If an iterable is used, multiple penalties are applied to the term. The length of the iterable must match the length of lam.

If ‘auto’, then 2nd derivative smoothing for ‘numerical’ dtypes, and L2/ridge smoothing for ‘categorical’ dtypes.

Custom penalties can be passed as a callable.

coding{‘one-hot’, ‘dummy’} type of contrast encoding to use.

‘one-hot’ keeps all columns while ‘dummy’ drops the first column.

Attributes:
n_coefsint

Number of coefficients contributed by the term to the model

istensorbool

whether the term is a tensor product of sub-terms

isinterceptbool

whether the term is an intercept

hasconstraintbool

whether the term has any constraints

infodict

contains dict with the sufficient information to duplicate the term

See also

FactorTerm

for developer details