Пример #1
0
def test_output_size_missing_classes():
    # Generate random training data with n_classes > n_calibration
    np.random.seed(1)
    n_classes = 200
    n_calibration = 100
    X_cal = np.random.uniform(0, 1, [n_calibration, n_classes])
    X_cal /= np.sum(X_cal, axis=1)[:, np.newaxis]
    y_cal = np.random.choice(range(n_classes), n_calibration)

    # Arbitrary Choice of binary calibration method
    platt = calm.PlattScaling()
    platt.fit(X_cal, y_cal)

    # Test output size
    assert np.shape(
        platt.predict_proba(X_cal)
    )[1] == n_classes, "Predicted probabilities do not match number of classes."
Пример #2
0
        "GPcalib_lin":
        calm.GPCalibration(n_classes=2,
                           maxiter=1000,
                           mean_function=meanfunc,
                           n_inducing_points=10,
                           logits=False,
                           random_state=random_state),
        "GPcalib_approx":
        calm.GPCalibration(n_classes=2,
                           maxiter=1000,
                           n_inducing_points=10,
                           logits=False,
                           random_state=random_state,
                           inf_mean_approx=True),
        "Platt":
        calm.PlattScaling(random_state=random_state),
        "Isotonic":
        calm.IsotonicRegression(),
        "Beta":
        calm.BetaCalibration(),
        "BBQ":
        calm.BayesianBinningQuantiles(),
        "Temp":
        calm.TemperatureScaling()
    }

    # Create benchmark object
    kitti_benchmark = pycalib.benchmark.KITTIBinaryData(
        run_dir=run_dir,
        clf_output_dir=clf_output_dir,
        classifier_names=classifier_names,
Пример #3
0
    def f_power(x):
        return x**2

    miscal_function_names = {
        'identity': f_id,
        'root': f_root,
        "power": f_power
    }

    # Define calibration methods
    cal_methods_dict = {
        "No_Calibration":
        cm.NoCalibration(),
        "Platt_scaling":
        cm.PlattScaling(),
        "Isotonic_Regression":
        cm.IsotonicRegression(),
        "Beta_Calibration":
        cm.BetaCalibration(params='abm'),
        "Histogram_Binning":
        cm.HistogramBinning(mode='equal_freq'),
        "Bayesian_Binning_into_Quantiles":
        cm.BayesianBinningQuantiles(),
        "Temperature_Scaling":
        cm.TemperatureScaling(verbose=False),
        "GP_calibration":
        cm.GPCalibration(n_classes=n_classes,
                         maxiter=300,
                         n_inducing_points=100)
    }