Lasso linear model with iterative fitting along a regularization path.
See glossary entry for cross-validation estimator.
The best model is selected by cross-validation.
The optimization objective for Lasso is:
new LassoCV(opts?: object): LassoCV;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.alphas? |
ArrayLike |
List of alphas where to compute the models. If undefined alphas are set automatically. |
opts.copy_X? |
boolean |
If true , X will be copied; else, it may be overwritten. Default Value true |
opts.cv? |
number |
Determines the cross-validation splitting strategy. Possible inputs for cv are: |
opts.eps? |
number |
Length of the path. eps=1e-3 means that alpha\_min / alpha\_max \= 1e-3 . Default Value 0.001 |
opts.fit_intercept? |
boolean |
Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). Default Value true |
opts.max_iter? |
number |
The maximum number of iterations. Default Value 1000 |
opts.n_alphas? |
number |
Number of alphas along the regularization path. Default Value 100 |
opts.n_jobs? |
number |
Number of CPUs to use during the cross validation. undefined means 1 unless in a joblib.parallel\_backend context. \-1 means using all processors. See Glossary for more details. |
opts.positive? |
boolean |
If positive, restrict regression coefficients to be positive. Default Value false |
opts.precompute? |
boolean | ArrayLike [] | "auto" |
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument. Default Value 'auto' |
opts.random_state? |
number |
The seed of the pseudo random number generator that selects a random feature to update. Used when selection == ‘random’. Pass an int for reproducible output across multiple function calls. See Glossary. |
opts.selection? |
"random" | "cyclic" |
If set to ‘random’, a random coefficient is updated every iteration rather than looping over features sequentially by default. This (setting to ‘random’) often leads to significantly faster convergence especially when tol is higher than 1e-4. Default Value 'cyclic' |
opts.tol? |
number |
The tolerance for the optimization: if the updates are smaller than tol , the optimization code checks the dual gap for optimality and continues until it is smaller than tol . Default Value 0.0001 |
opts.verbose? |
number | boolean |
Amount of verbosity. Default Value false |
Defined in: generated/linear_model/LassoCV.ts:27
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/linear_model/LassoCV.ts:188
Fit linear model with coordinate descent.
Fit is on grid of alphas and best alpha estimated by cross-validation.
fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output, X can be sparse. |
opts.sample_weight? |
number | ArrayLike |
Sample weights used for fitting and evaluation of the weighted mean squared error of each cv-fold. Note that the cross validated MSE that is finally used to find the best model is the unweighted mean over the (weighted) MSEs of each test fold. |
opts.y? |
ArrayLike |
Target values. |
Promise
<any
>
Defined in: generated/linear_model/LassoCV.ts:207
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/linear_model/LassoCV.ts:256
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/linear_model/LassoCV.ts:135
Compute Lasso path with coordinate descent.
The Lasso optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
path(opts: object): Promise<ArrayLike>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse. |
opts.Xy? |
ArrayLike |
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed. |
opts.alphas? |
ArrayLike |
List of alphas where to compute the models. If undefined alphas are set automatically. |
opts.coef_init? |
ArrayLike |
The initial values of the coefficients. |
opts.copy_X? |
boolean |
If true , X will be copied; else, it may be overwritten. Default Value true |
opts.eps? |
number |
Length of the path. eps=1e-3 means that alpha\_min / alpha\_max \= 1e-3 . Default Value 0.001 |
opts.n_alphas? |
number |
Number of alphas along the regularization path. Default Value 100 |
opts.params? |
any |
Keyword arguments passed to the coordinate descent solver. |
opts.positive? |
boolean |
If set to true , forces coefficients to be positive. (Only allowed when y.ndim \== 1 ). Default Value false |
opts.precompute? |
boolean | ArrayLike [] | "auto" |
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument. Default Value 'auto' |
opts.return_n_iter? |
boolean |
Whether to return the number of iterations or not. Default Value false |
opts.verbose? |
number | boolean |
Amount of verbosity. Default Value false |
opts.y? |
any |
Target values. |
Promise
<ArrayLike
>
Defined in: generated/linear_model/LassoCV.ts:293
Predict using the linear model.
predict(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
any |
Samples. |
Promise
<any
>
Defined in: generated/linear_model/LassoCV.ts:418
Return the coefficient of determination of the prediction.
The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y\_true \- y\_pred)\*\* 2).sum()
and \(v\) is the total sum of squares ((y\_true \- y\_true.mean()) \*\* 2).sum()
. The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y
, disregarding the input features, would get a \(R^2\) score of 0.0.
score(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n\_samples, n\_samples\_fitted) , where n\_samples\_fitted is the number of samples used in the fitting for the estimator. |
opts.sample_weight? |
ArrayLike |
Sample weights. |
opts.y? |
ArrayLike |
True values for X . |
Promise
<number
>
Defined in: generated/linear_model/LassoCV.ts:451
Request metadata passed to the fit
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
set_fit_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in fit . |
Promise
<any
>
Defined in: generated/linear_model/LassoCV.ts:502
Request metadata passed to the score
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
set_score_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in score . |
Promise
<any
>
Defined in: generated/linear_model/LassoCV.ts:539
boolean
=false
Defined in: generated/linear_model/LassoCV.ts:25
boolean
=false
Defined in: generated/linear_model/LassoCV.ts:24
PythonBridge
Defined in: generated/linear_model/LassoCV.ts:23
string
Defined in: generated/linear_model/LassoCV.ts:20
any
Defined in: generated/linear_model/LassoCV.ts:21
The amount of penalization chosen by cross validation.
alpha_(): Promise<number>;
Promise
<number
>
Defined in: generated/linear_model/LassoCV.ts:572
The grid of alphas used for fitting.
alphas_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/linear_model/LassoCV.ts:662
Parameter vector (w in the cost function formula).
coef_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/linear_model/LassoCV.ts:594
The dual gap at the end of the optimization for the optimal alpha (alpha\_
).
dual_gap_(): Promise<number | ArrayLike>;
Promise
<number
| ArrayLike
>
Defined in: generated/linear_model/LassoCV.ts:685
Names of features seen during fit. Defined only when X
has feature names that are all strings.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/linear_model/LassoCV.ts:756
Independent term in decision function.
intercept_(): Promise<number | ArrayLike>;
Promise
<number
| ArrayLike
>
Defined in: generated/linear_model/LassoCV.ts:616
Mean square error for the test set on each fold, varying alpha.
mse_path_(): Promise<ArrayLike[]>;
Promise
<ArrayLike
[]>
Defined in: generated/linear_model/LassoCV.ts:639
Number of features seen during fit.
n_features_in_(): Promise<number>;
Promise
<number
>
Defined in: generated/linear_model/LassoCV.ts:731
Number of iterations run by the coordinate descent solver to reach the specified tolerance for the optimal alpha.
n_iter_(): Promise<number>;
Promise
<number
>
Defined in: generated/linear_model/LassoCV.ts:708
py(): PythonBridge;
PythonBridge
Defined in: generated/linear_model/LassoCV.ts:122
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/linear_model/LassoCV.ts:126