Plotting a ROC curve in scikit yields only 3 points
The number of points depend on the number of unique values in the input. Since the input vector has only 2 unique values, the function gives correct output.
The number of points depend on the number of unique values in the input. Since the input vector has only 2 unique values, the function gives correct output.
You can bootstrap the ROC computations (sample with replacement new versions of y_true / y_pred out of the original y_true / y_pred and recompute a new value for roc_curve each time) and the estimate a confidence interval this way. To take the variability induced by the train test split into account, you can also use … Read more
As people mentioned in comments you have to convert your problem into binary by using OneVsAll approach, so you’ll have n_class number of ROC curves. A simple example: from sklearn.metrics import roc_curve, auc from sklearn import datasets from sklearn.multiclass import OneVsRestClassifier from sklearn.svm import LinearSVC from sklearn.preprocessing import label_binarize from sklearn.model_selection import train_test_split import matplotlib.pyplot … Read more
Since seaborn also uses matplotlib to do its plotting you can easily combine the two. If you only want to adopt the styling of seaborn the set_style function should get you started: import matplotlib.pyplot as plt import numpy as np import seaborn as sns sns.set_style(“darkgrid”) plt.plot(np.cumsum(np.random.randn(1000,1))) plt.show() Result:
You can do this using the epi package in R, however I could not find similar package or example in Python. The optimal cut off point would be where “true positive rate” is high and the “false positive rate” is low. Based on this logic, I have pulled an example below to find optimal threshold. … Read more
Here are two ways you may try, assuming your model is an sklearn predictor: import sklearn.metrics as metrics # calculate the fpr and tpr for all thresholds of the classification probs = model.predict_proba(X_test) preds = probs[:,1] fpr, tpr, threshold = metrics.roc_curve(y_test, preds) roc_auc = metrics.auc(fpr, tpr) # method I: plt import matplotlib.pyplot as plt plt.title(‘Receiver … Read more