watex.view.EvalPlot.plotPR#

EvalPlot.plotPR(clf, label, kind=None, method=None, cvp_kws=None, **prt_kws)[source]#

Precision/recall (PR) and tradeoff plots.

PR computes a score based on the decision function and plot the result as a score vs threshold.

Parameters

clf (callable, always as a function, classifier estimator) – A supervised predictor with a finite set of discrete possible output values. A classifier must supports modeling some of binary, targets. It must store a classes attribute after fitting.

label: int,

Specific class to evaluate the tradeoff of precision and recall. label needs to be specified and a value within the target. kind: str, [‘threshold|’recall’], default=’threshold’ kind of PR plot. If kind is ‘recall’, method plots the precision VS the recall scores, otherwiwe the PR tradeoff is plotted against the ‘threshold.’

method: str

Method to get scores from each instance in the trainset. Could be decison_funcion or predict_proba. When using the scikit-Learn classifier, it generally has one of the method. Default is decision_function.

cvp_kws: dict, optional

The sklearn.model_selection.cross_val_predict() keywords additional arguments

prt_kws:dict,

Additional keyword arguments passed to func:watex.exlib.sklearn.precision_recall_tradeoff Return

self: EvalPlot instance

self for easy method chaining.

Examples

>>> from watex.exlib.sklearn import SGDClassifier
>>> from watex.datasets.dload import load_bagoue
>>> from watex.utils import cattarget
>>> from watex.view.mlplot import EvalPlot
>>> X , y = load_bagoue(as_frame =True )
>>> sgd_clf = SGDClassifier(random_state= 42) # our estimator
>>> b= EvalPlot(scale = True , encode_labels=True)
>>> b.fit_transform(X, y)
>>> # binarize the label b.y
>>> ybin = cattarget(b.y, labels= 2 ) # can also use labels =[0, 1]
>>> b.y = ybin
>>> # plot the Precision-recall tradeoff
>>> b.plotPR(sgd_clf , label =1) # class=1
... EvalPlot(tname= None, objective= None, scale= True, ... ,
sns_height= 4.0, sns_aspect= 0.7, verbose= 0)