LogisticRegression¶
In [ ]:
LogisticRegression(name: str,
cursor = None,
penalty: str = 'ENet',
tol: float = 1e-4,
C: float = 1.0,
max_iter: int = 100,
solver: str = 'CGD',
l1_ratio: float = 0.5)
Creates a LogisticRegression object using the Vertica LOGISTIC_REG function.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
name | str | ❌ | Name of the model to be stored in the database. |
cursor | DBcursor | ✓ | Vertica DB cursor. |
penalty | str | ✓ | Determines the method of regularization.
|
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.
|
l1_ratio | float | ✓ | ENet mixture parameter that defines how much L1 versus L2 regularization to provide. |
Attributes¶
After the object creation, all the parameters become attributes. The model will also create extra attributes 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 |
---|---|
classification_report | Computes a classification report using multiple metrics to evaluate the model (AUC, accuracy, PRC AUC, F1...). In case of multiclass classification, it will consider each category as positive and switch to the next one during the computation. |
confusion_matrix | Computes the model confusion matrix. |
cutoff_curve | Draws the model Cutoff curve. |
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 by normalizing the Logistic Regression coefficients. |
fit | Trains the model. |
lift_chart | Draws the model Lift Chart. |
plot | Draws the Logistic Regression if the number of predictors is equal to 1 or 2. |
get_attr | Returns the model attribute. |
get_params | Returns the model Parameters. |
prc_curve | Draws the model precision-recall curve. |
predict | Predicts using the input relation. |
roc_curve | Draws the model ROC curve. |
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_sklearn | Converts this Vertica Model to sklearn model. |
Example¶
In [4]:
from verticapy.learn.linear_model import LogisticRegression
model = LogisticRegression(name = "public.LR_titanic",
tol = 1e-4,
C = 1.0,
max_iter = 100,
solver = 'CGD',
l1_ratio = 0.5)
display(model)