-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmissionprediction.py
More file actions
28 lines (21 loc) · 922 Bytes
/
admissionprediction.py
File metadata and controls
28 lines (21 loc) · 922 Bytes
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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
exam = pd.read_csv('C:\\Aneesh\\Machine Learning\\examdata.csv')
X = exam.iloc[:,:-1] ### all columns except last column(Input)
Y = exam.iloc[:, -1] ### Only last column (Output)
# filter out the applicants that got admitted
admitted = exam.loc[Y == 1]
# filter out the applicants that din't get admission
not_admitted = exam.loc[Y == 0]
##PLOTS##
plt.scatter(admitted.iloc[:, 0],admitted.iloc[:,1], label='Admitted')
plt.scatter(not_admitted.iloc[:, 0], not_admitted.iloc[:, 1], label='Not Admitted')
plt.legend()
plt.show()
xTrain, xTest, yTrain, yTest = train_test_split(x, y, test_size = 0.2, random_state = 0)
model = LogisticRegression()
model.fit(xTrain, yTrain)
predicted_classes = model.predict(xTest)