Documentation
Classes
LassoLarsIC

LassoLarsIC

Lasso model fit with Lars using BIC or AIC for model selection.

The optimization objective for Lasso is:

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new LassoLarsIC(opts?: object): LassoLarsIC;

Parameters

NameTypeDescription
opts?object-
opts.copy_X?booleanIf true, X will be copied; else, it may be overwritten. Default Value true
opts.criterion?"aic" | "bic"The type of criterion to use. Default Value 'aic'
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). Default Value true
opts.max_iter?numberMaximum number of iterations to perform. Can be used for early stopping. Default Value 500
opts.noise_variance?numberThe estimated noise variance of the data. If undefined, an unbiased estimate is computed by an OLS model. However, it is only possible in the case where n\_samples > n\_features + fit\_intercept.
opts.normalize?booleanThis parameter is ignored when fit\_intercept is set to false. If true, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. If you wish to standardize, please use StandardScaler before calling fit on an estimator with normalize=False. Default Value false
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 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 LassoLarsIC only makes sense for problems where a sparse solution is expected and/or reached. 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.verbose?number | booleanSets the verbosity amount. Default Value false

Returns

LassoLarsIC

Defined in: generated/linear_model/LassoLarsIC.ts:23 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/linear_model/LassoLarsIC.ts:21 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/linear_model/LassoLarsIC.ts:20 (opens in a new tab)

_py

PythonBridge

Defined in: generated/linear_model/LassoLarsIC.ts:19 (opens in a new tab)

id

string

Defined in: generated/linear_model/LassoLarsIC.ts:16 (opens in a new tab)

opts

any

Defined in: generated/linear_model/LassoLarsIC.ts:17 (opens in a new tab)

Accessors

alpha_

the alpha parameter chosen by the information criterion

Signature

alpha_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/LassoLarsIC.ts:349 (opens in a new tab)

alphas_

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 a list, it will be of length n\_targets.

Signature

alphas_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/linear_model/LassoLarsIC.ts:372 (opens in a new tab)

coef_

parameter vector (w in the formulation formula)

Signature

coef_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/linear_model/LassoLarsIC.ts:301 (opens in a new tab)

criterion_

The value of the information criteria (‘aic’, ‘bic’) across all alphas. The alpha which has the smallest information criterion is chosen, as specified in [1].

Signature

criterion_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/linear_model/LassoLarsIC.ts:418 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/linear_model/LassoLarsIC.ts:493 (opens in a new tab)

intercept_

independent term in decision function.

Signature

intercept_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/LassoLarsIC.ts:324 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/LassoLarsIC.ts:468 (opens in a new tab)

n_iter_

number of iterations run by lars_path to find the grid of alphas.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/LassoLarsIC.ts:395 (opens in a new tab)

noise_variance_

The estimated noise variance from the data used to compute the criterion.

Signature

noise_variance_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/LassoLarsIC.ts:443 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/linear_model/LassoLarsIC.ts:94 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/linear_model/LassoLarsIC.ts:98 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/linear_model/LassoLarsIC.ts:157 (opens in a new tab)

fit()

Fit the model using X, y as training data.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.
opts.copy_X?booleanIf provided, this parameter will override the choice of copy_X made at instance creation. If true, X will be copied; else, it may be overwritten.
opts.y?ArrayLikeTarget values. Will be cast to X’s dtype if necessary.

Returns

Promise<any>

Defined in: generated/linear_model/LassoLarsIC.ts:174 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/linear_model/LassoLarsIC.ts:107 (opens in a new tab)

predict()

Predict using the linear model.

Signature

predict(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?anySamples.

Returns

Promise<any>

Defined in: generated/linear_model/LassoLarsIC.ts:221 (opens in a new tab)

score()

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.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
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?ArrayLikeSample weights.
opts.y?ArrayLikeTrue values for X.

Returns

Promise<number>

Defined in: generated/linear_model/LassoLarsIC.ts:254 (opens in a new tab)