watex.view.plot_model_scores#
- watex.view.plot_model_scores(models, scores=None, cv_size=None, **baseplot_kws)[source]#
uses the cross validation to get an estimation of model performance generalization.
It Visualizes model fined tuned scores vs the cross validation
- Parameters
models (list of callables, always as a functions,) –
list of estimator names can also be a pair estimators and validations scores.For instance estimators and scores can be arranged as:
models =[('SVM', scores_svm), ('LogRegress', scores_logregress), ...]
If that arrangement is passed to models parameter then no need to pass the score values of each estimators in scores. Note that a model is an object which manages the estimation and decoding. The model is estimated as a deterministic function of:
parameters provided in object construction or with set_params;
- the global numpy.random random state if the estimator’s random_state
parameter is set to None; and
- any data or sample properties passed to the most recent call to fit,
fit_transform or fit_predict, or data similarly passed in a sequence of calls to partial_fit.
list of estimators names or a pairs estimators and validations scores. For instance:
clfs =[('SVM', scores_svm), ('LogRegress', scores_logregress), ...]
scores (array like) –
list of scores on different validation sets. If scores are given, set only the name of the estimators passed to models like:
models =['SVM', 'LogRegress', ...] scores=[scores_svm, scores_logregress, ...]
cv_size (float or int,) – The number of fold used for validation. If different models have different cross validation values, the minimum size of cross validation is used and the scored of each model is resized to match the minimum size number.
baseplot_kws (dict,) – All all the keywords arguments passed to the peroperty
watex.property.BasePlotclass.
Examples
(1) -> Score is appended to the model >>> from watex.exlib.sklearn import SVC >>> from watex.view.mlplot import plot_model_scores >>> import numpy as np >>> svc_model = SVC() >>> fake_scores = np.random.permutation (np.arange (0, 1, .05)) >>> plot_model_scores([(svc_model, fake_scores )]) … (2) -> Use model and score separately
>>> plot_model_scores([svc_model],scores =[fake_scores] )# >>> # customize plot by passing keywords properties >>> base_plot_params ={ 'lw' :3., 'lc':(.9, 0, .8), 'ms':7., 'fig_size':(12, 8), 'font_size':15., 'xlabel': 'samples', 'ylabel':'scores' , 'marker':'o', 'alpha' :1., 'yp_markeredgewidth':2., 'show_grid' :True, 'galpha' :0.2, 'glw':.5, 'rotate_xlabel' :90., 'fs' :3., 's' :20 , 'sns_style': 'darkgrid', } >>> plot_model_scores([svc_model],scores =[fake_scores] , **base_plot_params )