LinearSVC¶
In [ ]:
LinearSVC(name: str,
cursor = None,
tol: float = 1e-4,
C: float = 1.0,
fit_intercept: bool = True,
intercept_scaling: float = 1.0,
intercept_mode: str = "regularized",
class_weight: list = [1, 1],
max_iter: int = 100)
Creates a LinearSVC object using the Vertica SVM (Support Vector Machine) algorithm. Given a set of training examples, each marked as belonging to one of two categories, an SVM training algorithm builds a model that assigns new examples to each category, making it a non-probabilistic binary linear classifier.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
name | str | ❌ | Name of the model to be stored in the DB. |
cursor | DBcursor | ✓ | Vertica DB cursor. |
tol | float | ✓ | to use to control accuracy. |
C | float | ✓ | The weight for misclassification cost. The algorithm minimizes the regularization cost and the misclassification cost. |
fit_intercept | bool | ✓ | Whether to calculate the intercept for the model. |
intercept_scaling | float | ✓ | A float value, serves as the value of a dummy feature whose coefficient Vertica uses to calculate the model intercept. Because the dummy feature is not in the training data, its values are set to a constant, by default set to 1. |
intercept_mode | str | ✓ | Specify how to treat the intercept.
|
class_weight | list | ✓ | Specifies how to determine weights of the two classes. It can be a list of 2 elements or one of the following method:
|
max_iter | int | ✓ | The maximum number of iterations that the algorithm performs. |
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 | float | 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's confusion matrix. |
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 LinearSVC hyperplan coefficients. |
fit | Trains the model. |
get_attr | Returns the model attribute. |
get_params | Returns the model Parameters. |
lift_chart | Draws the model Lift Chart. |
plot | Draws the LinearSVC if the number of predictors is less than 3. |
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 an sklearn model. |
Example¶
In [8]:
from verticapy.learn.svm import LinearSVC
model = LinearSVC(name = "iris_svm",
tol = 1e-4,
C = 1.0,
fit_intercept = True,
intercept_scaling = 1.0,
intercept_mode = "regularized",
class_weight = [1, 1],
max_iter = 100)
display(model)