def _get_chance_level(scorer, y_train):
 if (scorer.__name__ == 'accuracy_score'):
  chance = np.max([np.mean((y_train == c)) for c in np.unique(y_train)])
 elif (scorer.__name__ == 'roc_auc_score'):
  chance = 0.5
 else:
  chance = np.nan
  warn(('Cannot find chance level from %s, specify chance level' % scorer.__name__))
 return chance

def _get_chance_level ( scorer , y_train ) : if ( scorer . __name__ == 'accuracy_score' ) : chance = np . max ( [ np . mean ( ( y_train == c ) ) for c in np . unique ( y_train ) ] ) elif ( scorer . __name__ == 'roc_auc_score' ) : chance = 0.5 else : chance = np . nan warn ( ( 'Cannot find chance level from %s, specify chance level' % scorer . __name__ ) ) return chance
get the chance level .