text_plain_output_1.png
from sklearn.ensemble import ExtraTreesClassifier

from sklearn.ensemble import ExtraTreesRegressor

from sklearn.ensemble import RandomForestRegressor

from sklearn.linear_model import LinearRegression

from sklearn.model_selection import KFold,cross_val_score

from sklearn.tree import DecisionTreeRegressor

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.model_selection import KFold, cross_val_score
from sklearn.metrics import classification_report
from sklearn.linear_model import LinearRegression
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
X = df.drop(['left', 'satisfaction_level'], axis=1)
y = df['satisfaction_level']
kfold = KFold(n_splits=10, random_state=7)
models = [LinearRegression(), DecisionTreeRegressor(), RandomForestRegressor()]
scoring = 'neg_mean_squared_error'
for i in models:
    results = cross_val_score(i, X, y, cv=kfold, scoring=scoring)

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_))
print(sorted(feature_importance_dict.items(), key=lambda x: x[1], reverse=True))