text_html_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.metrics import classification_report

from sklearn.metrics import confusion_matrix

from sklearn.model_selection import train_test_split

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

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

df.columns

sales_salary = pd.crosstab(df['sales'], df['salary'], normalize=False)
sales_salary = sales_salary[['low', 'medium', 'high']]
sales_salary['temp'] = sales_salary.index.values
sales_salary.iloc[0, 3] = 'it'
sales_salary.iloc[1, 3] = 'rand_d'
sales_salary.sort_values(by='temp', inplace=True)
sales_salary.set_index('temp', inplace=True)
sales_salary.index.name = 'sales'
sales_salary

df = df.join(pd.get_dummies(df['salary']))
df = df.join(pd.get_dummies(df['sales']), rsuffix='d')
df.drop(labels=['sales', 'salary'], inplace=True, axis=1)

y = df['low'].copy()
y[df['medium'] == 1] = 2
y[df['high'] == 1] = 3

df.drop(labels=['low', 'medium', 'high'], axis=1, inplace=True)

from sklearn.model_selection import train_test_split
xtr, xte, ytr, yte = train_test_split(df, y, test_size=0.25)
(xtr.shape, xte.shape, ytr.shape, yte.shape)

from sklearn.linear_model import LogisticRegression
lr = LogisticRegression()

lr.fit(xtr, ytr)

from sklearn.metrics import classification_report

from sklearn.metrics import confusion_matrix
confusion_matrix(yte, lr.predict(xte))