Lasso¶
In [ ]:
Lasso(name: str,
cursor = None,
tol: float = 1e-6,
C: float = 1.0,
max_iter: int = 100,
solver: str = 'CGD')
Creates a Lasso object using the Vertica Linear Regression function. The Lasso is a regularized regression method and uses an L1 penalty.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
name | str | ❌ | Name of the model to be stored in the database. |
cursor | DBcursor | ✓ | Vertica DB cursor. |
tol | float | ✓ | Determines whether the algorithm has reached the specified accuracy result. |
C | float | ✓ | The regularization parameter value. The value must be zero or non-negative. |
max_iter | int | ✓ | Determines the maximum number of iterations the algorithm performs before achieving the specified accuracy result. |
solver | str | ✓ | The optimizer method to use to train the model.
|
Attributes¶
After the object is created, all parameters become attributes. Additional attributes will be created when fitting the model:
| Name | Type | Description |
|---|---|---|
coef_ | tablesample | Coefficients and their mathematical information (pvalue, std, value...) |
input_relation | str | Training relation. |
X | list | List of the predictors. |
y | str | Response column. |
test_relation | str | Relation to use to test the model. All model methods are abstractions that simplify the process. The testing relation will be used by the methods to evaluate the model. If empty, the training relation will be used instead. This attribute can be changed at any time. |
Methods¶
| Name | Description |
|---|---|
| contour | Draws the model's contour plot. |
| deploySQL | Returns the SQL code needed to deploy the model. |
| drop | Drops the model from the Vertica DB. |
| features_importance | Computes the model features importance using the Gini Index. |
| fit | Trains the model. |
| get_attr | Returns the model attribute. |
| get_params | Returns the model Parameters. |
| plot | Draws the Linear Regression if the number of predictors is equal to 1 or 2. |
| predict | Predicts using the input relation. |
| regression_report | Computes a regression report using multiple metrics to evaluate the model (r2, mse, max error...). |
| score | Computes the model score. |
| set_cursor | Sets a new database cursor. |
| set_params | Sets the parameters of the model. |
| shapExplainer | Creates a shapExplainer for the model. |
| to_memmodel | Converts a specified Vertica model to a memModel model. |
| to_python | Returns the Python code needed to deploy the model without using built-in Vertica functions. |
| to_sklearn | Converts this Vertica model to an sklearn model. |
| to_sql | Returns the SQL code needed to deploy the model without using Vertica built-in functions. |
Example¶
In [50]:
from verticapy.learn.linear_model import Lasso
model = Lasso(name = "public.LR_winequality",
tol = 1e-4,
max_iter = 100,
solver = 'CGD')
display(model)
