fracridge.FracRidgeRegressorCV

class FracRidgeRegressorCV(fit_intercept=False, normalize=False, copy_X=True, tol=1e-10, jit=True, cv=None, scoring=None)[source]

Uses sklearn.model_selection.GridSearchCV to find the best value of frac given the data, using cross-validation.

Parameters
fit_interceptbool, optional

Whether to fit an intercept term. Default: False.

normalizebool, optional

Whether to normalize the columns of X. Default: False.

copy_Xbool, optional

Whether to make a copy of the X matrix before fitting. Default: True.

tolfloat, optional.

Tolerance under which singular values of the X matrix are considered to be zero. Default: 1e-10.

jitbool, optional.

Whether to use jit-accelerated implementation. Default: True.

cvint, cross-validation generator or an iterable

See https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html # noqa

scoringstr, callable, list/tuple or dict, default=None

See https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html # noqa

Examples

Generate random data:

>>> np.random.seed(1)
>>> y = np.random.randn(100)
>>> X = np.random.randn(100, 10)

Fit model with cross-validation:

>>> frcv = FracRidgeRegressorCV()
>>> frcv.fit(X, y, frac_grid=np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ]))
FracRidgeRegressorCV()
>>> print(frcv.best_frac_)
0.1
Attributes
best_frac_float

The best fraction as determined by cross-validation.

alpha_ndarray, shape (b)

The alpha coefficients associated with this fraction for each target.

coef_ndarray, shape (p, b)

The coefficients corresponding to the best solution. Where p number of parameters and b number of targets.

__init__(fit_intercept=False, normalize=False, copy_X=True, tol=1e-10, jit=True, cv=None, scoring=None)[source]
fit(X, y, sample_weight=None, frac_grid=None)[source]
Parameters
frac_gridsequence or float, optional

The values of frac to consider. Default: np.arange(.1, 1.1, .1)

get_params(deep=True)

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsdict

Parameter names mapped to their values.

score(X, y, sample_weight=None)

Score the fracridge fit

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters
**paramsdict

Estimator parameters.

Returns
selfestimator instance

Estimator instance.

Examples using fracridge.FracRidgeRegressorCV