Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose strategy param for calibration curve #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
matplotlib>=1.4.0
scikit-learn>=0.18
scikit-learn>=0.21
scipy>=0.9
joblib>=0.10
10 changes: 8 additions & 2 deletions scikitplot/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def plot_silhouette(X, cluster_labels, title='Silhouette Analysis',
return ax


def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10, strategy="uniform",
title='Calibration plots (Reliability Curves)',
ax=None, figsize=None, cmap='nipy_spectral',
title_fontsize="large", text_fontsize="medium"):
Expand Down Expand Up @@ -938,6 +938,12 @@ def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
n_bins (int, optional): Number of bins. A bigger number requires more
data.

strategy (str, optional): Strategy used to define the widths of the bins.
uniform
The bins have identical widths.
quantile
The bins have the same number of samples and depend on `y_prob`.

title (string, optional): Title of the generated plot. Defaults to
"Calibration plots (Reliabilirt Curves)"

Expand Down Expand Up @@ -1024,7 +1030,7 @@ def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
probas = (probas - probas.min()) / (probas.max() - probas.min())

fraction_of_positives, mean_predicted_value = \
calibration_curve(y_true, probas, n_bins=n_bins)
calibration_curve(y_true, probas, n_bins=n_bins, strategy=strategy)

color = plt.cm.get_cmap(cmap)(float(i) / len(probas_list))

Expand Down