Esempio n. 1
0
def create_bining_strategy_test(function_name):
    arg_dict = {
        'test': DEFAULT_TEST,
        'train': DEFAULT_TRAIN,
        'structure': DEFAULT_STRUCTURE,
        'tolorance': DEFAULT_TOLORANCE,
        'k': DEFAULT_K,
        'number_of_bins': DEFAULT_NUMBER_OF_BINS,
        'bin_type': DEFAULT_BIN_TYPE,
        'missing_values': DEFAULT_MISSING_VALUES,
        '8020': DEFAULT_8020
    }
    resuluts = []
    for strategy in ['equal_width', 'equal_frequency', 'entropy']:
        result = get_result(function_name, **{
            **arg_dict,
            **{
                'bin_type': strategy
            }
        })
        result_tupple = (function_name, result['score'], result['TP'],
                         result['TN'], result['FP'], result['FN'], strategy)
        resuluts.append(result_tupple)
    columns = ('function', 'score', 'TP', 'TN', 'FP', 'FN', 'strategy')
    return matrix_to_df(columns, resuluts)
Esempio n. 2
0
def create_nans_test(function_name):
    arg_dict = {
        'test': DEFAULT_TEST,
        'train': DEFAULT_TRAIN,
        'structure': DEFAULT_STRUCTURE,
        'tolorance': DEFAULT_TOLORANCE,
        'k': DEFAULT_K,
        'number_of_bins': DEFAULT_NUMBER_OF_BINS,
        'bin_type': DEFAULT_BIN_TYPE,
        'missing_values': DEFAULT_MISSING_VALUES,
        '8020': DEFAULT_8020
    }
    resuluts = []
    for s in ('remove_nans', 'replace_nans'):
        result = get_result(function_name, **{
            **arg_dict,
            **{
                'missing_values': s
            }
        })
        result_tupple = (function_name, result['score'], result['TP'],
                         result['TN'], result['FP'], result['FN'], s)
        resuluts.append(result_tupple)
    columns = ('function', 'score', 'TP', 'TN', 'FP', 'FN',
               'dealing with nans strategy')
    return matrix_to_df(columns, resuluts)
Esempio n. 3
0
def create_bins_number_test(function_name, bins_array, strategy):
    arg_dict = {
        'test': DEFAULT_TEST,
        'train': DEFAULT_TRAIN,
        'structure': DEFAULT_STRUCTURE,
        'tolorance': DEFAULT_TOLORANCE,
        'k': DEFAULT_K,
        'number_of_bins': DEFAULT_NUMBER_OF_BINS,
        'bin_type': strategy,
        'missing_values': DEFAULT_MISSING_VALUES,
        '8020': DEFAULT_8020
    }
    resuluts = []
    for b in bins_array:
        print(b)
        result = get_result(function_name, **{
            **arg_dict,
            **{
                'number_of_bins': b
            }
        })
        result_tupple = (function_name, result['score'], result['TP'],
                         result['TN'], result['FP'], result['FN'], b, strategy)
        resuluts.append(result_tupple)
    columns = ('function', 'score', 'TP', 'TN', 'FP', 'FN', 'number of bins',
               'strategy')
    return matrix_to_df(columns, resuluts)
Esempio n. 4
0
 def update_output(**kwargs):
     setStatus('Working...')
     function_name = kwargs['choosen_function_name']
     ###  sending kwargs to start module
     ###      vvvvvvvvvvvv
     result = get_result(function_name, **kwargs)
     ###     ^^^^^^^^^^^^^
     setScore(result['score'])
     output_components['TP_box'].config(text=result['TP'])
     output_components['TN_box'].config(text=result['TN'])
     output_components['FP_box'].config(text=result['FP'])
     output_components['FN_box'].config(text=result['FN'])
     setStatus('Done')
Esempio n. 5
0
def create_k_test(function_name, k_array):
    arg_dict = {
        'test': DEFAULT_TEST,
        'train': DEFAULT_TRAIN,
        'structure': DEFAULT_STRUCTURE,
        'tolorance': DEFAULT_TOLORANCE,
        'k': DEFAULT_K,
        'number_of_bins': DEFAULT_NUMBER_OF_BINS,
        'bin_type': DEFAULT_BIN_TYPE,
        'missing_values': DEFAULT_MISSING_VALUES,
        '8020': DEFAULT_8020
    }
    resuluts = []
    for k in k_array:
        result = get_result(function_name, **{**arg_dict, **{'k': k}})
        result_tupple = (result['score'], result['TP'], result['TN'],
                         result['FP'], result['FN'], k)
        resuluts.append(result_tupple)
    columns = ('score', 'TP', 'TN', 'FP', 'FN', 'k')
    return matrix_to_df(columns, resuluts)
Esempio n. 6
0
# function to open structure file
def load_structure():
    returnList = []
    filename = 'Structure.txt'
    try:
        tmp = open(filename, "r")
        for line in tmp:
            returnList.append(line)
        tmp.close()
    except FileNotFoundError as e:
        print("Error", "file was not found!!")
    return returnList


# the settings for the single test
kwargs = {
    'test': pd.read_csv('test.csv'),
    'train': pd.read_csv('train.csv'),
    'structure': load_structure(),
    'number_of_bins': 14,
    'k': 5,
    'tolorance': 5,
    'bin_type': 'equal_frequency',
    'missing_values': 'remove_nans',
    '8020': 'yes',
}

# test run example:
print(get_result('id3', **kwargs))