-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNaiveStudentGradePredict.Rmd
More file actions
211 lines (142 loc) · 4.48 KB
/
NaiveStudentGradePredict.Rmd
File metadata and controls
211 lines (142 loc) · 4.48 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
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
205
206
207
208
209
210
211
---
title: "Predict Student's Final Grade"
output:
html_document:
df_print: paged
---
<p>
Created by Jonathan Calderon Chavez for the 2nd Annual CSEDM Data Challenge - Track 2 <br> loosely based on Yang Azure's naive_model
</p>
<p>
<b> Install/Importing ML Libraries </b>
</p>
```{r}
library(tidyverse)
library(BBmisc)
library(caret)
```
<p>
Loading Student Training Data
</P>
```{r}
# Main path to data set
# base_dir <- "~/spring2022/cs496/cs496_project"
base_dir <- "~/csedm/cs496-csedm-main"
# path to subject.csv from the data set dir
subject_path <- "Subject.csv"
# combine paths
train_subjectID_and_grades_path <- paste(base_dir, subject_path, sep="/")
# read data from subject.csv
train_subjectID_and_grades_data <- read_csv(train_subjectID_and_grades_path)
```
<p>
View Table
</p>
```{r}
train_subjectID_and_grades_data
names(train_subjectID_and_grades_data)[names(train_subjectID_and_grades_data) == "X-Grade"] <- "x_grade"
# here we separate the labels
training_labels <- train_subjectID_and_grades_data["x_grade"]
student_id <- train_subjectID_and_grades_data["SubjectID"]
# training_labels
# student_id
```
<p>
Hand Crafted Feature Extraction Algorithm
</p>
```{r}
find_avg_attempts = function(student_instance, early_dataset){
# This is get the all data related to the current student
first_half_data <- filter(early_dataset, SubjectID == student_instance)
# find avg number of attempts
avg_attempts <- median(first_half_data$Attempts)
}
```
```{r}
find_percent_CorrectEventually = function(student_instance, early_dataset){
# This is get the all data related to the current student
first_half_data <- filter(early_dataset, SubjectID == student_instance) # All of this student's problem entries from the the early part of the semester
# find percent of time student gets the right answer eventually
PerCorrectEventually <- mean(first_half_data$CorrectEventually) # Average number correct for all of this student's problems that are attempted
# final_grade <- 100
}
```
```{r}
# get_final_grade = function(student, dataset) {
# grade <- dataset[student, "X-Grade"]
# }
```
<p>
Load in the Early semester Performance
</p>
```{r}
# loading early data set
early_dataset_path <- paste(base_dir, "Train/early.csv", sep="/")
early_dataset <- read_csv(early_dataset_path)
```
<p>
Feature Extraction on the training data
</p>
```{r}
# find the avg number of attempts
train_subjectID_and_grades_data <- train_subjectID_and_grades_data %>%
rowwise() %>%
mutate(avg_attempts = find_avg_attempts(SubjectID, early_dataset))
# find the percent of time student gets the right answer, eventually
train_subjectID_and_grades_data <- train_subjectID_and_grades_data %>%
rowwise() %>%
mutate(per_CorrectEventually =
find_percent_CorrectEventually(SubjectID,early_dataset))
# student_id <- student_id %>%
# rowwise() %>%
# mutate(final_grade =
# get_final_grade(SubjectID, train_subjectID_and_grades_data))
student_features <- tibble(train_subjectID_and_grades_data)
# student_features <- select(student_features, -c(SubjectID))
student_features
```
```{r}
model1 <- lm(avg_attempts~x_grade, data=student_features)
model2 <- lm(per_CorrectEventually~x_grade, data = student_features)
attempts_grade_plot <- student_features %>%
ggplot(aes(x = avg_attempts, y = x_grade)) +
geom_point() + geom_smooth(method="lm")
labs(x = "Average attempts", y = "Final grade")
model3 <- lm(x_grade~avg_attempts+per_CorrectEventually, data=student_features)
percent_grade_plot <- student_features %>%
ggplot(aes(x = per_CorrectEventually, y = x_grade)) +
geom_point() + geom_smooth(method="lm")
labs(x = "Percent correct eventually", y = "Final grade")
attempts_grade_plot
percent_grade_plot
s1 <- summary(model1)
s2 <- summary(model2)
s3 <- summary(model3)
s1$r.squared # Correlation between average attempts and final grade
s2$r.squared # Correlation between percent eventually correct and final grade
s3$r.squared
# look at outliers
```
```{r}
```
```{r}
```
<p>
Standardize Features
</p>
```{r}
student_features <-
student_features %>%
mutate(across(c("avg_attempts", "per_CorrectEventually"), normalize))
student_features
```
<p>
Train Simple ML Model
</p>
```{r}
```
<p>
Evaluation - Calculate Metrics
</p>
```{r}
```