LinearRegression

In [ ]:
LinearRegression(name: str,
                 cursor = None,
                 tol: float = 1e-6,
                 max_iter: int = 100, 
                 solver: str = 'Newton')

Creates a LinearRegression object with the Vertica linear regression function.

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.
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

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
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 DB cursor.
set_params Sets the parameters of the model.
shapExplainer Creates a shapExplainer for the model.
to_sklearn Converts this Vertica model to an sklearn model.

Example

In [52]:
from verticapy.learn.linear_model import LinearRegression
model = LinearRegression(name = "public.LR_winequality")
display(model)
<LinearRegression>