fracridge.FracRidgeRegressorCV¶
- class FracRidgeRegressorCV(fit_intercept=False, copy_X=True, tol=1e-10, jit=True, cv=None, scoring=None)[source]¶
Uses
sklearn.model_selection.GridSearchCVto find the best value of frac given the data, using cross-validation.- Parameters:
- fit_interceptbool, optional
Whether to fit an intercept term. 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
- 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.
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
- fit(X, y, frac_grid=None)[source]¶
- Parameters:
- frac_gridsequence or float, optional
The values of frac to consider. Default: np.arange(.1, 1.1, .1)
- get_metadata_routing()¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- 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)¶
Score the fracridge fit
- set_fit_request(*, frac_grid: bool | None | str = '$UNCHANGED$') FracRidgeRegressorCV¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
- frac_gridstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
frac_gridparameter infit.
- Returns:
- selfobject
The updated object.
- 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¶
Integrating FracRidge objects into sklearn pipelines