<s> """<STR_LIT>""" <EOL> print ( __doc__ ) <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> from matplotlib import cm <EOL> from sklearn . datasets import make_blobs <EOL> from sklearn . naive_bayes import GaussianNB <EOL> from sklearn . metrics import brier_score_loss <EOL> from sklearn . calibration import CalibratedClassifierCV <EOL> from sklearn . model_selection import train_test_split <EOL> n_samples = <NUM_LIT> <EOL> n_bins = <NUM_LIT:3> <EOL> centers = [ ( - <NUM_LIT:5> , - <NUM_LIT:5> ) , ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:5> , <NUM_LIT:5> ) ] <EOL> X , y = make_blobs ( n_samples = n_samples , n_features = <NUM_LIT:2> , cluster_std = <NUM_LIT:1.0> , <EOL> centers = centers , shuffle = False , random_state = <NUM_LIT> ) <EOL> y [ : n_samples // <NUM_LIT:2> ] = <NUM_LIT:0> <EOL> y [ n_samples // <NUM_LIT:2> : ] = <NUM_LIT:1> <EOL> sample_weight = np . random . RandomState ( <NUM_LIT> ) . rand ( y . shape [ <NUM_LIT:0> ] ) <EOL> X_train , X_test , y_train , y_test , sw_train , sw_test = train_test_split ( X , y , sample_weight , test_size = <NUM_LIT> , random_state = <NUM_LIT> ) <EOL> clf = GaussianNB ( ) <EOL> clf . fit ( X_train , y_train ) <EOL> prob_pos_clf = clf . predict_proba ( X_test ) [ : , <NUM_LIT:1> ] <EOL> clf_isotonic = CalibratedClassifierCV ( clf , cv = <NUM_LIT:2> , method = '<STR_LIT>' ) <EOL> clf_isotonic . fit ( X_train , y_train , sw_train ) <EOL> prob_pos_isotonic = clf_isotonic . predict_proba ( X_test ) [ : , <NUM_LIT:1> ] <EOL> clf_sigmoid = CalibratedClassifierCV ( clf , cv = <NUM_LIT:2> , method = '<STR_LIT>' ) <EOL> clf_sigmoid . fit ( X_train , y_train , sw_train ) <EOL> prob_pos_sigmoid = clf_sigmoid . predict_proba ( X_test ) [ : , <NUM_LIT:1> ] <EOL> print ( "<STR_LIT>" ) <EOL> clf_score = brier_score_loss ( y_test , prob_pos_clf , sw_test ) <EOL> print ( "<STR_LIT>" % clf_score ) <EOL> clf_isotonic_score = brier_score_loss ( y_test , prob_pos_isotonic , sw_test ) <EOL> print ( "<STR_LIT>" % clf_isotonic_score ) <EOL> clf_sigmoid_score = brier_score_loss ( y_test , prob_pos_sigmoid , sw_test ) <EOL> print ( "<STR_LIT>" % clf_sigmoid_score ) <EOL> plt . figure ( ) <EOL> y_unique = np . unique ( y ) <EOL> colors = cm . rainbow ( np . linspace ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , y_unique . size ) ) <EOL> for this_y , color in zip ( y_unique , colors ) : <EOL> this_X = X_train [ y_train == this_y ] <EOL> this_sw = sw_train [ y_train == this_y ] <EOL> plt . scatter ( this_X [ : , <NUM_LIT:0> ] , this_X [ : , <NUM_LIT:1> ] , s = this_sw * <NUM_LIT:50> , c = color , alpha = <NUM_LIT:0.5> , <EOL> label = "<STR_LIT>" % this_y ) <EOL> plt . legend ( loc = "<STR_LIT>" ) <EOL> plt . title ( "<STR_LIT>" ) <EOL> plt . figure ( ) <EOL> order = np . lexsort ( ( prob_pos_clf , ) ) <EOL> plt . plot ( prob_pos_clf [ order ] , '<STR_LIT:r>' , label = '<STR_LIT>' % clf_score ) <EOL> plt . plot ( prob_pos_isotonic [ order ] , '<STR_LIT:g>' , linewidth = <NUM_LIT:3> , <EOL> label = '<STR_LIT>' % clf_isotonic_score ) <EOL> plt . plot ( prob_pos_sigmoid [ order ] , '<STR_LIT:b>' , linewidth = <NUM_LIT:3> , <EOL> label = '<STR_LIT>' % clf_sigmoid_score ) <EOL> plt . plot ( np . linspace ( <NUM_LIT:0> , y_test . size , <NUM_LIT> ) [ <NUM_LIT:1> : : <NUM_LIT:2> ] , <EOL> y_test [ order ] . reshape ( <NUM_LIT> , - <NUM_LIT:1> ) . mean ( <NUM_LIT:1> ) , <EOL> '<STR_LIT:k>' , linewidth = <NUM_LIT:3> , label = r'<STR_LIT>' ) <EOL> plt . ylim ( [ - <NUM_LIT> , <NUM_LIT> ] ) <EOL> plt . xlabel ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> plt . ylabel ( "<STR_LIT>" ) <EOL> plt . legend ( loc = "<STR_LIT>" ) <EOL> plt . title ( "<STR_LIT>" ) <EOL> plt . show ( ) </s>
