How to plot ROC curve in Python

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

How to calculate cumulative normal distribution?

Here’s an example: >>> from scipy.stats import norm >>> norm.cdf(1.96) 0.9750021048517795 >>> norm.cdf(-1.96) 0.024997895148220435 In other words, approximately 95% of the standard normal interval lies within two standard deviations, centered on a standard mean of zero. If you need the inverse CDF: >>> norm.ppf(norm.cdf(1.96)) array(1.9599999999999991)

Rolling median algorithm in C

I have looked at R’s src/library/stats/src/Trunmed.c a few times as I wanted something similar too in a standalone C++ class / C subroutine. Note that this are actually two implementations in one, see src/library/stats/man/runmed.Rd (the source of the help file) which says \details{ Apart from the end values, the result \code{y = runmed(x, k)} simply … Read more