def generate_statistical_results(): """Generate the statistical results of the experiment.""" # Combine experiments objects results = [] for ratio in UNDERSAMPLING_RATIOS: # Generate results partial_results = generate_results(ratio) # Extract results cols = partial_results.columns partial_results = partial_results.reset_index() partial_results['Dataset'] = partial_results['Dataset'].apply(lambda name: f'{name}({ratio})') partial_results.set_index(['Dataset', 'Oversampler', 'Classifier', 'params'], inplace=True) partial_results.columns = cols results.append(partial_results) # Combine results results = combine_results(*results) # Calculate statistical results friedman_test = sort_tbl(generate_pvalues_tbl(apply_friedman_test(results)), ovrs_order=OVERSAMPLERS_NAMES, clfs_order=CLASSIFIERS_NAMES) holms_test = sort_tbl(generate_pvalues_tbl(apply_holms_test(results, control_oversampler='G-SMOTE')), ovrs_order=OVERSAMPLERS_NAMES[:-1], clfs_order=CLASSIFIERS_NAMES) statistical_results_names = ('friedman_test', 'holms_test') statistical_results = zip(statistical_results_names, (friedman_test, holms_test)) return statistical_results
def generate_statistical_results(): """Generate the statistical results of the experiment.""" friedman_test = sort_tbl(generate_pvalues_tbl(apply_friedman_test(results)), ovrs_order=OVRS_NAMES, clfs_order=CLFS_NAMES) holms_test = sort_tbl(generate_pvalues_tbl_bold(apply_holms_test(results, control_oversampler='K-SMOTE')), ovrs_order=OVRS_NAMES[:-1], clfs_order=CLFS_NAMES) statistical_results_names = ('friedman_test', 'holms_test') statistical_results = zip(statistical_results_names, (friedman_test, holms_test)) return statistical_results
def generate_statistical_results(): """Generate the statistical results of the experiment.""" # Generate results results = generate_results() # Calculate statistical results friedman_test = sort_tbl(generate_pvalues_tbl( apply_friedman_test(results)), ovrs_order=OVERSAMPLERS_NAMES, clfs_order=CLASSIFIERS_NAMES) holms_test = sort_tbl(generate_pvalues_tbl( apply_holms_test(results, control_oversampler='G-SOMO')), ovrs_order=OVERSAMPLERS_NAMES[:-1], clfs_order=CLASSIFIERS_NAMES) # Generate statistical results statistical_results_names = ('friedman_test', 'holms_test') statistical_results = zip(statistical_results_names, (friedman_test, holms_test)) return statistical_results
def test_friedman_test(): """Test the results of friedman test.""" friedman_test = apply_friedman_test(EXPERIMENT.results_, alpha=0.05) assert set(friedman_test.Classifier.unique()) == set( EXPERIMENT.classifiers_names_) assert len(friedman_test) == len(CLASSIFIERS)