text_plain_output_1.png image_output_1.png
from sklearn.ensemble import ExtraTreesClassifier

from sklearn.ensemble import ExtraTreesRegressor

import numpy as np

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/HR_comma_sep.csv')

df.isnull().any()

df = df.rename(columns={'sales': 'job'})

X = np.array(df.drop('left', 1))
y = np.array(df['left'])
model = ExtraTreesClassifier()
model.fit(X, y)
feature_list = list(df.drop('left', 1).columns)
feature_importance_dict = dict(zip(feature_list, model.feature_importances_))

from sklearn.ensemble import ExtraTreesRegressor
model = ExtraTreesRegressor()
X = df.drop(['left', 'satisfaction_level'], axis=1)
y = df['satisfaction_level']
model.fit(X, y)
feature_list = list(df.drop(['left', 'satisfaction_level'], 1).columns)
feature_importance_dict = dict(zip(feature_list, model.feature_importances_))

df1 = df.copy()
group_name = list(range(20))
df1['last_evaluation'] = pd.cut(df1['last_evaluation'], 20, labels=group_name)
df1['average_montly_hours'] = pd.cut(df1['average_montly_hours'], 20, labels=group_name)
"\n{0: '(149.5, 160.2]', 1: '(256.5, 267.2]', 2: '(267.2, 277.9]', 3: '(213.7, 224.4]', 4: '(245.8, 256.5]', 5: '(138.8, 149.5]',\n 6: '(128.1, 138.8]', 7: '(299.3, 310]', 8: '(224.4, 235.1]', 9: '(277.9, 288.6]', 10: '(235.1, 245.8]'\n , 11: '(117.4, 128.1]', 12: '(288.6, 299.3]', 13: '(181.6, 192.3]', 14: '(160.2, 170.9]',\n 15: '(170.9, 181.6]', 16: '(192.3, 203]', 17: '(203, 213.7]', 18: '(106.7, 117.4]',\n 19: '(95.786, 106.7]'}\n "