From 3d34a8df261bdbaf755592bdc3fe40773c5a869a Mon Sep 17 00:00:00 2001 From: jc5230 Date: Mon, 18 Nov 2019 23:52:11 -0500 Subject: [PATCH 1/2] Complete! --- Assignment 5.Rmd | 48 ++++- Assignment-5.html | 522 ++++++++++++++++++++++++++++++++++++++++++++++ assignment5.Rproj | 13 ++ score_tree.ps | Bin 0 -> 10533 bytes tree.ps | Bin 0 -> 8044 bytes 5 files changed, 576 insertions(+), 7 deletions(-) create mode 100644 Assignment-5.html create mode 100644 assignment5.Rproj create mode 100644 score_tree.ps create mode 100644 tree.ps diff --git a/Assignment 5.Rmd b/Assignment 5.Rmd index 8838dc9..20e0f9b 100644 --- a/Assignment 5.Rmd +++ b/Assignment 5.Rmd @@ -8,15 +8,16 @@ For this assignment we will be using data from the Assistments Intelligent Tutor #Install & call libraries ```{r} -install.packages("party", "rpart") +#install.packages("party", "rpart", "rpart.plot") library(rpart) +library(rpart.plot) library(party) ``` ## Part I ```{r} -D1 <- +D1 <- read.csv("intelligent_tutor.csv") ``` ##Classification Tree @@ -31,6 +32,11 @@ printcp(c.tree) #Plot the tree post(c.tree, file = "tree.ps", title = "Session Completion Action: 1 - Ask teacher, 2 - Start new session, 3 - Give up") +plot(c.tree, compress = TRUE) +text(c.tree, use.n = TRUE) + +rpart.plot(c.tree) + ``` ## Part II @@ -40,25 +46,33 @@ 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.3, "Intervene", ifelse(D1$score < 0.6, "Monitor Progress", "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 <- rpart(advice ~ prior_prob_count + prior_percent_correct + hints, method="class", data=D1) ``` #Plot tree ```{r} +post(score_ctree, file = "score_tree.ps", title = "Session Completion Advice: 1 - Intervene, 2 - Monitor Progress, 3 - No Action") +plot(score_ctree, compress = TRUE) +text(score_ctree, use.n = TRUE) + +rpart.plot(score_ctree) ``` Please interpret the tree, which two behaviors do you think the teacher should most closely pay attemtion to? +1. hints >= 58 +2. prior_percent_corect < 0.6 + #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. @@ -66,16 +80,36 @@ Upload the data "intelligent_tutor_new.csv". This is a data set of a differnt sa ```{r} #Upload new data -D2 <- +D2 <- read.csv("intelligent_tutor_new.csv") #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? +The following results show that the predicted "no action" is less than the one observed, the "monitor progress" number is more than the observed number, and there is no student need to be intervened. I feel that the predicted one is more centralized since the middle choice - "monitor progress" is more than the observed one. +```{r} + +# Observed +# No Action: 34% + 39% = 73% +# Monitor Progress: 6% + 19% = 25% +# Intervene: 2% + +# Predicted +D3 <- apply(D2$prediction,1,which.max) +# No Action +sum(D3 == 3) / length(D3) # 64.5% +# Monitor Progress +sum(D3 == 2) / length(D3) # 34.5% +# Intervene +sum(D3 == 1) / length(D3) # 0.01% + +``` + + ### 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. diff --git a/Assignment-5.html b/Assignment-5.html new file mode 100644 index 0000000..4cc9c9b --- /dev/null +++ b/Assignment-5.html @@ -0,0 +1,522 @@ + + + + + + + + + + + + + + + + +Assignment 5 - Decision Trees + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +

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

+
#install.packages("party", "rpart", "rpart.plot")
+
+library(rpart)
+library(rpart.plot)
+library(party)
+
## Loading required package: grid
+
## Loading required package: mvtnorm
+
## Loading required package: modeltools
+
## Loading required package: stats4
+
## Loading required package: strucchange
+
## Loading required package: zoo
+
## 
+## Attaching package: 'zoo'
+
## The following objects are masked from 'package:base':
+## 
+##     as.Date, as.Date.numeric
+
## Loading required package: sandwich
+
+

Part I

+
D1 <- read.csv("intelligent_tutor.csv")
+

##Classification Tree First we will build a classification tree to predict which students ask a teacher for help, which start a new session, or which give up, based on whether or not the student completed a session (D1\(complete) and whether or not they asked for hints (D1\)hint.y).

+
c.tree <- rpart(action ~ hint.y + complete, method="class", data=D1) #Notice the standard R notion for a formula X ~ Y
+
+#Look at the error of this tree
+printcp(c.tree)
+
## 
+## Classification tree:
+## rpart(formula = action ~ hint.y + complete, data = D1, method = "class")
+## 
+## Variables actually used in tree construction:
+## [1] complete hint.y  
+## 
+## Root node error: 250/378 = 0.66138
+## 
+## n= 378 
+## 
+##      CP nsplit rel error xerror     xstd
+## 1 0.052      0     1.000  1.096 0.034730
+## 2 0.012      1     0.948  1.024 0.036359
+## 3 0.010      2     0.936  0.972 0.037264
+
#Plot the tree
+post(c.tree, file = "tree.ps", title = "Session Completion Action: 1 - Ask teacher, 2 - Start new session, 3 - Give up")
+
+plot(c.tree, compress = TRUE)
+text(c.tree, use.n = TRUE)
+

+
rpart.plot(c.tree)
+

## Part II

+

#Regression Tree

+

We want to see if we can build a decision tree to help teachers decide which students to follow up with, based on students’ performance in Assistments. We will create three groups (“teacher should intervene”, “teacher should monitor student progress” and “no action”) based on students’ previous use of the system and how many hints they use. To do this we will be building a decision tree using the “party” package. The party package builds decision trees based on a set of statistical stopping rules.

+

#Visualize our outcome variable “score”

+
hist(D1$score)
+

+

#Create a categorical outcome variable based on student score to advise the teacher using an “ifelse” statement

+
D1$advice <- ifelse(D1$score < 0.3, "Intervene", ifelse(D1$score < 0.6, "Monitor Progress", "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

+
score_ctree <- rpart(advice ~ prior_prob_count + prior_percent_correct + hints, method="class", data=D1)
+

#Plot tree

+
post(score_ctree, file = "score_tree.ps", title = "Session Completion Advice: 1 - Intervene, 2 - Monitor Progress, 3 - No Action")
+
+plot(score_ctree, compress = TRUE)
+text(score_ctree, use.n = TRUE)
+

+
rpart.plot(score_ctree)
+

+

Please interpret the tree, which two behaviors do you think the teacher should most closely pay attemtion to? 1. hints >= 58 2. prior_percent_corect < 0.6

+

#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.

+
#Upload new data
+
+D2 <- read.csv("intelligent_tutor_new.csv")
+
+#Generate predicted advice using the predict() command for new students based on tree generated from old students
+
+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?

+

The following results show that the predicted “no action” is less than the one observed, the “monitor progress” number is more than the observed number, and there is no student need to be intervened. I feel that the predicted one is more centralized since the middle choice - “monitor progress” is more than the observed one.

+
# Observed
+# No Action: 34% + 39% = 73%
+# Monitor Progress: 6% + 19% = 25%
+# Intervene: 2%
+
+# Predicted
+D3 <- apply(D2$prediction,1,which.max)
+# No Action
+sum(D3 == 3) / length(D3) # 64.5%
+
## [1] 0.645
+
# Monitor Progress
+sum(D3 == 2) / length(D3) # 34.5%
+
## [1] 0.345
+
# Intervene
+sum(D3 == 1) / length(D3) # 0.01%
+
## [1] 0.01
+
+

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.

+
+
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/assignment5.Rproj b/assignment5.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/assignment5.Rproj @@ -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 diff --git a/score_tree.ps b/score_tree.ps new file mode 100644 index 0000000000000000000000000000000000000000..9450d5d322c074b3d4dde12dbc2e0dfbfc65dbeb GIT binary patch literal 10533 zcmds7`)}OF5&r%Dis=sqWHjR5@^L&Gjse+`9ksFL`q4Bof`CV^PE2^@h2+UrRsZk( zW*>Y=C&hLVAgH70xZK&nB~ZKw84@sbDsQuN%ao7nU6mKr`f>f?0m&u*L`g_-9Afgg z%AeF5wpPoeYF$(>o4TymGqKtdUD3Lw_SLh;EV4JBL*lMUtG2|pl+3BAv7=(5kCdyk z**#h@3-Y$Dx3zpQsrjTA3RJ72$~CE2H~M{}T4*<&QhMw5ynerhngmMxjMr|6*KTTf zvYt$o{JtrR>iR^bSyl=hyYtDCOwVLx-KraNXL_HrqAVv%YW=$Hn)=tN;F+FqyUZzA z%qeZM$zrGt8AI}6J@BucagxwE=8E2tcye<5IBiva^!SMr3bYR&lK4ht zb*{d9{$lhVQ-oDll<&4Q_vS(3FOg-hQ)n{&b%ivR_<=7eFD^dbP6k#{L}{Lr)K8!$ z-wR>EE#0!LI8$Z2XJ@B51cZ>+xBO}PLOf3qn;)Pgy_;~a*gX9IGMP_^A3YlO`-y`^M@qX*vuVO?`)IlmO71LC72FQE&cydcbyT&*v3)`B zW+c3-?r`$_j}QOfjEva@j*>Fnkoav^cPd|%B&ywJrJA-_S0r*AMrlK0t57V#!6Mz@ zu|*+aS2V@?yn~^(C_pNp8zlNszXy4X%BE<4#oKb%lE_e2q$D;)#UrpPYH&j3(4K?I zzg1I{s4GRHdyl8?yis^QL#c+}1r8+979a3SU8oB5iZ_SAIM|tWSwrGhZ3_EXsur85 z-*zdqLefN00zRnNTCRt%KE>iA5|5EzkVr@zlXyzv8D_pEaYEv6B>qm~I}*=HydZIk ziI*h)LE;sO*CgJMcuV4+B)-SQzexN*;ztszCe40TDBRcG4Q_A1%!w z;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)pSV|48f9(o01s?0>B9fIJhw3=}a^Hv}n^>uE3hcX%GUYj0s>GRq{c@pdn2w9&OY7&YvVe!why)UbjR z78CB1jeFE^X6aGGDeXFH1|=P8G{UuSoM~X=QLlh4- ze|1{W6gHKOgF;JW)7UlC^zr2ak9Bhq$$O7ObsWRv;C85C!)lY;q&1*s5rb#+N1{fb zH4ZhmpEVQIu=3Z=8XeDURejdz^NtNZJ!__@(Lm@yG)jFMea6F%k#+xm)Zip=ke;Mr z&I1}>*Up+xKn+f6V4**2aGJS%)T7}uQ8Td6In;6gLe#)^HZ|zXj=|@nW;op8DP&Jz zNFTgB(w?#q8l2es*P*5_Gk}^tDDFT_A7AdQ`D0KMp%_N}+1K!V)}US-Dm2Uu6&ep* zg@zi#xqS@aFRjoRH71D02C~P1tDPoR)o0Bf)UYpjZsaFR>QWyMM|qKlqom0d+Vrf^ zs4>EQ5^8ikI?3xd&YDj^jXorGuH&w7$}FT0E0cK*;k=mM~xQf+F5f0HLROEYgp-VsNQkb=%{DI zIykV!hqK0?BddcZ#4V6-&Ts_o_qrZ9lz6#Z>YFRR{$bw^OM}IdON%dA8se^qN=N$G zeExa6E`pdt{7aU`SQ_Kf_L;i6HpUV%$8_+brX&3q4*R$2{+8?LaC*-{=O;q?OX2&n zr*LhG1-cWsuRpJ=0^b)R^kw+V5$z4S5Pb#EMM5S5*KON9NsvR9&lmlj zoxh}WaKSfozM%%_D;y{^Yt27*Veh*gxCnzF6uubAh>I>tcE|p987-Y}m`EXG5%e-f z=(wO!5?D=dwV9){n);!T^F-he_dO@qT(Roj%E{3=c|x%az--Yoa(xyFu%JzGt74W8 zEejNjFiz+Te-I~H=u<{oF1Lzf=`0sH7oik!(hIYIVFENfeore$=d_v&e<7qC+;wO7 zPB-ZMzWGQv=_d_32~Zt<8 literal 0 HcmV?d00001 diff --git a/tree.ps b/tree.ps new file mode 100644 index 0000000000000000000000000000000000000000..2fd2b6f8a73870ef0429354d165eaeb7d9089d20 GIT binary patch literal 8044 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tue, 19 Nov 2019 22:36:50 -0500 Subject: [PATCH 2/2] Add "class" in predict function. --- Assignment 5.Rmd | 11 +++++------ Assignment-5.html | 16 ++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Assignment 5.Rmd b/Assignment 5.Rmd index 20e0f9b..0354900 100644 --- a/Assignment 5.Rmd +++ b/Assignment 5.Rmd @@ -84,8 +84,7 @@ D2 <- read.csv("intelligent_tutor_new.csv") #Generate predicted advice using the predict() command for new students based on tree generated from old students -D2$prediction <- predict(score_ctree,D2) - +D2$prediction <- predict(score_ctree,D2, "class") ``` ## Part III Compare the predicted advice with the actual advice that these students recieved. What is the difference between the observed and predicted results? @@ -99,13 +98,13 @@ The following results show that the predicted "no action" is less than the one o # Intervene: 2% # Predicted -D3 <- apply(D2$prediction,1,which.max) + # No Action -sum(D3 == 3) / length(D3) # 64.5% +sum(D2$prediction == "No Action") / nrow(D2) # 64.5% # Monitor Progress -sum(D3 == 2) / length(D3) # 34.5% +sum(D2$prediction == "Monitor Progress") / nrow(D2) # 34.5% # Intervene -sum(D3 == 1) / length(D3) # 0.01% +sum(D2$prediction == "Intervene") / nrow(D2) # 0.01% ``` diff --git a/Assignment-5.html b/Assignment-5.html index 4cc9c9b..2a06b0d 100644 --- a/Assignment-5.html +++ b/Assignment-5.html @@ -409,9 +409,9 @@

Part I

## n= 378 ## ## CP nsplit rel error xerror xstd -## 1 0.052 0 1.000 1.096 0.034730 -## 2 0.012 1 0.948 1.024 0.036359 -## 3 0.010 2 0.936 0.972 0.037264 +## 1 0.052 0 1.000 1.088 0.034934 +## 2 0.012 1 0.948 1.048 0.035867 +## 3 0.010 2 0.936 0.996 0.036873
#Plot the tree
 post(c.tree, file = "tree.ps", title = "Session Completion Action: 1 - Ask teacher, 2 - Start new session, 3 - Give up")
 
@@ -445,7 +445,7 @@ 

Part I

#Generate predicted advice using the predict() command for new students based on tree generated from old students -D2$prediction <- predict(score_ctree,D2)
+D2$prediction <- predict(score_ctree,D2, "class")

Part III

@@ -457,15 +457,15 @@

Part III

# Intervene: 2% # Predicted -D3 <- apply(D2$prediction,1,which.max) + # No Action -sum(D3 == 3) / length(D3) # 64.5% +sum(D2$prediction == "No Action") / nrow(D2) # 64.5%
## [1] 0.645
# Monitor Progress
-sum(D3 == 2) / length(D3) # 34.5%
+sum(D2$prediction == "Monitor Progress") / nrow(D2) # 34.5%
## [1] 0.345
# Intervene
-sum(D3 == 1) / length(D3) # 0.01%
+sum(D2$prediction == "Intervene") / nrow(D2) # 0.01%
## [1] 0.01

To Submit Your Assignment