From 9e3124c679dc471d3bb98509b6b8c9a29d59ab85 Mon Sep 17 00:00:00 2001 From: k-david-pearce <54962664+k-david-pearce@users.noreply.github.com> Date: Tue, 10 Dec 2019 14:32:53 -0500 Subject: [PATCH] EDM Assignment 7 --- Assignment7.Rmd | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/Assignment7.Rmd b/Assignment7.Rmd index 105cbdf..2f29d98 100644 --- a/Assignment7.Rmd +++ b/Assignment7.Rmd @@ -1,37 +1,64 @@ --- -title: "Assignment 7 - Answers" -author: "Charles Lang" -date: "11/30/2016" +title: "Assignment 7" +author: "K. David Pearce" +date: "12/3/2019" output: html_document --- -In the following assignment you will be looking at data from an one level of an online geography tutoring system used by 5th grade students. The game involves a pre-test of geography knowledge (pre.test), a series of assignments for which you have the average score (av.assignment.score), the number of messages sent by each student to other students about the assignments (messages), the number of forum posts students posted asking questions about the assignment (forum.posts), a post test at the end of the level (post.test) and whether or not the system allowed the students to go on to the next level (level.up). +In the following assignment you will be looking at data from one level of an online geography tutoring system used by 5th grade students. The game involves a pre-test of geography knowledge (pre.test), a series of assignments for which you have the average score (av.assignment.score), the number of messages sent by each student to other students about the assignments (messages), the number of forum posts students posted asking questions about the assignment (forum.posts), a post test at the end of the level (post.test) and whether or not the system allowed the students to go on to the next level (level.up). ## Part I #Upload data ```{r} +library(tidyverse) +D1 <- read_csv("online.data.csv") ``` #Visualization ```{r} #Start by creating histograms of the distributions for all variables (#HINT: look up "facet" in the ggplot documentation) +ggplot(data = D1) + + geom_histogram(mapping = aes(id)) + + facet_wrap(vars(post.test.score, pre.test.score, + messages, forum.posts, av.assignment.score), + nrow = 2 ) + #Then visualize the relationships between variables +D2 <- rbind(data.frame(scores=D1$post.test.score, activity=D1$messages, comb='post vs messages'), + data.frame(scores=D1$pre.test.score, activity=D1$messages, comb='pre vs messages'), + data.frame(scores=D1$av.assignment.score, activity=D1$messages, comb='avg vs messages'), + data.frame(scores=D1$post.test.score, activity=D1$forum.posts, comb='post vs messages'), + data.frame(scores=D1$pre.test.score, activity=D1$forum.posts, comb='pre vs messages'), + data.frame(scores=D1$av.assignment.score, activity=D1$forum.posts, comb='avg vs messages') + ) + #Try to capture an intution about the data and the relationships +ggplot(D2, aes(scores, activity)) + geom_point() + facet_wrap(~comb, nrow = 2) + ``` #Classification tree ```{r} #Create a classification tree that predicts whether a student "levels up" in the online course using three variables of your choice (As we did last time, set all controls to their minimums) +library(rpart) +library(party) + +c.tree <- rpart(level.up ~ pre.test.score + post.test.score + messages, method="class", data=D1) + #Plot and generate a CP table for your tree +printcp(c.tree) + +post(c.tree, file = "tree.ps", title = "Level Up: Yes or No") # creates a pdf image of the tree #Generate a probability value that represents the probability that a student levels up based your classification tree -D1$pred <- predict(rp, type = "prob")[,2]#Last class we used type = "class" which predicted the classification for us, this time we are using type = "prob" to see the probability that our classififcation is based on. +# D1$pred <- predict(rp, type = "prob")[,2] ## Error in predict(rp, type = "prob") : object 'rp' not found +#Last class we used type = "class" which predicted the classification for us, this time we are using type = "prob" to see the probability that our classififcation is based on. ``` ## Part II #Now you can generate the ROC curve for your model. You will need to install the package ROCR to do this.