Class: LassoLarsCV
Cross-validated Lasso, using the LARS algorithm.
See glossary entry for cross-validation estimator.
The optimization objective for Lasso is:
Constructors
new LassoLarsCV()
new LassoLarsCV(
opts?):LassoLarsCV
Parameters
| Parameter | Type | Description |
|---|---|---|
opts? | object | - |
opts.copy_X? | boolean | If true, X will be copied; else, it may be overwritten. |
opts.cv? | number | Determines the cross-validation splitting strategy. Possible inputs for cv are: |
opts.eps? | number | The machine-precision regularization in the computation of the Cholesky diagonal factors. Increase this for very ill-conditioned systems. Unlike the tol parameter in some iterative optimization-based algorithms, this parameter does not control the tolerance of the optimization. |
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). |
opts.max_iter? | number | Maximum number of iterations to perform. |
opts.max_n_alphas? | number | The maximum number of points on the path used to compute the residuals in the cross-validation. |
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 | Restrict coefficients to be >= 0. Be aware that you might want to remove fit_intercept which is set true by default. Under the positive restriction the model coefficients do not converge to the ordinary-least-squares solution for small values of alpha. Only coefficients up to the smallest alpha value (alphas_\[alphas_ > 0.\].min() when fit_path=true) reached by the stepwise Lars-Lasso algorithm are typically in congruence with the solution of the coordinate descent Lasso estimator. As a consequence using LassoLarsCV only makes sense for problems where a sparse solution is expected and/or reached. |
opts.precompute? | boolean | "auto" | Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix cannot be passed as argument since we will use only subsets of X. |
opts.verbose? | number | boolean | Sets the verbosity amount. |
Returns LassoLarsCV
Defined in generated/linear_model/LassoLarsCV.ts:25
Properties
| Property | Type | Default value | Defined in |
|---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/LassoLarsCV.ts:23 |
_isInitialized | boolean | false | generated/linear_model/LassoLarsCV.ts:22 |
_py | PythonBridge | undefined | generated/linear_model/LassoLarsCV.ts:21 |
id | string | undefined | generated/linear_model/LassoLarsCV.ts:18 |
opts | any | undefined | generated/linear_model/LassoLarsCV.ts:19 |
Accessors
active_
Get Signature
get active_():
Promise<any>
Indices of active variables at the end of the path.
Returns Promise<any>
Defined in generated/linear_model/LassoLarsCV.ts:578
alpha_
Get Signature
get alpha_():
Promise<number>
the estimated regularization parameter alpha
Returns Promise<number>
Defined in generated/linear_model/LassoLarsCV.ts:461
alphas_
Get Signature
get alphas_():
Promise<ArrayLike>
the different values of alpha along the path
Returns Promise<ArrayLike>
Defined in generated/linear_model/LassoLarsCV.ts:484
coef_
Get Signature
get coef_():
Promise<ArrayLike>
parameter vector (w in the formulation formula)
Returns Promise<ArrayLike>
Defined in generated/linear_model/LassoLarsCV.ts:388
coef_path_
Get Signature
get coef_path_():
Promise<ArrayLike[]>
the varying values of the coefficients along the path
Returns Promise<ArrayLike[]>
Defined in generated/linear_model/LassoLarsCV.ts:436
cv_alphas_
Get Signature
get cv_alphas_():
Promise<ArrayLike>
all the values of alpha along the path for the different folds
Returns Promise<ArrayLike>
Defined in generated/linear_model/LassoLarsCV.ts:507
feature_names_in_
Get Signature
get feature_names_in_():
Promise<ArrayLike>
Names of features seen during fit. Defined only when X has feature names that are all strings.
Returns Promise<ArrayLike>
Defined in generated/linear_model/LassoLarsCV.ts:626
intercept_
Get Signature
get intercept_():
Promise<number>
independent term in decision function.
Returns Promise<number>
Defined in generated/linear_model/LassoLarsCV.ts:411
mse_path_
Get Signature
get mse_path_():
Promise<ArrayLike[]>
the mean square error on left-out for each fold along the path (alpha values given by cv_alphas)
Returns Promise<ArrayLike[]>
Defined in generated/linear_model/LassoLarsCV.ts:532
n_features_in_
Get Signature
get n_features_in_():
Promise<number>
Number of features seen during fit.
Returns Promise<number>
Defined in generated/linear_model/LassoLarsCV.ts:601
n_iter_
Get Signature
get n_iter_():
Promise<number|ArrayLike>
the number of iterations run by Lars with the optimal alpha.
Returns Promise<number | ArrayLike>
Defined in generated/linear_model/LassoLarsCV.ts:555
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge):void
Parameters
| Parameter | Type |
|---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/linear_model/LassoLarsCV.ts:94
Methods
dispose()
dispose():
Promise<void>
Disposes of the underlying Python resources.
Once dispose() is called, the instance is no longer usable.
Returns Promise<void>
Defined in generated/linear_model/LassoLarsCV.ts:146
fit()
fit(
opts):Promise<any>
Fit the model using X, y as training data.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.params? | any | Parameters to be passed to the CV splitter. |
opts.X? | ArrayLike[] | Training data. |
opts.y? | ArrayLike | Target values. |
Returns Promise<any>
Defined in generated/linear_model/LassoLarsCV.ts:163
get_metadata_routing()
get_metadata_routing(
opts):Promise<any>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRouter encapsulating routing information. |
Returns Promise<any>
Defined in generated/linear_model/LassoLarsCV.ts:207
init()
init(
py):Promise<void>
Initializes the underlying Python resources.
This instance is not usable until the Promise returned by init() resolves.
Parameters
| Parameter | Type |
|---|---|
py | PythonBridge |
Returns Promise<void>
Defined in generated/linear_model/LassoLarsCV.ts:107
predict()
predict(
opts):Promise<any>
Predict using the linear model.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.X? | any | Samples. |
Returns Promise<any>
Defined in generated/linear_model/LassoLarsCV.ts:241
score()
score(
opts):Promise<number>
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.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.sample_weight? | ArrayLike | Sample weights. |
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.y? | ArrayLike | True values for X. |
Returns Promise<number>
Defined in generated/linear_model/LassoLarsCV.ts:274
set_fit_request()
set_fit_request(
opts):Promise<any>
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:
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.Xy? | string | boolean | Metadata routing for Xy parameter in fit. |
Returns Promise<any>
Defined in generated/linear_model/LassoLarsCV.ts:320
set_score_request()
set_score_request(
opts):Promise<any>
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:
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample_weight parameter in score. |
Returns Promise<any>
Defined in generated/linear_model/LassoLarsCV.ts:356