randomized_search_cv

In [ ]:
randomized_search_cv(estimator,
                     input_relation: (str, vDataFrame),
                     X: list,
                     y: str,
                     metric: str = "auto",
                     cv: int = 3,
                     pos_label: (int, float, str) = None,
                     cutoff: float = -1,
                     nbins: int = 1000,
                     lmax: int = 4,
                     optimized_grid: int = 1,
                     print_info: bool = True,)

Computes the K-Fold randomized search of an estimator.

Parameters

Name Type Optional Description
estimator
object
Vertica estimator having a fit.
input_relation
str / vDataFrame
Input Relation.
X
list
List of the predictor columns.
y
str
Response Column.
metric
str / list
Metric used to do the model evaluation.
  • auto : logloss for classification & rmse for regression.

For Classification:
  • accuracy : Accuracy
  • auc : Area Under the Curve (ROC)
  • bm : Informedness = tpr + tnr - 1
  • csi : Critical Success Index = tp / (tp + fn + fp)
  • f1 : F1 Score
  • logloss : Log Loss
  • mcc : Matthews Correlation Coefficient
  • mk : Markedness = ppv + npv - 1
  • npv : Negative Predictive Value = tn / (tn + fn)
  • prc_auc : Area Under the Curve (PRC)
  • precision : Precision = tp / (tp + fp)
  • recall : Recall = tp / (tp + fn)
  • specificity : Specificity = tn / (tn + fp)

For Regression:
  • max : Max Error
  • mae : Mean Absolute Error
  • median : Median Absolute Error
  • mse : Mean Squared Error
  • msle : Mean Squared Log Error
  • r2 : R-squared coefficient
  • r2a : R2 adjusted
  • rmse : Root Mean Squared Error
  • var : Explained Variance
cv
int
Number of folds.
pos_label
int / float / str
The main class to be considered as positive (classification only).
cutoff
float
The model cutoff (classification only).
nbins
int
Number of bins used to compute the different parameters categories.
lmax
int
Maximum length of each parameter list.
optimized_grid
int
If set to 0, the randomness is based on the input parameters. If set to 1, the randomness is limited to some parameters, the other ones are picked based on a default grid. If set to 2, there is no randomness and a default grid is returned.
print_info
bool
If set to True, prints the model information at each step.

Returns

tablesample : An object containing the result. For more information, see utilities.tablesample.

Example

In [5]:
from verticapy.learn.linear_model import LogisticRegression
model = LogisticRegression(name = "public.LR_titanic",
                           tol = 1e-4,
                           max_iter = 100, 
                           solver = 'Newton')

from verticapy.learn.model_selection import randomized_search_cv
randomized_search_cv(model,
                     input_relation = "public.titanic_clean",
                     X = ["age", "fare", "parch", "sex", "boat"],
                     y = "survived",
                     cv = 3,
                     metric = "auc",
                     lmax = 5)
Model: LogisticRegression; Parameters: {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 2, 'l1_ratio': 0.8}; Test_score: 0.6749487449904648; Train_score: 0.7000767706602541; Time: 0.8710722923278809;
Model: LogisticRegression; Parameters: {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 2, 'l1_ratio': 0.1}; Test_score: 0.7032595757352726; Train_score: 0.7058611736385693; Time: 0.8391083081563314;
Model: LogisticRegression; Parameters: {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 1, 'l1_ratio': 0.2}; Test_score: 0.7239566637740104; Train_score: 0.7058636182778295; Time: 0.8325083255767822;
Model: LogisticRegression; Parameters: {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'none', 'solver': 'newton'}; Test_score: 0.9912612989453908; Train_score: 0.9919101493833449; Time: 1.0511376857757568;
Model: LogisticRegression; Parameters: {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'l2', 'solver': 'newton', 'C': 4}; Test_score: 0.994789013144222; Train_score: 0.9901850022436899; Time: 0.905972957611084;

Model: LogisticRegression; Best_Parameters: {'solver': 'newton', 'penalty': 'l2', 'max_iter': 1000, 'C': 4, 'tol': 1e-08}; Best_Test_score: 0.994789013144222; Train_score: 0.9901850022436899; Time: 0.905972957611084;


Out[5]:
avg_score
avg_train_score
avg_time
score_std
score_train_std
10.9947890131442220.99018500224368990.9059729576110840.00246229223245033380.0010029936610647903
20.99126129894539080.99191014938334491.05113768577575680.00509574185132021050.002623493765619229
30.72395666377401040.70586361827782950.83250832557678220.024095287852016540.017046612231218023
40.70325957573527260.70586117363856930.83910830815633140.0079878731764496290.009628706344259327
50.67494874499046480.70007677066025410.87107229232788090.0049118051762190740.0029656851577108813
Rows: 1-5 | Columns: 6