Plastic Net¶
Classes¶
-
class
plasticnet.classes.Regression(X, y)[source]¶ This class encapsulates a regression problem. It stores the data matrix \(X\) and the target \(\vec{y}\), and provides as methods all of the in-place solvers in
plasticnet.solvers.in_place. It also stores the coefficient vector \(\vec{\beta}\), and the penalized regression target vectors \(\vec{\xi}\) (L1 target) and \(\vec{\zeta}\) (L2 target). Calling any of thefit_methods below will update \(\vec{\beta}\) in-place.Parameters: - X (numpy.ndarray) – shape (N,D) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
Variables: - beta (numpy.ndarray) – shape (D,) coefficient vector
- xi (numpy.ndarray) – shape (D,) L1 coefficient target vector
- zeta (numpy.ndarray) – shape (D,) L2 coefficient target vector
-
beta¶ beta is a property becasue when setting \(\vec{\beta}\) you also need to set \(\vec{r}\) such that \(\vec{r} = \vec{y} - X\vec{\beta}\). Via the property implementation you can transparently get and set it like a normal attribute.
-
fit_elastic_net(lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ In-place elastic net regression. See
plasticnet.solvers.in_place.elastic_net_()for documentation.
-
fit_general_plastic_net(lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ In-place general plastic net regression. See
plasticnet.solvers.in_place.general_plastic_net_()for documentation.
-
fit_hard_plastic_net(lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ In-place hard plastic net regression. See
plasticnet.solvers.in_place.hard_plastic_net_()for documentation.
-
fit_lasso(lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ In-place lasso regression. See
plasticnet.solvers.in_place.lasso_()for documentation.
-
fit_ordinary_least_squares(tol=1e-08, max_iter=1000)[source]¶ In-place ordinary least squares regression. See
plasticnet.solvers.in_place.ordinary_least_squares_()for documentation.
-
fit_plastic_lasso(lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ In-place plastic lasso regression. See
plasticnet.solvers.in_place.plastic_lasso_()for documentation.
-
fit_plastic_ridge(lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ In-place plastic ridge regression. See
plasticnet.solvers.in_place.plastic_ridge_()for documentation.
-
fit_ridge(lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ In-place ridge regression. See
plasticnet.solvers.in_place.ridge_()for documentation.
-
fit_soft_plastic_net(lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ In-place sof t plastic net regression. See
plasticnet.solvers.in_place.soft_plastic_net_()for documentation.
-
fit_unified_plastic_net(lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ In-place unified plastic net regression. See
plasticnet.solvers.in_place.unified_plastic_net_()for documentation.
User-friendly Functions¶
-
plasticnet.solvers.functional.ordinary_least_squares(X, y, tol=1e-08, max_iter=1000)[source]¶ Ordinary least squares regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N}||\vec{y}-X\vec{\beta}||_2^2\]Parameters: - X (numpy.ndarray) – shape (N,D) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.ridge(X, y, lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ Ridge regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \tfrac{1}{2} ||\vec{\beta}||_2^2\]Parameters: - X (numpy.ndarray) – shape (N,D) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.lasso(X, y, lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ Lasso regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda ||\vec{\beta}||_1\]Parameters: - X (numpy.ndarray) – shape (N,D) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.elastic_net(X, y, lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ Elastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}||_2^2 \bigr)\]Parameters: - X (numpy.ndarray) – shape (N,D) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.general_plastic_net(X, y, xi, zeta, lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ General plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}-\vec{\zeta}||_2^2 \bigr)\]Parameters: - X (numpy.ndarray) – shape (N,P) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- xi (numpy.ndarray) – shape (P,) target for L1 penalty.
- zeta (numpy.ndarray) – shape (P,) target for L2 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.plastic_ridge(X, y, zeta, lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ Plastic ridge regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \tfrac{1}{2} ||\vec{\beta}-\vec{\zeta}||_2^2\]Parameters: - X (numpy.ndarray) – shape (N,P) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- zeta (numpy.ndarray) – shape (P,) target for L2 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.plastic_lasso(X, y, xi, lambda_total=1.0, tol=1e-08, max_iter=1000)[source]¶ Plastic lasso regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda ||\vec{\beta}-\vec{\xi}||_1\]Parameters: - X (numpy.ndarray) – shape (N,P) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- xi (numpy.ndarray) – shape (P,) target for L1 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.hard_plastic_net(X, y, xi, lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ Hard plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}||_2^2 \bigr)\]Parameters: - X (numpy.ndarray) – shape (N,P) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- xi (numpy.ndarray) – shape (P,) target for L1 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.soft_plastic_net(X, y, zeta, lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ Soft plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}-\vec{\zeta}||_2^2 \bigr)\]Parameters: - X (numpy.ndarray) – shape (N,P) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- zeta (numpy.ndarray) – shape (P,) target for L2 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
-
plasticnet.solvers.functional.unified_plastic_net(X, y, xi, lambda_total=1.0, alpha=0.75, tol=1e-08, max_iter=1000)[source]¶ Unified plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}-\vec{\xi}||_2^2 \bigr)\]Parameters: - X (numpy.ndarray) – shape (N,P) data matrix.
- y (numpy.ndarray) – shape (N,) target vector.
- xi (numpy.ndarray) – shape (P,) target for both L1 and L2 penalties.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: shape (D,) coefficient vector.
Return type:
In-place Functions¶
-
plasticnet.solvers.in_place.ordinary_least_squares_(beta, r, X, tol=1e-8, max_iter=1000)[source]¶ Ordinary least squares regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N}||\vec{y}-X\vec{\beta}||_2^2\]Parameters: - beta (numpy.ndarray) – shape (D,) coefficient vector. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,D) data matrix.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.ridge_(beta, r, X, lambda_total=1.0, tol=1e-8, max_iter=1000)[source]¶ Ridge regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \tfrac{1}{2} ||\vec{\beta}||_2^2\]Parameters: - beta (numpy.ndarray) – shape (D,) coefficient vector. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,D) data matrix.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
Returns: tuple
(converged, iter_num)containing convergence information.converged(bool) is whether or not the algorithm converged in the alloted number of iterations) anditer_num(int) is how many iterations the algorithm ran for.Return type: converged (tuple)
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.lasso_(beta, r, X, lambda_total=1.0, tol=1e-8, max_iter=1000)[source]¶ Lasso regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda ||\vec{\beta}||_1\]Parameters: - beta (numpy.ndarray) – shape (D,) coefficient vector. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,D) data matrix.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.elastic_net_(beta, r, X, lambda_total=1.0, alpha=0.75, tol=1e-8, max_iter=1000)[source]¶ Elastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}||_2^2 \bigr)\]Parameters: - beta (numpy.ndarray) – shape (D,) coefficient vector. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,D) data matrix.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.general_plastic_net_(beta, r, X, xi, zeta, lambda_total=1.0, alpha=0.75, tol=1e-8, max_iter=1000)[source]¶ General plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}-\vec{\zeta}||_2^2 \bigr)\]Parameters: - beta (numpy.ndarray) – shape (P,) initial guess for the solution to the regression. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,P) data matrix.
- xi (numpy.ndarray) – shape (P,) target for L1 penalty.
- zeta (numpy.ndarray) – shape (P,) target for L2 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.plastic_ridge_(beta, r, X, zeta, lambda_total=1.0, tol=1e-8, max_iter=1000)[source]¶ Plastic ridge regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \tfrac{1}{2} ||\vec{\beta}-\vec{\zeta}||_2^2\]Parameters: - beta (numpy.ndarray) – shape (P,) initial guess for the solution to the regression. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,P) data matrix.
- zeta (numpy.ndarray) – shape (P,) target for L2 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.plastic_lasso_(beta, r, X, xi, lambda_total=1.0, tol=1e-8, max_iter=1000)[source]¶ Plastic lasso regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda ||\vec{\beta}-\vec{\xi}||_1\]Parameters: - beta (numpy.ndarray) – shape (P,) initial guess for the solution to the regression. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,P) data matrix.
- xi (numpy.ndarray) – shape (P,) target for L1 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.hard_plastic_net_(beta, r, X, xi, lambda_total=1.0, alpha=0.75, tol=1e-8, max_iter=1000)[source]¶ Hard plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}||_2^2 \bigr)\]Parameters: - beta (numpy.ndarray) – shape (P,) initial guess for the solution to the regression. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,P) data matrix.
- xi (numpy.ndarray) – shape (P,) target for L1 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.soft_plastic_net_(beta, r, X, zeta, lambda_total=1.0, alpha=0.75, tol=1e-8, max_iter=1000)[source]¶ Soft plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}-\vec{\zeta}||_2^2 \bigr)\]Parameters: - beta (numpy.ndarray) – shape (P,) initial guess for the solution to the regression. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,P) data matrix.
- zeta (numpy.ndarray) – shape (P,) target for L2 penalty.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).
-
plasticnet.solvers.in_place.unified_plastic_net_(beta, r, X, xi, lambda_total=1.0, alpha=0.75, tol=1e-8, max_iter=1000)[source]¶ Unified plastic net regression. This function finds the \(\vec{\beta}\) that minimizes
\[\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}-\vec{\xi}||_2^2 \bigr)\]Parameters: - beta (numpy.ndarray) – shape (P,) initial guess for the solution to the regression. modified in-place.
- r (numpy.ndarray) – shape (N,) residual, i.e \(\vec{r} = \vec{y} - X\vec{\beta}\). modified in-place.
- X (numpy.ndarray) – shape (N,P) data matrix.
- xi (numpy.ndarray) – shape (P,) target for both L1 and L2 penalties.
- lambda_total (float) – must be non-negative. total regularization penalty strength.
- alpha (float) – mixing parameter between L1 and L1 penalties. must be between zero and one. \(\alpha=0\) is pure L2 penalty, \(\alpha=1\) is pure L1 penalty.
- tol (float) – convergence criterion for coordinate descent. coordinate descent runs until the maximum element-wise change in beta is less than tol.
- max_iter (int) – maximum number of update passes through all P elements of beta, in case tol is never met.
- Note
- beta and r are modified in-place. As inputs, if \(\vec{\beta} = 0\), then it must be the case that \(\vec{r} = \vec{y}\), or the function will not converge to the correct answer. In general, the inputs beta and r must be coordinated such that \(\vec{r} = \vec{y} - X\vec{\beta}\).