learning_curve

In [ ]:
learning_curve(estimator,
               input_relation: (str, vDataFrame),
               X: list,
               y: str,
               sizes: list = [0.1, 0.33, 0.55, 0.78, 1.0],
               method = "efficiency",
               metric: str = "auto",
               cv: int = 3,
               pos_label: (int, float, str) = None,
               cutoff: float = -1,
               std_coeff: float = 1,
               ax=None,
               **style_kwds,)

Draws the learning curve.

Parameters

Name Type Optional Description
estimator
object
Vertica estimator having a fit method.
input_relation
str / vDataFrame
Input Relation.
X
list
List of the predictor columns.
y
str
Response Column.
sizes
list
Different sizes of the dataset used to train the model. Multiple models will be trained using the different sizes.
metric
str / list
Method used to plot the curve.
  • efficiency : draws train/test score vs sample size.
  • performance : draws score vs time.
  • scalability : draws time vs sample size.
metric
str / list
Metric used to do the model evaluation. It can also be a list of metrics.
  • 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).
std_coeff
float
Value of the standard deviation coefficient used to compute the area plot around each score.
ax
Matplotlib axes object
The axes to plot on.
**style_kwds
any
Any optional parameter to pass to the Matplotlib functions.

Returns

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

Example

In [14]:
from verticapy.learn.ensemble import RandomForestClassifier
model = RandomForestClassifier(name = "public.RF_titanic")

from verticapy.learn.model_selection import learning_curve

# Efficiency
learning_curve(model,
               input_relation = "public.titanic", 
               X = ["age", "fare", "parch",],
               y = "survived",
               method = "efficiency",
               cv = 3,
               metric = "auc",)
Out[14]:
n
auc
auc_std
auc_train
auc_train_std
time
time_std
11180.62320718998350590.077168286621389140.91437531202023940.026342655733331861.2303079764048260.08847785026785102
24400.60117536978276550.060462110631116720.79335669898328630.0269632492667418561.25174180666605640.22754656359291583
36460.68553322327057190.024923480197640750.80481127373778220.0047889649964003231.28339910507202150.09871047554219624
49680.68612960161312320.0311367642307583650.75713114552097850.0105631974823819681.5457856655120850.25085902623688866
512340.70139347143346080.0188499219446875840.76614967944960740.0094551026721686941.32811419169108080.35271516602760966
Rows: 1-5 | Columns: 7
In [15]:
# Scalability
learning_curve(model,
               input_relation = "public.titanic", 
               X = ["age", "fare", "parch",],
               y = "survived",
               method = "scalability",
               cv = 3,
               metric = "auc",)
Out[15]:
n
auc
auc_std
auc_train
auc_train_std
time
time_std
11340.51676601176601190.103530778645477160.90548400035083370.016347520480859831.13869961102803540.0705586899199437
24140.61897233206334860.0485561325196502340.84927841854250340.0115060659701626081.21573901176452640.24663237448222033
36610.64327336966540050.036472304813462080.8013334932959490.0043094752470134251.21280201276143380.26779752805591356
49510.70081820919127990.038192658244339210.77462927322459850.0166493694272281981.37914864222208670.08692612536226947
512340.71564858551524140.0166640779868933160.75480125228660650.0066373983306805151.85802332560221360.4899776062646076
Rows: 1-5 | Columns: 7
In [16]:
# Performance
learning_curve(model,
               input_relation = "public.titanic", 
               X = ["age", "fare", "parch",],
               y = "survived",
               method = "performance",
               cv = 3,
               metric = "auc",)
Out[16]:
n
auc
auc_std
auc_train
auc_train_std
time
time_std
13650.63014127682260450.0050934311759743690.85560987698084460.0248146758085067041.0615226427714030.051973754398303214
212340.6925271745915940.036729605756428590.77465558010076090.0149915457289004441.26691540082295730.12237853722391252
37000.71340332188226010.0182613901000391670.78021880437336090.0039836961719707221.38588603337605790.6278487950308989
41210.73115344622697550.0538282737056722460.95676894957800720.0123486688024994681.45449701944986990.38701140468343154
59470.66645745895870150.0387818430745245150.79971314910133640.017988839293830951.4695999622344970.1608715625898985
Rows: 1-5 | Columns: 7