adelie.sklearn.GroupElasticNet#
- class adelie.sklearn.GroupElasticNet(solver: str = 'grpnet', family: str = 'gaussian')[source]#
Group Elastic Net estimator with scikit-learn compatible API.
- Parameters:
- solverstr, optional
The solver to use. It must be one of the following:
"grpnet"
"cv_grpnet"
Default is
"grpnet"
.- familystr, optional
The family of the response variable. It must be one of the following:
"gaussian"
"binomial"
"poisson"
"multigaussian"
"multinomial"
Default is
"gaussian"
.
Methods
__init__
([solver, family])Initialize the GroupElasticNet estimator.
fit
(X, y, **kwargs)Fit the Group Elastic Net model.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
predict
(X)Predict using the fitted Group Elastic Net model.
Predict class probabilities.
score
(X, y)Compute the R-squared score of the model.
set_params
(**params)Set the parameters of this estimator.
- __init__(solver: str = 'grpnet', family: str = 'gaussian')[source]#
Initialize the GroupElasticNet estimator.
- fit(X: ndarray | MatrixNaiveBase32 | MatrixNaiveBase64, y: ndarray, **kwargs: Dict[str, Any])[source]#
Fit the Group Elastic Net model.
- Parameters:
- X(n, p) Union[ndarray, MatrixNaiveBase32, MatrixNaiveBase64]
Feature matrix. It is typically one of the matrices defined in
adelie.matrix
submodule ornumpy.ndarray
.- y(n,) ndarray
Response vector.
- **kwargsDict[str, Any], optional
Additional arguments to pass to the solver.
- Returns:
- self
Returns an instance of self.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequest
encapsulating 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.
- predict(X: ndarray) ndarray [source]#
Predict using the fitted Group Elastic Net model.
If
self.family
is either"binomial"
or"multinomial"
, the output is class label predictions based on the largest probability predictions. Otherwise, the output is linear predictions.- Parameters:
- X(n, p) Union[ndarray, MatrixNaiveBase32, MatrixNaiveBase64]
Feature matrix. It is typically one of the matrices defined in
adelie.matrix
submodule ornumpy.ndarray
.
- Returns:
- predsndarray
The class or linear predictions at
X
.
- predict_proba(X: ndarray | MatrixNaiveBase32 | MatrixNaiveBase64) ndarray [source]#
Predict class probabilities.
This method is only available for
"binomial"
and"multinomial"
families.- Parameters:
- X(n, p) Union[ndarray, MatrixNaiveBase32, MatrixNaiveBase64]
Feature matrix. It is typically one of the matrices defined in
adelie.matrix
submodule ornumpy.ndarray
.
- Returns:
- probandarray
The class probabilities at
X
.
- score(X: ndarray, y: ndarray) float [source]#
Compute the R-squared score of the model.
- Parameters:
- X(n, p) Union[ndarray, MatrixNaiveBase32, MatrixNaiveBase64]
Feature matrix. It is typically one of the matrices defined in
adelie.matrix
submodule ornumpy.ndarray
.- y(n,) ndarray
Response vector.
- Returns:
- R2float
The R-squared score.
- 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.