Calibration curve (also known as reliability diagram) visualization.
It is recommended to use from_estimator
or from_predictions
to create a CalibrationDisplay
. All parameters are stored as attributes.
Read more about calibration in the User Guide and more about the scikit-learn visualization API in Visualizations.
For an example on how to use the visualization, see Probability Calibration curves.
Added in version 1.0.
The proportion of samples whose class is the positive class (fraction of positives), in each bin.
The mean predicted probability in each bin.
Probability estimates for the positive class, for each sample.
Name of estimator. If None, the estimator name is not shown.
The positive class when computing the calibration curve. By default, pos_label
is set to estimators.classes_[1]
when using from_estimator
and set to 1 when using from_predictions
.
Added in version 1.1.
Calibration curve.
Axes with calibration curve.
Figure containing the curve.
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.model_selection import train_test_split >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.calibration import calibration_curve, CalibrationDisplay >>> X, y = make_classification(random_state=0) >>> X_train, X_test, y_train, y_test = train_test_split( ... X, y, random_state=0) >>> clf = LogisticRegression(random_state=0) >>> clf.fit(X_train, y_train) LogisticRegression(random_state=0) >>> y_prob = clf.predict_proba(X_test)[:, 1] >>> prob_true, prob_pred = calibration_curve(y_test, y_prob, n_bins=10) >>> disp = CalibrationDisplay(prob_true, prob_pred, y_prob) >>> disp.plot() <...>
Plot calibration curve using a binary classifier and data.
A calibration curve, also known as a reliability diagram, uses inputs from a binary classifier and plots the average predicted probability for each bin against the fraction of positive classes, on the y-axis.
Extra keyword arguments will be passed to matplotlib.pyplot.plot
.
Read more about calibration in the User Guide and more about the scikit-learn visualization API in Visualizations.
Added in version 1.0.
Fitted classifier or a fitted Pipeline
in which the last estimator is a classifier. The classifier must have a predict_proba method.
Input values.
Binary target values.
Number of bins to discretize the [0, 1] interval into when calculating the calibration curve. A bigger number requires more data.
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 predicted probabilities.
The positive class when computing the calibration curve. By default, estimators.classes_[1]
is considered as the positive class.
Added in version 1.1.
Name for labeling curve. If None
, the name of the estimator is used.
Axes object to plot on. If None
, a new figure and axes is created.
If True
, plots a reference line representing a perfectly calibrated classifier.
Keyword arguments to be passed to matplotlib.pyplot.plot
.
CalibrationDisplay
.
Object that stores computed values.
Examples
>>> import matplotlib.pyplot as plt >>> from sklearn.datasets import make_classification >>> from sklearn.model_selection import train_test_split >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.calibration import CalibrationDisplay >>> X, y = make_classification(random_state=0) >>> X_train, X_test, y_train, y_test = train_test_split( ... X, y, random_state=0) >>> clf = LogisticRegression(random_state=0) >>> clf.fit(X_train, y_train) LogisticRegression(random_state=0) >>> disp = CalibrationDisplay.from_estimator(clf, X_test, y_test) >>> plt.show()
Plot calibration curve using true labels and predicted probabilities.
Calibration curve, also known as reliability diagram, uses inputs from a binary classifier and plots the average predicted probability for each bin against the fraction of positive classes, on the y-axis.
Extra keyword arguments will be passed to matplotlib.pyplot.plot
.
Read more about calibration in the User Guide and more about the scikit-learn visualization API in Visualizations.
Added in version 1.0.
True labels.
The predicted probabilities of the positive class.
Number of bins to discretize the [0, 1] interval into when calculating the calibration curve. A bigger number requires more data.
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 predicted probabilities.
The positive class when computing the calibration curve. By default pos_label
is set to 1.
Added in version 1.1.
Name for labeling curve.
Axes object to plot on. If None
, a new figure and axes is created.
If True
, plots a reference line representing a perfectly calibrated classifier.
Keyword arguments to be passed to matplotlib.pyplot.plot
.
CalibrationDisplay
.
Object that stores computed values.
Examples
>>> import matplotlib.pyplot as plt >>> from sklearn.datasets import make_classification >>> from sklearn.model_selection import train_test_split >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.calibration import CalibrationDisplay >>> X, y = make_classification(random_state=0) >>> X_train, X_test, y_train, y_test = train_test_split( ... X, y, random_state=0) >>> clf = LogisticRegression(random_state=0) >>> clf.fit(X_train, y_train) LogisticRegression(random_state=0) >>> y_prob = clf.predict_proba(X_test)[:, 1] >>> disp = CalibrationDisplay.from_predictions(y_test, y_prob) >>> plt.show()
Plot visualization.
Extra keyword arguments will be passed to matplotlib.pyplot.plot
.
Axes object to plot on. If None
, a new figure and axes is created.
Name for labeling curve. If None
, use estimator_name
if not None
, otherwise no labeling is shown.
If True
, plots a reference line representing a perfectly calibrated classifier.
Keyword arguments to be passed to matplotlib.pyplot.plot
.
CalibrationDisplay
Object that stores computed values.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4