-
Notifications
You must be signed in to change notification settings - Fork 0
/
ms_university_prediction.py
203 lines (162 loc) · 6.53 KB
/
ms_university_prediction.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# -*- coding: utf-8 -*-
"""MS_University prediction.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1PgymAl_Y219rzSJq8np6yJ-OkbPmQAKf
"""
from google.colab import files
uploaded = files.upload()
import numpy as np
import pandas as pd
#import os
from matplotlib import pyplot as plt
from sklearn import preprocessing
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
import seaborn as sns
sns.set(style='white')
sns.set(style='whitegrid', color_codes=True)
df = pd.read_csv('GRE.csv')
df.head()
df.describe()
df.rename(columns = {'Chance of Admit ':'Chance of Admit', 'LOR ':'LOR'}, inplace=True)
df.drop(labels='Serial No.', axis=1, inplace=True)
df.describe()
fig, ax = plt.subplots(figsize=(10,10))
sns.heatmap(df.corr(), annot=True, cmap='Blues')
plt.figure(figsize=(20,6))
plt.subplot(1,2,1)
sns.distplot(df['CGPA'])
plt.title('CGPA Distribution of Applicants')
plt.subplot(1,2,2)
sns.regplot(df['CGPA'], df['Chance of Admit'])
plt.title('CGPA vs Chance of Admit')
plt.figure(figsize=(20,6))
plt.subplot(1,2,1)
sns.distplot(df['GRE Score'])
plt.title('Distributed GRE Scores of Applicants')
plt.subplot(1,2,2)
sns.regplot(df['GRE Score'], df['Chance of Admit'])
plt.title('GRE Scores vs Chance of Admit')
plt.figure(figsize=(20,6))
plt.subplot(1,2,1)
sns.distplot(df['TOEFL Score'])
plt.title('Distributed TOEFL Scores of Applicants')
plt.subplot(1,2,2)
sns.regplot(df['TOEFL Score'], df['Chance of Admit'])
plt.title('TOEFL Scores vs Chance of Admit')
fig, ax = plt.subplots(figsize=(8,6))
sns.countplot(df['Research'])
plt.title('Research Experience')
plt.ylabel('Number of Applicants')
ax.set_xticklabels(['No Research Experience', 'Has Research Experience'])
fig, ax = plt.subplots(figsize=(8,6))
sns.countplot(df['University Rating'])
plt.title('University Rating')
plt.ylabel('Number of Applicants')
targets = df['Chance of Admit']
features = df.drop(columns = {'Chance of Admit'})
X_train, X_test, y_train, y_test = train_test_split(features, targets, test_size=0.2, random_state=42)
from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
X_train['colleges_encoded'] = labelencoder.fit_transform(X_train['colleges'])
X_test['colleges_encoded'] = labelencoder.fit_transform(X_test['colleges'])
X_train=X_train.drop('colleges',axis=1)
X_test=X_test.drop('colleges',axis=1)
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.fit_transform(X_test)
linreg = LinearRegression()
linreg.fit(X_train, y_train)
y_predict = linreg.predict(X_test)
linreg_score = (linreg.score(X_test, y_test))*100
linreg_score
dec_tree = DecisionTreeRegressor(random_state=0, max_depth=6)
dec_tree.fit(X_train, y_train)
y_predict = dec_tree.predict(X_test)
dec_tree_score = (dec_tree.score(X_test, y_test))*100
dec_tree_score
forest = RandomForestRegressor(n_estimators=110,max_depth=6,random_state=0)
forest.fit(X_train, y_train)
y_predict = forest.predict(X_test)
forest_score = (forest.score(X_test, y_test))*100
forest_score
Methods = ['Linear Regression', 'Decision Trees', 'Random Forests']
Scores = np.array([linreg_score, dec_tree_score, forest_score])
fig, ax = plt.subplots(figsize=(8,6))
sns.barplot(Methods, Scores)
plt.title('Algorithm Prediction Accuracies')
plt.ylabel('Accuracy')
X_train[0]
regressor = LinearRegression()
regressor.fit(X_train,y_train)
# GRE_SCORE = float(input('Enter your GRE Score: '))
# TOEFL_Score = float(input('Enter your TOEFL Score: '))
# UR = float(input('Enter your University ranking (between 1-5) : '))
# SOP = float(input('Enter your Statement of Purpose(between 1-5): '))
# LOR = float(input('Enter your (Latter of recommendation ) score(between 1-5): '))
# CGPA = float(input('Enter your CGPA(between 1-10): '))
# RESEARCH = float(input('Enter your Statement of Purpose(between 1(means you did research) and 0(means no)): '))
#
# VTL = []
# VTL.extend([GRE_SCORE,TOEFL_Score,UR,SOP,LOR,CGPA,RESEARCH])
# LTL = [VTL]
LTL = [[180, 100, 3, 3.5, 2.5, 8.57, 1, 0.32]]
prediction = regressor.predict(LTL)
print('MODEL accuracy is : ',regressor.score(X_test,y_test))
print('Your chances of admission is :',prediction)
destinction = [0.90]
c = [0.80]
e = [0.70]
f = [0.60]
g = [0.40]
if prediction >= destinction :
print('You have chances of get admission in Harvard university ')
elif prediction >= c <destinction:
print('You have chances of get admission in MIT')
elif prediction >=e <c:
print('You have chances of get admission in Stanford university')
elif prediction >=f <e:
print('You have chances of get admission in Caltech(California Institute of Technology)')
elif prediction >=g <f:
print('You have chances of get admission in UOC (University of Chicago)')
elif prediction <g :
print("You don't have chances of get admission in top colleges !! Better luck next time:))")
forest = RandomForestRegressor(n_estimators=60,max_depth=3,random_state=0)
forest.fit(X_train, y_train)
# GRE_SCORE = float(input('Enter your GRE Score: '))
# TOEFL_Score = float(input('Enter your TOEFL Score: '))
# UR = float(input('Enter your University ranking (between 1-5) : '))
# SOP = float(input('Enter your Statement of Purpose(between 1-5): '))
# LOR = float(input('Enter your (Latter of recommendation ) score(between 1-5): '))
# CGPA = float(input('Enter your CGPA(between 1-10): '))
# RESEARCH = float(input('Enter your Statement of Purpose(between 1(means you did research) and 0(means no)): '))
#
# VTL = []
# VTL.extend([GRE_SCORE,TOEFL_Score,UR,SOP,LOR,CGPA,RESEARCH])
# LTL = [VTL]
LTL = [[150, 80, 3, 3.5, 2.5, 8.57, 1, 0.32]]
prediction = forest.predict(LTL)
print(prediction)
print('MODEL accuracy is : ',forest.score(X_test,y_test))
print('Your chances of admission is :',prediction)
destinction = [0.90]
c = [0.80]
e = [0.70]
f = [0.60]
g = [0.40]
if prediction >= destinction :
print('You have chances of get admission in Harvard university ')
elif prediction >= c <destinction:
print('You have chances of get admission in MIT')
elif prediction >=e <c:
print('You have chances of get admission in Stanford university')
elif prediction >=f <e:
print('You have chances of get admission in Caltech(California Institute of Technology)')
elif prediction >=g <f:
print('You have chances of get admission in UOC (University of Chicago)')
elif prediction <g :
print("You don't have chances of get admission in top colleges !! Better luck next time:))")