scoring.py
def score(files, n_seed):
    '''
    Calculates the Average Accuracy, Average Precision, Average Recall, Average F1, and Standard Error of Accuracy 
    from all the validation runs of each classifier and feature selection method and saves them in a csv.

    Args:
        files: Arraylike structure that contains all the names of all the classifier-feature selection combinations
        n_seed: Number of validations
    '''
    for filename in files:
        df = pd.read_csv(filename+'.csv', index_col=0)
        with open(filename+'.npy', 'rb') as f:
            confusion_array = np.load(f, allow_pickle=True)
        average_array = np.zeros((len(confusion_array),5))
        for i in range(len(confusion_array)):
            acc = []
            prec = []
            rec = []
            f = []
            for j in range(n_seed):
                tn = confusion_array[i][j][0]
                fp = confusion_array[i][j][1]
                fn = confusion_array[i][j][2]
                tp = confusion_array[i][j][3]
                acc.append(accuracy(tp, tn, sum([tn,fp,fn,tp])))
                p = precision(tp, fp)
                prec.append(p)
                r = recall(tp, fn)
                rec.append(r)
                f.append(f1(p, r))
            if(n_seed>1): 
                average_array[i] = [sum(acc)/n_seed,sum(prec)/n_seed,sum(rec)/n_seed,sum(f)/n_seed, 2*(math.sqrt(statistics.variance(acc))/math.sqrt(n_seed))]
            else:
                average_array[i] = [sum(acc)/n_seed,sum(prec)/n_seed,sum(rec)/n_seed,sum(f)/n_seed, np.nan]
        averages = pd.DataFrame(average_array, columns=['Average Accuracy','Average Precision','Average Recall','Average F1', 'Standard Error of Accuracy'])
        final_df = pd.concat([df.iloc[:,range(df.shape[1])], averages],axis=1)
        final_df.to_csv(filename+'score.csv',index=True)

    Calculates the Average Accuracy, Average Precision, Average Recall, Average F1, and Standard Error of Accuracy 
    from all the validation runs of each classifier and feature selection method and saves them in a csv.

    Args:
        files: Arraylike structure that contains all the names of all the classifier-feature selection combinations
        n_seed: Number of validations
    
Calculates the Average Accuracy, Average Precision, Average Recall, Average F1, and Standard Error of Accuracy
from all the validation runs of each classifier and feature selection method and saves them in a csv.
Calculates the Average Accuracy Average Precision Average Recall Average F1 and Standard Error of Accuracy from all the validation runs of each classifier and feature selection method and saves them in a csv .
def score(files, n_seed):
    for filename in files:
        df = pd.read_csv(filename+'.csv', index_col=0)
        with open(filename+'.npy', 'rb') as f:
            confusion_array = np.load(f, allow_pickle=True)
        average_array = np.zeros((len(confusion_array),5))
        for i in range(len(confusion_array)):
            acc = []
            prec = []
            rec = []
            f = []
            for j in range(n_seed):
                tn = confusion_array[i][j][0]
                fp = confusion_array[i][j][1]
                fn = confusion_array[i][j][2]
                tp = confusion_array[i][j][3]
                acc.append(accuracy(tp, tn, sum([tn,fp,fn,tp])))
                p = precision(tp, fp)
                prec.append(p)
                r = recall(tp, fn)
                rec.append(r)
                f.append(f1(p, r))
            if(n_seed>1): 
                average_array[i] = [sum(acc)/n_seed,sum(prec)/n_seed,sum(rec)/n_seed,sum(f)/n_seed, 2*(math.sqrt(statistics.variance(acc))/math.sqrt(n_seed))]
            else:
                average_array[i] = [sum(acc)/n_seed,sum(prec)/n_seed,sum(rec)/n_seed,sum(f)/n_seed, np.nan]
        averages = pd.DataFrame(average_array, columns=['Average Accuracy','Average Precision','Average Recall','Average F1', 'Standard Error of Accuracy'])
        final_df = pd.concat([df.iloc[:,range(df.shape[1])], averages],axis=1)
        final_df.to_csv(filename+'score.csv',index=True)
def score ( files , n_seed ) : for filename in files : df = pd . read_csv ( filename + '.csv' , index_col = 0 ) with open ( filename + '.npy' , 'rb' ) as f : confusion_array = np . load ( f , allow_pickle = True ) average_array = np . zeros ( ( len ( confusion_array ) , 5 ) ) for i in range ( len ( confusion_array ) ) : acc = [ ] prec = [ ] rec = [ ] f = [ ] for j in range ( n_seed ) : tn = confusion_array [ i ] [ j ] [ 0 ] fp = confusion_array [ i ] [ j ] [ 1 ] fn = confusion_array [ i ] [ j ] [ 2 ] tp = confusion_array [ i ] [ j ] [ 3 ] acc . append ( accuracy ( tp , tn , sum ( [ tn , fp , fn , tp ] ) ) ) p = precision ( tp , fp ) prec . append ( p ) r = recall ( tp , fn ) rec . append ( r ) f . append ( f1 ( p , r ) ) if ( n_seed > 1 ) : average_array [ i ] = [ sum ( acc ) / n_seed , sum ( prec ) / n_seed , sum ( rec ) / n_seed , sum ( f ) / n_seed , 2 * ( math . sqrt ( statistics . variance ( acc ) ) / math . sqrt ( n_seed ) ) ] else : average_array [ i ] = [ sum ( acc ) / n_seed , sum ( prec ) / n_seed , sum ( rec ) / n_seed , sum ( f ) / n_seed , np . nan ] averages = pd . DataFrame ( average_array , columns = [ 'Average Accuracy' , 'Average Precision' , 'Average Recall' , 'Average F1' , 'Standard Error of Accuracy' ] ) final_df = pd . concat ( [ df . iloc [ : , range ( df . shape [ 1 ] ) ] , averages ] , axis = 1 ) final_df . to_csv ( filename + 'score.csv' , index = True )
Calculates the Average Accuracy, Average Precision, Average Recall, Average F1, and Standard Error of Accuracy
from all the validation runs of each classifier and feature selection method and saves them in a csv.
Calculates the Average Accuracy Average Precision Average Recall Average F1 and Standard Error of Accuracy from all the validation runs of each classifier and feature selection method and saves them in a csv .
'''
    Calculates the Average Accuracy, Average Precision, Average Recall, Average F1, and Standard Error of Accuracy 
    from all the validation runs of each classifier and feature selection method and saves them in a csv.

    Args:
        files: Arraylike structure that contains all the names of all the classifier-feature selection combinations
        n_seed: Number of validations
    '''
files
Arraylike structure that contains all the names of all the classifier-feature selection combinations
Arraylike structure that contains all the names of all the classifier - feature selection combinations
n_seed
Number of validations
Number of validations