Ejemplo n.º 1
0
    if repo is None:
        raise ValueError(
            'environment variable MLPYTHON_DATASET_REPO is not defined')
    dataset_dir = os.path.join(
        os.environ.get('MLPYTHON_DATASET_REPO') + '/' + dataset_directory,
        dataset_name)

    gammas = [0.01, 1, 5, 10, 50, 100]
    Cs = [1, 10, 50, 100]

    hyperparams_grid = []
    all_data = data_utils.load_data(dataset_dir)
    test = all_data['test']
    fulltrain_backup = all_data['finaltrain']
    factor = 500
    all_data = data_utils.data_reduction(fulltrain_backup, factor)
    all_data['test'] = test
    print len(fulltrain_backup[0])
    print len(all_data['finaltrain'][0])
    train = [int(t[1]) for t in all_data['train'][0]]
    valid = [int(v[1]) for v in all_data['valid'][0]]
    finaltrain = [int(f[1]) for f in all_data['finaltrain'][0]]
    train = np.asarray(train)
    valid = np.asarray(valid)
    finaltrain = np.asarray(finaltrain)
    datasets = data_utils.create_datasets(all_data)
    testset = datasets['testset']

    resultg1, resultg2 = '', ''
    for gamma in gammas:
        for C in Cs:
Ejemplo n.º 2
0
for brain in brain_names[0:2]:
    dataset_dir = os.path.join(os.environ.get('MLPYTHON_DATASET_REPO') + '/' + dataset_directory, brain)
    all_data = data_utils.load_data(dataset_dir)
    test = all_data['test']
    fulltrain_backup = all_data['finaltrain']    
    resultc1, resultc2 = '' ,''           
    brain_str = brain + ' \n'
    
    for factor in Factors:
        resultc3 = ''
        dice_t = np.zeros((10))
        processed_timet = np.zeros((10))
        for nb in range(10):
            resultc3 = ''
            all_data = data_utils.data_reduction(fulltrain_backup , factor)
            all_data['test'] = test
            print len(fulltrain_backup[0])
            print len(all_data['finaltrain'][0])
            train = [int(t[1]) for t in all_data['train'][0]] 
            valid = [int(v[1]) for v in all_data['valid'][0]]
            finaltrain = [int(f[1]) for f in all_data['finaltrain'][0]]
            train = np.asarray(train)
            valid = np.asarray(valid)
            finaltrain = np.asarray(finaltrain)
            datasets = create_datasets(all_data)
            dice_t[nb] , processed_timet[nb] = svm_model(datasets)


            resultc3 += 'factor = ' + str(factor) + '\n'
            resultc3 += 'finaltrain = ' + str(len(all_data['finaltrain'][0])) + '\n'