-
Notifications
You must be signed in to change notification settings - Fork 0
/
Admission_Prediction_v1.Rmd
205 lines (120 loc) · 4.38 KB
/
Admission_Prediction_v1.Rmd
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
203
204
---
title: "College Admission Prediction"
author: "Deo Ivan Mareza"
date: "`14 February 2020`"
output:
html_document:
df_print: paged
highlight: breezedark
theme: cosmo
toc: yes
toc_float:
collapsed: no
word_document:
toc: yes
---
# INTRODUCTION
In this exercise, I want to predict someone's `chance of admission` to a university of their choice using linear regression method based on other variables.
<br><br>
I will use MSE and RMSE as a measure of my model's accuracy.
<br>
<br>
# DATA PREPARATION
Library packages that I'm using
```{r,warning=FALSE, results='hide',message=FALSE}
library(tidyverse)
library(GGally)
library(MLmetrics)
library(car)
library(lmtest)
library(stringr)
```
Reading the data
```{r,warning=FALSE, results='hide',message=FALSE}
admission <- read_csv("data_input/Admission_Predict_Ver1.1.csv")
```
Checking the data
```{r, results='asis'}
knitr::kable(head(admission, 10))
```
<br>
<font size = "5">
The Data Explains : <br><br>
</font>
1. GRE Scores ( out of 340 ) <br>
2. TOEFL Scores ( out of 120 ) <br>
3. University Rating ( out of 5 ) <br>
4. Statement of Purpose and Letter of Recommendation Strength ( out of 5 ) <br>
5. Undergraduate GPA ( out of 10 ) <br>
6. Research Experience ( either 0 or 1 ) <br>
7. Chance of Admit ( ranging from 0 to 1 )
<br>
I'm changing the column names to something more code-friendly & our research column from numeric to a logical TRUE and FALSE
```{r}
names(admission) <- str_replace_all(str_to_lower(names(admission)), " ", "_")
admission[,"research"] <- as.logical(as.integer( unlist(admission[,"research"])))
```
## Separating Data to Train and Test
In order to test the model on later stage, I'll separate the dataset into 2, training and testing data with a ratio 8:2.
```{r}
admission_train <- admission[1:400,]
admission_test <- admission[401:ncol(admission),]
```
<br>
# DATA ANALYSIS
Checking if any of the variables are linearly related to each other.
```{r, warning=FALSE,}
ggcorr(admission_train, label = T, hjust = .7, layout.exp = 1, label_size = 4, cex = 3)
```
Seeing that all variablers have a good correlation with each other except the serial number, I think we can move to modelling and exclude the serial number in our model.
<br>
# MODELLING
I'll make a linear model with the name `model_admission`
```{r}
model_admission <- lm(formula = chance_of_admit ~ gre_score + toefl_score +
university_rating + lor + cgpa + research, data = admission_train)
summary(model_admission)
```
I think I'm pretty happy with the resulting R squared and t value. The university rating has a lower t value but I personally think that it's an important variable, so I'll keep it inside the linear model.
<br>
## Checking Our Assumption
### Normality
```{r}
hist(model_admission$residuals)
shapiro.test(model_admission$residuals)
```
### Homoscedacity
```{r}
plot(model_admission$fitted.values, model_admission$residuals)
abline(h = 0, col = "red")
bptest(model_admission)
```
Based on our bp test, there seemed to be abit of a pattern here, but looking at the graph, I think it's still acceptable.
### Multicolinearity
```{r}
vif(model_admission)
```
It seemed that our predictor variable does not correlate strongly with each other.
<br><br>
### Initial MSE and RMSE with training data
```{r}
MSE(y_pred = model_admission$fitted.values, y_true = admission_train$chance_of_admit)
RMSE(y_pred = model_admission$fitted.values, y_true = admission_train$chance_of_admit)
```
<br>
# PREDICTION
Using the model I've built, I will try to test it with the `admission_test` dataset that we've split before.
```{r}
admission_test$chance_admit_predict <- round(predict(object = model_admission, newdata = admission_test),2)
```
### MSE and RMSE value with test data
```{r}
MSE(y_pred = admission_test$chance_admit_predict, y_true = admission_test$chance_of_admit)
RMSE(y_pred = admission_test$chance_admit_predict, y_true = admission_test$chance_of_admit)
```
<br>
# CONCLUSION
Considering that our range of data is between `0.34` and `0.97`, I think my model have achieved a pretty good prediction result with average error value of `0.063`.
<br>
# CREDITS
The data is kindly provided by : Mohan S Acharya, Asfia Armaan, Aneeta S Antony : A Comparison of Regression Models for Prediction of Graduate Admissions, IEEE International Conference on Computational Intelligence in Data Science 2019