LogisticRegression¶
In [ ]:
LogisticRegression(name: str,
penalty: str = 'ENet',
tol: float = 1e-4,
C: float = 1.0,
max_iter: int = 100,
solver: str = 'CGD',
l1_ratio: float = 0.5,
fit_intercept: bool = True)
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. |
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. |
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 BFGS optimizer. |
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 / 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. |
| contour | Draws the model's contour plot. |
| 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. |
| predict_proba | Returns the model's probabilities using the input relation. |
| roc_curve | Draws the model ROC curve. |
| 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 [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)
