def test_calibration_curve():
 y_true = np.array([0, 0, 0, 1, 1, 1])
 y_pred = np.array([0.0, 0.1, 0.2, 0.8, 0.9, 1.0])
 (prob_true, prob_pred) = calibration_curve(y_true, y_pred, n_bins=2)
 (prob_true_unnormalized, prob_pred_unnormalized) = calibration_curve(y_true, (y_pred * 2), n_bins=2, normalize=True)
 assert_equal(len(prob_true), len(prob_pred))
 assert_equal(len(prob_true), 2)
 assert_almost_equal(prob_true, [0, 1])
 assert_almost_equal(prob_pred, [0.1, 0.9])
 assert_almost_equal(prob_true, prob_true_unnormalized)
 assert_almost_equal(prob_pred, prob_pred_unnormalized)
 assert_raises(ValueError, calibration_curve, [1.1], [(-0.1)], normalize=False)

def test_calibration_curve ( ) : y_true = np . array ( [ 0 , 0 , 0 , 1 , 1 , 1 ] ) y_pred = np . array ( [ 0.0 , 0.1 , 0.2 , 0.8 , 0.9 , 1.0 ] ) ( prob_true , prob_pred ) = calibration_curve ( y_true , y_pred , n_bins = 2 ) ( prob_true_unnormalized , prob_pred_unnormalized ) = calibration_curve ( y_true , ( y_pred * 2 ) , n_bins = 2 , normalize = True ) assert_equal ( len ( prob_true ) , len ( prob_pred ) ) assert_equal ( len ( prob_true ) , 2 ) assert_almost_equal ( prob_true , [ 0 , 1 ] ) assert_almost_equal ( prob_pred , [ 0.1 , 0.9 ] ) assert_almost_equal ( prob_true , prob_true_unnormalized ) assert_almost_equal ( prob_pred , prob_pred_unnormalized ) assert_raises ( ValueError , calibration_curve , [ 1.1 ] , [ ( - 0.1 ) ] , normalize = False )
check calibration_curve function .