Class: LassoLars

Lasso model fit with Least Angle Regression a.k.a. Lars.

It is a Linear Model trained with an L1 prior as regularizer.

The optimization objective for Lasso is:

Python Reference

Constructors

new LassoLars()

new LassoLars(opts?): LassoLars

Parameters

ParameterTypeDescription
opts?object-
opts.alpha?numberConstant that multiplies the penalty term. Defaults to 1.0. alpha \= 0 is equivalent to an ordinary least square, solved by LinearRegression. For numerical reasons, using alpha \= 0 with the LassoLars object is not advised and you should prefer the LinearRegression object.
opts.copy_X?booleanIf true, X will be copied; else, it may be overwritten.
opts.eps?numberThe 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?booleanWhether 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.fit_path?booleanIf true the full path is stored in the coef_path_ attribute. If you compute the solution for a large problem or many targets, setting fit_path to false will lead to a speedup, especially with a small alpha.
opts.jitter?numberUpper bound on a uniform noise parameter to be added to the y values, to satisfy the model’s assumption of one-at-a-time computations. Might help with stability.
opts.max_iter?numberMaximum number of iterations to perform.
opts.positive?booleanRestrict 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 will 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.
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.
opts.random_state?numberDetermines random number generation for jittering. Pass an int for reproducible output across multiple function calls. See Glossary. Ignored if jitter is undefined.
opts.verbose?number | booleanSets the verbosity amount.

Returns LassoLars

Defined in generated/linear_model/LassoLars.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/linear_model/LassoLars.ts:23
_isInitializedbooleanfalsegenerated/linear_model/LassoLars.ts:22
_pyPythonBridgeundefinedgenerated/linear_model/LassoLars.ts:21
idstringundefinedgenerated/linear_model/LassoLars.ts:18
optsanyundefinedgenerated/linear_model/LassoLars.ts:19

Accessors

active_

Get Signature

get active_(): Promise<any>

Indices of active variables at the end of the path. If this is a list of list, the length of the outer list is n_targets.

Returns Promise<any>

Defined in generated/linear_model/LassoLars.ts:417


alphas_

Get Signature

get alphas_(): Promise<ArrayLike>

Maximum of covariances (in absolute value) at each iteration. n_alphas is either max_iter, n_features or the number of nodes in the path with alpha >= alpha_min, whichever is smaller. If this is a list of array-like, the length of the outer list is n_targets.

Returns Promise<ArrayLike>

Defined in generated/linear_model/LassoLars.ts:394


coef_

Get Signature

get coef_(): Promise<ArrayLike>

Parameter vector (w in the formulation formula).

Returns Promise<ArrayLike>

Defined in generated/linear_model/LassoLars.ts:463


coef_path_

Get Signature

get coef_path_(): Promise<ArrayLike[]>

If a list is passed it’s expected to be one of n_targets such arrays. The varying values of the coefficients along the path. It is not present if the fit_path parameter is false. If this is a list of array-like, the length of the outer list is n_targets.

Returns Promise<ArrayLike[]>

Defined in generated/linear_model/LassoLars.ts:440


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/LassoLars.ts:557


intercept_

Get Signature

get intercept_(): Promise<number | ArrayLike>

Independent term in decision function.

Returns Promise<number | ArrayLike>

Defined in generated/linear_model/LassoLars.ts:486


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/LassoLars.ts:532


n_iter_

Get Signature

get n_iter_(): Promise<number | ArrayLike>

The number of iterations taken by lars_path to find the grid of alphas for each target.

Returns Promise<number | ArrayLike>

Defined in generated/linear_model/LassoLars.ts:509


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/linear_model/LassoLars.ts:101

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/LassoLars.ts:152


fit()

fit(opts): Promise<any>

Fit the model using X, y as training data.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.
opts.Xy?ArrayLikeXy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/linear_model/LassoLars.ts:169


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

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/linear_model/LassoLars.ts:213


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/linear_model/LassoLars.ts:114


predict()

predict(opts): Promise<any>

Predict using the linear model.

Parameters

ParameterTypeDescription
optsobject-
opts.X?anySamples.

Returns Promise<any>

Defined in generated/linear_model/LassoLars.ts:247


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

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample 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?ArrayLikeTrue values for X.

Returns Promise<number>

Defined in generated/linear_model/LassoLars.ts:280


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

ParameterTypeDescription
optsobject-
opts.Xy?string | booleanMetadata routing for Xy parameter in fit.

Returns Promise<any>

Defined in generated/linear_model/LassoLars.ts:326


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

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/linear_model/LassoLars.ts:362