Exemplo n.º 1
0
    -1
}

if __name__ == '__main__':

    # Extract paths
    data_path, results_path, _ = generate_paths()

    # Load lucas dataset
    datasets = load_datasets(data_path=data_path, data_type='csv')

    # Extract oversamplers
    oversamplers = CONFIG['oversamplers']

    # Generate oversamplers
    for oversampler in oversamplers:

        # Define and fit experiment
        experiment = ImbalancedExperiment(
            oversamplers=[oversampler],
            classifiers=CONFIG['classifiers'],
            scoring=CONFIG['scoring'],
            n_splits=CONFIG['n_splits'],
            n_runs=CONFIG['n_runs'],
            random_state=CONFIG['rnd_seed'],
            n_jobs=CONFIG['n_jobs']).fit(datasets)

        # Save results
        file_name = f'{oversampler[0].replace("-", "").lower()}.pkl'
        experiment.results_.to_pickle(join(results_path, file_name))
Exemplo n.º 2
0
    summarize_datasets,
    calculate_optimal,
    calculate_wide_optimal,
    calculate_ranking,
    calculate_mean_sem_ranking,
    calculate_mean_sem_scores,
    calculate_mean_sem_perc_diff_scores,
    apply_friedman_test,
    apply_holms_test,
)
from rlearn.model_selection import ModelSearchCV
from rlearn.tools.tests import DATASETS, CLASSIFIERS, OVERSAMPLERS

EXPERIMENT = ImbalancedExperiment(OVERSAMPLERS,
                                  CLASSIFIERS,
                                  scoring=None,
                                  n_splits=3,
                                  n_runs=3,
                                  random_state=0).fit(DATASETS)


@pytest.mark.parametrize(
    'scoring,sort_results',
    [
        (None, None),
        (None, 'mean_fit_time'),
        (None, 'mean_test_score'),
        ('accuracy', None),
        ('recall', 'mean_fit_time'),
        ('recall', 'mean_test_score'),
        (['accuracy', 'recall'], None),
        (['accuracy', 'recall'], 'mean_fit_time'),