LinearSVR

In [ ]:
LinearSVR(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",
          acceptable_error_margin: float = 0.1,
          max_iter: int = 100)

Creates a LinearSVR object using the Vertica SVM (Support Vector Machine) algorithm. This algorithm finds the hyperplane used to approximate distribution of the data.

Parameters

Name Type Optional Description
name
str
Name of the model to be stored in the database.
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
A bool to fit also the intercept.
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.
  • regularized : Fits the intercept and applies a regularization on it.
  • unregularized : Fits the intercept but does not include it in regularization.
acceptable_error_margin
float
Defines the acceptable error margin. Any data points outside this region add a penalty to the cost function.
max_iter
int
The maximum number of iterations that the algorithm performs.

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
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 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.
plot Draws the LinearSVR if the number of predictors is lesser than 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 database cursor.
set_params Sets the parameters of the model.
shapExplainer Creates a shapExplainer for 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_sklearn Converts this Vertica model to an sklearn model.
to_sql Returns the SQL code needed to deploy the model without using Vertica built-in functions.

Example

In [10]:
from verticapy.learn.svm import LinearSVR
model = LinearSVR(name = "winequality_svm",
                  tol = 1e-4, 
                  C = 1.0, 
                  fit_intercept = True,
                  intercept_scaling = 1.0,
                  intercept_mode = "regularized",
                  acceptable_error_margin = 0.1,
                  max_iter = 100)
display(model)
<LinearSVR>