text_plain_output_1.png
from sklearn import tree

from sklearn.ensemble import AdaBoostClassifier, AdaBoostRegressor

from sklearn.ensemble import GradientBoostingRegressor

from sklearn.linear_model import LinearRegression

from sklearn.model_selection import train_test_split

from sklearn.multiclass import OneVsOneClassifier

from sklearn.multiclass import OneVsRestClassifier

from sklearn.naive_bayes import MultinomialNB

from sklearn.svm import LinearSVC

import numpy as np # linear algebra

from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(X, Y)
x_train = np.array(x_train).reshape(len(x_train), 10)
x_test = np.array(x_test).reshape(len(x_test), 10)
y_train = y_train.values.ravel()
y_test = y_test.values.ravel()

def fit_and_score(x_train, x_validation, y_train, y_validation):
    names = ['OneVsrest', 'OneVsOne', 'MultinomialNB', 'AdaBoost', 'LinearRegression', 'DecisionTreeRegressor', 'AdaBoostRegressor', 'GradientBoostingRegressor']
    models = [OneVsRestClassifier(LinearSVC(random_state=0)), OneVsOneClassifier(LinearSVC(random_state=0)), MultinomialNB(), AdaBoostClassifier(), LinearRegression(), tree.DecisionTreeRegressor(), AdaBoostRegressor(), GradientBoostingRegressor()]
    scores_train = []
    scores_validation = []
    for model in models:
        model.fit(x_train, y_train)
        scores_train.append(model.score(x_train, y_train))
        scores_validation.append(model.score(x_validation, y_validation))
    return (names, scores_train, scores_validation)

nome, resultado_treino, resultado_validacao = fit_and_score(x_train, x_test, y_train, y_test)
print(' Results ')
for n, r_train, r_validation in zip(nome, resultado_treino, resultado_validacao):
    print('_' * 30)
    print('Model: {}'.format(n))
    print('Score train: {:0.3}'.format(r_train))
    print('Score validation: {:0.3}'.format(r_validation))
print('\n')