Пример #1
0
    for key in classifier_dict:
        myclassifier = classifier_dict[key]

        acc = D.ClfScatter(myclassifier, title=key)

    return acc  # Return the last accuracy (important to get the correct answer in the TP)


if __name__ == "__main__":
    # We can use this function to test the Classifier
    if len(
            argv
    ) == 1:  # Use the default input and output directories if no arguments are provided
        input_dir = "../public_data"
        output_dir = "../results"
        score_dir = "../scoring_program"
    else:
        input_dir = argv[1]
        output_dir = argv[2]
        score_dir = argv[3]

# The M2 may have prepared challenges using sometimes AutoML challenge metrics
    path.append(score_dir)

    from zDataManager import DataManager  # The class provided by binome 1

    basename = 'Iris'
    D = DataManager(basename, input_dir)  # Load data
    print(D)
    test(D)
Пример #2
0
This is an example of program that tests the PSP challenge Classifier class.
You can also find a test in the main function of the class zClassifier itself.

"""
import numpy as np
from zDataManager import DataManager
from zClassifier import Classifier, Classifier2
from sklearn.metrics import accuracy_score
from sklearn.cross_validation import cross_val_score
from zPreprocessor import Preprocessor

input_dir = "../public_data"
output_dir = "../res"

basename = 'movies'
D = DataManager(basename, input_dir)  # Load data
print D

Prepro = Preprocessor()

# Preprocess on the data and load it back into D
D.data['X_train'] = Prepro.fit_transform(D.data['X_train'], D.data['Y_train'])
D.data['X_valid'] = Prepro.transform(D.data['X_valid'])
D.data['X_test'] = Prepro.transform(D.data['X_test'])


def ebar(score, sample_num):
    '''ebar calculates the error bar for the classification score (accuracy or error rate)
    for sample_num examples'''
    return np.sqrt(1. * score * (1 - score) / sample_num)
"""
Created on Sat Mar 11 08:04:23 2017

@author: isabelleguyon

This is an example of program that tests the Iris challenge Data Manager class.
Another style is to incorporate the test as a main function in the Data manager class itself.
"""
from zDataManager import DataManager
mypath = "../sample_code"
from sys import argv, path
from os.path import abspath
path.append(abspath(mypath))

if __name__ == "__main__":
    # We can use this to run this file as a script and test the DataManager
    if len(
            argv
    ) == 1:  # Use the default input and output directories if no arguments are provided
        input_dir = "../public_data"
        output_dir = "../res"
    else:
        input_dir = argv[1]
        output_dir = argv[2]

    print("Using input_dir: " + input_dir)
    print("Using output_dir: " + output_dir)

    basename = 'movies'
    D = DataManager(basename, input_dir)
Пример #4
0
        return self.transformer.transform(X)


if __name__ == "__main__":
    # We can use this to run this file as a script and test the Preprocessor
    if len(
            argv
    ) == 1:  # Use the default input and output directories if no arguments are provided
        input_dir = "../public_data"
        output_dir = "../results"
    else:
        input_dir = argv[1]
        output_dir = argv[2]

    basename = 'Iris'
    D = DataManager(basename, input_dir)  # Load data
    print("*** Original data ***")
    print(D)

    Prepro = Preprocessor()

    # Preprocess on the data and load it back into D
    D.data['X_train'] = Prepro.fit_transform(D.data['X_train'],
                                             D.data['Y_train'])
    D.data['X_valid'] = Prepro.transform(D.data['X_valid'])
    D.data['X_test'] = Prepro.transform(D.data['X_test'])
    D.feat_name = np.array(['PC1', 'PC2'])
    D.feat_type = np.array(['Numeric', 'Numeric'])

    # Here show something that proves that the preprocessing worked fine
    print("*** Transformed data ***")
Пример #5
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 11 08:04:23 2017

@author: isabelleguyon

This is an example of program that tests the Iris challenge Data Manager class.
Another style is to incorporate the test as a main function in the Data manager class itself.
"""
from zDataManager import DataManager
input_dir = "../public_data"
output_dir = "../res"

basename = 'Iris'
D = DataManager(basename, input_dir)
print D

D.DataStats('train')
D.ShowScatter(1, 2, 'train')