MulaiMulai sekarang secara gratis

ROC curve

Let's now create an ROC curve for our random forest classifier. The first step is to calculate the predicted probabilities output by the classifier for each label using its .predict_proba() method. Then, you can use the roc_curve function from sklearn.metrics to compute the false positive rate and true positive rate, which you can then plot using matplotlib.

A RandomForestClassifier with a training set size of 70% has been fit to the data and is available in your workspace as clf.

Latihan ini adalah bagian dari kursus

Marketing Analytics: Predicting Customer Churn in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Generate the probabilities
y_pred_prob = ____.____(____)[:, 1]
Edit dan Jalankan Kode