-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
executable file
·37 lines (29 loc) · 1 KB
/
Copy pathhello.py
File metadata and controls
executable file
·37 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
import pickle
from mlxtend.plotting import plot_decision_regions
df = pd.read_csv('placement.csv')
plt.scatter(df['cgpa'],df['iq'],c=df['placement'])
plt.show()
df = df.iloc[:,1:]
x = df.iloc[:,:2]
y = df.iloc[:,-1]
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.1)
scaler = StandardScaler()
x_train = scaler.fit_transform(x_train)
x_test = scaler.transform(x_test)
#model training
clf = LogisticRegression()
clf.fit(x_train,y_train)
y_pred = clf.predict(x_test)
print('predicted values after training : ',y_pred)
print('testing_values',y_test)
#90% accuracy for 9 out of 10 will be predicted correctly
print('accuracy is: ',accuracy_score(y_test,y_pred))
plot_decision_regions(x_train, y_train.values, clf=clf, legend=2)
plt.show()