:mod:`heat.regression.lasso` ============================ .. py:module:: heat.regression.lasso .. autoapi-nested-parse:: Implementation of the LASSO regression Module Contents --------------- .. py:class:: Lasso(lam: Optional[float] = 0.1, max_iter: Optional[int] = 100, tol: Optional[float] = 1e-06) Bases: :class:`heat.RegressionMixin`, :class:`heat.BaseEstimator` ``Least absolute shrinkage and selection operator``(LASSO), a linear model with L1 regularization. The optimization objective for Lasso is: .. math:: E(w) = \frac{1}{2 m} ||y - Xw||^2_2 + \lambda ||w\_||_1 with .. math:: w\_=(w_1,w_2,...,w_n), w=(w_0,w_1,w_2,...,w_n), .. math:: y \in M(m \times 1), w \in M(n \times 1), X \in M(m \times n) :param lam: Constant that multiplies the L1 term. Default value: 0.1 ``lam = 0.`` is equivalent to an ordinary least square (OLS). For numerical reasons, using ``lam = 0.,`` with the ``Lasso`` object is not advised. :type lam: float, optional :param max_iter: The maximum number of iterations. Default value: 100 :type max_iter: int, optional :param tol: The tolerance for the optimization. :type tol: float, optional. Default value: 1e-8 :ivar __theta: :vartype __theta: array, shape (n_features + 1,), first element is the interception parameter vector w. :ivar coef_: parameter vector (w in the cost function formula) :vartype coef_: array, shape (n_features,) | (n_targets, n_features) :ivar intercept_: independent term in decision function. :vartype intercept_: float | array, shape (n_targets,) :ivar n_iter_: number of iterations run by the coordinate descent solver to reach the specified tolerance. :vartype n_iter_: int or None | array-like, shape (n_targets,) .. rubric:: Examples >>> X = ht.random.randn(10, 4, split=0) >>> y = ht.random.randn(10, 1, split=0) >>> estimator = ht.regression.lasso.Lasso(max_iter=100, tol=None) >>> estimator.fit(X, y) .. attribute:: __lam :annotation: = 0.1 .. attribute:: max_iter :annotation: = 100 .. attribute:: tol :annotation: = 1e-06 .. attribute:: __theta :annotation: = None .. attribute:: n_iter :annotation: = None .. role:: raw-html(raw) :format: html .. method:: soft_threshold(rho: heat.core.dndarray.DNDarray) -> Union[heat.core.dndarray.DNDarray, float] Soft threshold operator :param rho: Input model data, Shape = (1,) :type rho: DNDarray :param out: Thresholded model data, Shape = (1,) :type out: DNDarray or float .. method:: rmse(gt: heat.core.dndarray.DNDarray, yest: heat.core.dndarray.DNDarray) -> heat.core.dndarray.DNDarray Root mean square error (RMSE) :param gt: Input model data, Shape = (1,) :type gt: DNDarray :param yest: Thresholded model data, Shape = (1,) :type yest: DNDarray .. method:: fit(x: heat.core.dndarray.DNDarray, y: heat.core.dndarray.DNDarray) -> None Fit lasso model with coordinate descent :param x: Input data, Shape = (n_samples, n_features) :type x: DNDarray :param y: Labels, Shape = (n_samples,) :type y: DNDarray .. method:: predict(x: heat.core.dndarray.DNDarray) -> heat.core.dndarray.DNDarray Apply lasso model to input data. First row data corresponds to interception :param x: Input data, Shape = (n_samples, n_features) :type x: DNDarray