示例#1
0
def scores(conf):
    parameters = {
        'svm__C': np.logspace(-2, 5, 8),
        'svm__gamma': np.logspace(-9, 2, 12),
        'svm__kernel': ['linear', 'rbf']
    }
    training_data, training_targets = learning_utils.getData(conf['datasets'], type=conf['type'], split=True,
                                                             balanced=conf['balanced'], shuffle=True)
    clf = svm.SVC()
    pipeline = learning_utils.getPipeline(training_data, clf, 'svm')
    grid_search = GridSearchCV(pipeline, parameters, n_jobs=-1, verbose=1)
    learning_utils.gs(grid_search, training_data, training_targets)
示例#2
0
def scores(conf):
    parameters = {
        "svm__C": np.logspace(-2, 5, 8),
        "svm__gamma": np.logspace(-9, 2, 12),
        "svm__kernel": ["linear", "rbf"],
    }
    training_data, training_targets = learning_utils.getData(
        conf["datasets"], type=conf["type"], split=True, balanced=conf["balanced"], shuffle=True
    )
    clf = svm.SVC()
    pipeline = learning_utils.getPipeline(training_data, clf, "svm")
    grid_search = GridSearchCV(pipeline, parameters, n_jobs=-1, verbose=1)
    learning_utils.gs(grid_search, training_data, training_targets)
示例#3
0
def scores(conf):
    if conf['tree'] == 'tree':
        parameters = {
            'tree__criterion': ['gini', 'entropy'],
            'tree__splitter': ['best', 'random'],
            'tree__max_features': [.1, .2, .5, 'sqrt', 'log2', None],
            'tree__max_depth': range(1, 20),
            'tree__presort': [True, False]
        }
        clf = tree.DecisionTreeClassifier()
    elif conf['tree'] == 'random':
        parameters = {
            'tree__criterion': ['gini', 'entropy'],
            'tree__n_estimators': range(5, 50),
            'tree__max_features': [.1, .2, .5, 'sqrt', 'log2', None],
            'tree__max_depth': range(1, 20),
            'tree__bootstrap': [True, False],
        }
        clf = ensemble.RandomForestClassifier()
    elif conf['tree'] == 'extra':
        parameters = {
            'tree__criterion': ['gini', 'entropy'],
            'tree__n_estimators': range(5, 50),
            'tree__max_features': [.1, .2, .5, 'sqrt', 'log2', None],
            'tree__max_depth': range(1, 20),
            'tree__bootstrap': [True, False],
        }
        clf = ensemble.ExtraTreesClassifier()

    training_data, training_targets = learning_utils.getData(conf['datasets'], type=conf['type'], split=True,
                                                             balanced=conf['balanced'], shuffle=True)

    pipeline = learning_utils.getPipeline(training_data, clf, 'tree')

    grid_search = GridSearchCV(pipeline, parameters, n_jobs=-1, verbose=1)

    learning_utils.gs(grid_search, training_data, training_targets)