Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 5 - Hsiao Ting Yang #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions Assignment 5.Rmd
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
title: "Assignment 5 - Decision Trees"
author: "Charles Lang"
author: "Hsiao Ting Yang"
date: "November 9, 2016"
output: html_document
---
For this assignment we will be using data from the Assistments Intelligent Tutoring system. This system gives students hints based on how they perform on math problems.

#Install & call libraries
```{r}
install.packages("party", "rpart")

library(rpart)
library(party)
```

## Part I
```{r}
D1 <-
D1 <- read.csv("intelligent_tutor.csv", header = TRUE)
```

##Classification Tree
Expand All @@ -40,42 +39,68 @@ We want to see if we can build a decision tree to help teachers decide which stu

#Visualize our outcome variable "score"
```{r}

hist(D1$score)
```

#Create a categorical outcome variable based on student score to advise the teacher using an "ifelse" statement
```{r}
D1$advice <-

D1$advice <- ifelse(D1$score <= 0.4, "intervene", ifelse(D1$score >0.4 & D1$score <=0.8, "monitor", "no action"))

```

#Build a decision tree that predicts "advice" based on how many problems students have answered before, the percentage of those problems they got correct and how many hints they required
```{r}
score_ctree <-

score_ctree <- ctree(as.factor(D1$advice) ~ prior_prob_count + prior_percent_correct + hints, data = D1)

```

#Plot tree
```{r}

plot(score_ctree)

```

Please interpret the tree, which two behaviors do you think the teacher should most closely pay attemtion to?

##Comment
I think the teacher should focus on node 7 and node 9 since those nodes have the higher percentage intervention based on the categorical outcome I setted. For node 7, these group of students have asked for less than 12 hints and answered less than 62.9% correctly. For node 9, these group of students have asked for more than 12 hints. These two behaviors should be what teachers should closely pay attention to since they've asked the most hints and answered the least amount of questions correctly.

#Test Tree
Upload the data "intelligent_tutor_new.csv". This is a data set of a differnt sample of students doing the same problems in the same system. We can use the tree we built for the previous data set to try to predict the "advice" we should give the teacher about these new students.

```{r}
#Upload new data

D2 <-
D2 <- read.csv("intelligent_tutor_new.csv", header = TRUE)

#Generate predicted advice using the predict() command for new students based on tree generated from old students

D2$prediction <-
D2$prediction <- predict(score_ctree, D2)

```
## Part III
Compare the predicted advice with the actual advice that these students recieved. What is the difference between the observed and predicted results?

```{r}

D2$advice <- ifelse(D2$score <= 0.4, "intervene", ifelse(D2$score >0.4 & D2$score <=0.8, "monitor", "no action"))

T1 <- table(D2$prediction)

#monitor
T1[2]/sum(T1)

#no action
T1[3]/sum(T1)

```
##Comment
Our prediction is off but we are still able to capture some patterns. Most of the people are in the "no action" category, so that's why it has the highest percentage with 58%. The next group is the "monitor", which has 42%.


### To Submit Your Assignment

Please submit your assignment by first "knitting" your RMarkdown document into an html file and then commit, push and pull request both the RMarkdown file and the html file.
Expand Down
508 changes: 508 additions & 0 deletions Assignment-5.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions assignment5.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
Binary file added tree.ps
Binary file not shown.