This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ROCR) | |
| library(rpart) | |
| library(rpart.plot) | |
| gerber <- read.csv('gerber.csv') | |
| table(gerber$voting) | |
| table(gerber$voting)[2] / nrow(gerber) | |
| # Which of the four "treatment groups" had the largest percentage of people who actually voted (voting = 1)? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(caTools) | |
| library(rpart) | |
| library(randomForest) | |
| letters <- read.csv('letters_ABPR.csv') | |
| letters$isB <- as.factor(letters$letter == 'B') | |
| set.seed(1000) | |
| spl <- sample.split(letters$isB, SplitRatio = 0.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(caTools) | |
| library(ROCR) | |
| library(rpart) | |
| library(rpart.plot) | |
| library(randomForest) | |
| library(caret) | |
| data <- read.csv('census.csv') | |
| set.seed(2000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| packages <- c('tm', 'SnowballC', 'caTools', 'rpart', 'rpart.plot', 'randomForest', 'ROCR') | |
| if (length(setdiff(packages, rownames(installed.packages()))) > 0) { | |
| install.packages(setdiff(packages, rownames(installed.packages()))) | |
| } | |
| library(tm) | |
| library(SnowballC) | |
| library(caTools) | |
| library(rpart) | |
| library(rpart.plot) | |
| library(randomForest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| packages <- c('tm', 'SnowballC', 'caTools', 'rpart', 'rpart.plot', 'randomForest', 'ROCR') | |
| if (length(setdiff(packages, rownames(installed.packages()))) > 0) { | |
| install.packages(setdiff(packages, rownames(installed.packages()))) | |
| } | |
| library(tm) | |
| library(SnowballC) | |
| library(caTools) | |
| library(rpart) | |
| library(rpart.plot) | |
| library(randomForest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Basic movie recommendation system, using content filtering (grouping movies with similar characteristics (ie., genre) together). | |
| # Download dataset, if it does not exist. | |
| fileName <- 'movieLens.txt'; | |
| if (!file.exists(fileName)) { | |
| # , method="curl" | |
| download.file(paste0('http://files.grouplens.org/datasets/movielens/ml-100k/u.item', ''), fileName) | |
| } | |
| movies <- read.table('movieLens.txt', header=F, sep='|', quote='"') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(flexclust) | |
| # Download dataset, if it does not exist. | |
| fileName <- 'flower.csv'; | |
| if (!file.exists(fileName)) { | |
| # , method="curl" | |
| download.file(paste0('https://d37djvu3ytnwxt.cloudfront.net/asset-v1:MITx+15.071x_3+1T2016+type@asset+block/', fileName), fileName) | |
| } | |
| fileName <- 'healthy.csv'; |