Skip to content

Develop #26

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

Open
wants to merge 6 commits 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
4 changes: 4 additions & 0 deletions 8_PREDMACHLEARN/.directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Dolphin]
Timestamp=2017,2,16,14,12,56
Version=3
ViewMode=1
15 changes: 12 additions & 3 deletions 8_PREDMACHLEARN/Practical Machine Learning Course Notes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ header-includes: \usepackage{graphicx} \usepackage{mathtools}
---


```{r setup, include=FALSE, error=TRUE, message=FALSE}
knitr::opts_chunk$set(echo = TRUE, comment = NA, error = TRUE)
```

$\pagebreak$


Expand Down Expand Up @@ -427,7 +431,8 @@ folds$test[[1]]

```{r}
# returns the arguments of the default train function
args(train.default)
# args(train.default) <- this dosn't work anymore in caret
args(train)
```

* `train` function has a large set of parameters, below are the default options
Expand Down Expand Up @@ -774,8 +779,11 @@ testing <- spam[-inTrain,]
preProc <- preProcess(log10(training[,-58]+1),method="pca",pcaComp=2)
# calculate PCs for training data
trainPC <- predict(preProc,log10(training[,-58]+1))
# add variable `type` to trainPC
type <- training$type
trainPC <- data.frame(trainPC, type) # join variable `type`
# run model on outcome and principle components
modelFit <- train(training$type ~ .,method="glm",data=trainPC)
modelFit <- train(type ~ .,method="glm",data=trainPC)
# calculate PCs for test data
testPC <- predict(preProc,log10(testing[,-58]+1))
# compare results
Expand All @@ -789,7 +797,7 @@ confusionMatrix(testing$type,predict(modelFit,testPC))

```{r message = FALSE, warning = FALSE}
# construct model
modelFit <- train(training$type ~ .,method="glm",preProcess="pca",data=training)
modelFit <- train(type ~ .,method="glm",preProcess="pca",data=training)
# print results of model
confusionMatrix(testing$type,predict(modelFit,testing))
```
Expand Down Expand Up @@ -1321,6 +1329,7 @@ pred.lda
- ***example: `caret` package***

```{r message = F, warning = F}
# package needed: klaR
# using the same data from iris, run naive Bayes on training data
nb <- train(Species ~ ., data=training,method="nb")
# predict test outcomes using naive Bayes model
Expand Down
1,467 changes: 775 additions & 692 deletions 8_PREDMACHLEARN/Practical_Machine_Learning_Course_Notes.html

Large diffs are not rendered by default.

Binary file modified 8_PREDMACHLEARN/Practical_Machine_Learning_Course_Notes.pdf
Binary file not shown.