mojolearn.LassoLars#
- class mojolearn.LassoLars(alpha=1.0, *, fit_intercept=True, verbose=False, precompute='auto', max_iter=500, eps=2.220446049250313e-16, copy_X=True, fit_path=True, positive=False, jitter=None, random_state=None)[source]#
Bases:
_LinearRegressorMixin,NumericModeMixinLasso fitted by least angle regression.
Follows scikit-learn’s LassoLars: the LARS path with the lasso modification, stopped at
alpha.jittermust be None (any other value raises ValueError).- Parameters:
alpha (float, default 1.0) – L1 regularization strength (>= 0); 0 runs the full path.
fit_intercept (bool, default True) – Whether to fit an intercept.
verbose (bool, default False) – Accepted for compatibility; ignored.
precompute (bool, ‘auto’ or array, default ‘auto’) – Accepted for compatibility; the fit always uses the Gram matrix.
max_iter (int, default 500) – Maximum number of path steps.
eps (float, default 2.220446049250313e-16) – Accepted for compatibility; ignored.
copy_X (bool, default True) – Accepted for compatibility;
Xis never modified.fit_path (bool, default True) – Accepted for compatibility; the path is not stored.
positive (bool, default False) – Restrict the weights to be non-negative.
jitter (None, default None) – Not supported: any value other than None raises ValueError.
random_state (int or None, default None) – Accepted for compatibility; ignored.
numeric_mode (str or None, default None) – Numeric mode for this model (
'identical','deterministic'or'fast', which runs on Apple GPUs only); None uses the process default (seemojolearn.set_numeric_mode()).
- Variables:
Examples
>>> import numpy as np, mojolearn >>> rng = np.random.default_rng(0) >>> X = rng.random((1000, 8), dtype=np.float32) >>> y = 3 * X[:, 0] - 2 * X[:, 1] >>> model = mojolearn.LassoLars(alpha=0.01).fit(X, y)
- __init__(alpha=1.0, *, fit_intercept=True, verbose=False, precompute='auto', max_iter=500, eps=2.220446049250313e-16, copy_X=True, fit_path=True, positive=False, jitter=None, random_state=None)[source]#
Methods
fit(X, y)Fit the model.
get_params([deep])numeric_mode_used()The numeric mode this estimator runs in.
predict(X)Predict targets for
X.score(X, y)Coefficient of determination R^2 of
predict(X)againsty.set_params(**params)Set constructor parameters.
vendor_used()The GPU backend this estimator runs on.
- fit(X, y)[source]#
Fit the model.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Training data, converted to float32; values must be finite.
y (array-like of shape (n_samples,)) – Targets.
- Returns:
self (LassoLars) – The fitted model.
- Raises:
ValueError – If
alphais negative orjitteris not None.