-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Project.Rmd
More file actions
96 lines (68 loc) · 4.71 KB
/
Copy pathTest_Project.Rmd
File metadata and controls
96 lines (68 loc) · 4.71 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
---
title: "Project_R"
author: "TJ"
date: "Sunday, January 25, 2015"
output:
html_document:
toc: yes
---
1.0 Genreal Information's
"Using devices such as Jawbone Up, Nike FuelBand, and Fitbit it is now possible to collect a large amount of data about personal activity relatively inexpensively. These type of devices are part of the quantified self movement ??? a group of enthusiasts who take measurements about themselves regularly to improve their health, to find patterns in their behavior, or because they are tech geeks. One thing that people regularly do is quantify how much of a particular activity they do, but they rarely quantify how well they do it. In this project, your goal will be to use data from accelerometers on the belt, forearm, arm, and dumbell of 6 participants. They were asked to perform barbell lifts correctly and incorrectly in 5 different ways. More information is available from the website here: http://groupware.les.inf.puc-rio.br/har (see the section on the Weight Lifting Exercise Dataset)."
2.0 Data Sources
The training_set data for this project are available here:
https://d396qusza40orc.cloudfront.net/predmachlearn/pml-training_set.csv
The test data are available here:
https://d396qusza40orc.cloudfront.net/predmachlearn/pml-testing_set.csv
The data for this project comes from this original source: http://groupware.les.inf.puc-rio.br/har. If you use the document you create for this class for any purpose please cite them as they have been very generous in allowing their data to be used for this kind of assignment.
Please Note that I the code I use loads the data directly from the URL provided, so that you are not required to download the file to your environment. Please customize the code to your specific needs.
3.0 Project Intended Results
The goal of your project is to predict the manner in which they did the exercise. This is the "classe" variable in the training_set set. You may use any of the other variables to predict with. You should create a report describing how you built your model, how you used cross validation, what you think the expected out of sample error is, and why you made the choices you did. You will also use your prediction model to predict 20 different test cases.
Your submission should consist of a link to a Github repo with your R markdown and compiled HTML file describing your analysis. Please constrain the text of the writeup to < 2000 words and the number of figures to be less than 5. It will make it easier for the graders if you submit a repo with a gh-pages branch so the HTML page can be viewed online (and you always want to make it easy on graders :-).
You should also apply your machine learning algorithm to the 20 test cases available in the test data above. Please submit your predictions in appropriate format to the programming assignment for automated grading. See the programming assignment for additional details.
Author initial note
Please consult the explorAnalysis.R (in code/raw code) file in the gitHub repo in order to better understand the reasoning behind the tatics choosen. For instance and as a very simple example, the initial loading of data to memory involves assuming some values as NA. For obvious reasons, this is only possible after you have already pooked around the data initially.
3.1 Reproduceablity
In order to reproduce the same results, you need a certain set of packages, as well as setting a pseudo random seed equal to the one I used. *Note:To install, for instance, the caret package in R, run this command: install.packages("caret")
The following Libraries were used for this project, which you should install - if not done yet - and load on your working environment.
3.2 Loading the necessary packages
```{r}
library(RColorBrewer)
library(caret)
library(rattle)
library(rpart)
library(rpart.plot)
```
4.0 Extracting Data
The training_set data set:
```{r}
train <- "http://d396qusza40orc.cloudfront.net/predmachlearn/pml-training.csv"
```
The test data set:
```{r}
test <- "http://d396qusza40orc.cloudfront.net/predmachlearn/pml-testing.csv"
```
The storage of the data:
```{r}
training <- read.csv(url(train), na.strings=c("NA","#DIV/0!",""))
testing <- read.csv(url(test), na.strings=c("NA","#DIV/0!",""))
```
5.0 Data Analisis
Spliting the data into test/train sets in a 0.5 ~ 0.5 ratio:
```{r}
inTrain <- createDataPartition(y=training$classe, p=0.5, list=FALSE)
myTraining <- training[inTrain, ]
myTesting <- training[-inTrain, ]
```
Decision Tree training_set:
```{r}
model_1 <- rpart(classe ~ ., data=myTraining, method="class")
fancyRpartPlot(model_1)
```
Decision Tree Prediction:
```{r}
predictions_1 <- predict(model_1, myTesting, type = "class")
```
Evaluation of the Prediction:
```{r}
confusionMatrix(predictions_1, myTesting$classe)
```