text_html_output_1.png
from sklearn.preprocessing import LabelEncoder

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

data = pd.read_csv('/kaggle/input/factors-affecting-campus-placement/Placement_Data_Full_Class.csv')
data

data.isna().sum()

data.drop(['salary', 'sl_no'], axis=1, inplace=True)
data.isna().sum()

data.nunique()

corr = data.corr()
corr.style.background_gradient(cmap='coolwarm').set_precision(2)

unique_vals = data.nunique()
col_log = data.columns
for i in range(0, len(unique_vals)):
    coln = str(col_log[i])
    if int(unique_vals[i]) < 5 and coln != 'status':
        data = pd.concat([data.drop(coln, axis=1), pd.get_dummies(data[coln], prefix=coln)], axis=1)

data_y = pd.DataFrame(data['status'])
data_x = data.drop('status', axis=1)
status_encoder = LabelEncoder()
data_y = status_encoder.fit_transform(data_y)

print('Guessing always placed accuracy: %f' % ((data['status'] == 'Placed').sum() / data['status'].count() * 100))