twinlab.get_calibration_curve_campaign#
- twinlab.get_calibration_curve_campaign(campaign_id, type='quantile', processor='cpu', verbose=True, debug=False)[source]#
Quantify the performance of your trained model with a calibration curve.
- Parameters:
type (str) – Determine whether to use “quantiile” or “interval” for the model calibration error.
- Returns:
pd.DataFrame: containing the data for the calibration curve
- Return type:
None
Examples
import pandas as pd import twinlab as tl df = pd.DataFrame({'X': [1.5, 2.5, 3.5]}) tl.train_campaign(df, "my_campaign") tl.get_calibration_curve(df, type="quantile") # Plot the calibration curve fraction_observed = tl.get_calibration_curve(type="quantile") fraction_expected = np.linspace(0,1,fraction_observed.shape[0]) fig, ax = plt.subplots(figsize=(5, 5)) ax.set_title("Calibration curve") ax.set_xlabel("Expected coverage") ax.set_ylabel("Observed coverage") plt.plot(np.linspace(0, 1, 100), fraction_observed) plt.plot(np.linspace(0, 1, 100), np.linspace(0, 1, 100), "--") plt.show()
Deprecated since version 2.5.0: The twinLab Python client version v1 will be deprecated imminently. Please upgrade to the latest version of the twinLab Python client. Avaible at https://pypi.org/project/twinlab/.