#NEWLINE# def cvm_flatness( y , proba , X , uniform_variables , sample_weight = None , label = 1 , knn = 30 ) : #NEWLINE# #INDENT# " The most simple way to compute Cramer-von Mises flatness, this is however very slow\n    if you need to compute it many times\n    :param y: real classes of events, shape = [n_samples]\n    :param proba: predicted probabilities, shape = [n_samples, n_classes]\n    :param X: pandas.DataFrame with uniform features (i.e. test dataset)\n    :param uniform_variables: features, along which uniformity is desired, list of strings\n    :param sample_weight: weights of events, shape = [n_samples]\n    :param label: class, for which uniformity is measured (usually, 0 is bck, 1 is signal)\n    :param knn: number of nearest neighbours used in knn\n\n    Example of usage:\n    proba = classifier.predict_proba(testX)\n    cvm_flatness(testY, proba=proba, X=testX, uniform_variables=['mass'])\n    " #NEWLINE# ( y , proba ) = check_arrays ( y , proba ) #NEWLINE# assert ( len ( y ) == len ( proba ) == len ( X ) ) , 'Different lengths' #NEWLINE# y = column_or_1d ( y ) #NEWLINE# sample_weight = check_sample_weight ( y , sample_weight = sample_weight ) #NEWLINE# X = pandas . DataFrame ( X ) #NEWLINE# signal_mask = ( y == label ) #NEWLINE# groups_indices = computeSignalKnnIndices ( uniform_variables = uniform_variables , dataframe = X , is_signal = signal_mask , n_neighbors = knn ) #NEWLINE# groups_indices = groups_indices [ signal_mask , : ] #NEWLINE# return ut . group_based_cvm ( proba [ : , label ] , mask = signal_mask , groups_indices = groups_indices , sample_weight = sample_weight )