ElasticNet

In [ ]:
ElasticNet(name: str,
           tol: float = 1e-6, 
           C: float = 1.0, 
           max_iter: int = 100, 
           solver: str = 'CGD', 
           l1_ratio: float = 0.5,
           fit_intercept: bool = True)

Creates a ElasticNet object by using the Vertica linear regression function on the data. Elastic net regularization is a regularized regression method that linearly combines the L1 and L2 penalties of the Lasso and Ridge methods.

Parameters

Name Type Optional Description
name
str
Name of the model to be stored in the database.
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.
  • Newton : Newton Method
  • BFGS : Broyden Fletcher Goldfarb Shanno
  • CGD : Coordinate Gradient Descent
l1_ratio
float
ENet mixture parameter that defines how much L1 versus L2 regularization to provide.
fit_intercept
bool
Boolean, specifies whether the model includes an intercept. If False, intercepts are not used when training the model. fit_intercept should not be False when using the BFGS optimizer.

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 importance of model features 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 / report Computes a regression report using multiple metrics to evaluate the model (r2, mse, max error...).
score Computes the model score.
set_params Sets the parameters of 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_sql Returns the SQL code needed to deploy the model without using Vertica built-in functions.

Example

In [49]:
from verticapy.learn.linear_model import ElasticNet
model = ElasticNet(name = "public.LR_winequality",
                   tol = 1e-4, 
                   C = 1.0, 
                   max_iter = 100, 
                   solver = 'CGD', 
                   l1_ratio = 0.5)
display(model)
<LinearRegression>