text_html_output_1.png
from sklearn import  neighbors, svm

from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier,\

from sklearn.linear_model import LogisticRegressionCV

from sklearn.model_selection import cross_val_score, train_test_split,\

from sklearn.naive_bayes import MultinomialNB

import numpy as np

import pandas as pd

hr = pd.read_csv(DIR_DATA + '/HR_comma_sep.csv')

hr.sales = hr.sales.astype('category').cat.codes
hr.salary = hr.salary.astype('category').cat.codes

def predict_left(df, clf, test_size=0.2):
    X = df.drop(['left'], 1)
    y = df.left
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size)
    clf.fit(X_train, y_train)
    train_pred = clf.predict(X_train)
    test_pred = clf.predict(X_test)

classifiers = [RandomForestClassifier(n_jobs=-1), RandomForestClassifier(criterion='entropy', n_jobs=-1), svm.SVC(), LogisticRegressionCV(n_jobs=-1), AdaBoostClassifier(), GradientBoostingClassifier(), neighbors.KNeighborsClassifier(n_jobs=-1), MultinomialNB(class_prior=[76.19, 23.81])]
np.random.seed(0)
for i, clf in enumerate(classifiers):
    print('Classifier ', i)
    predict_left(hr, clf, test_size=0.4)