How to Build a Text Mining, Machine Learning Document Classification System in R!

Check Your Assumptions · 186K views · 2012 · 26:02

Open on YouTube

Data science & statisticsMachine learning & deep learningPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the tutorial whose R script they copied for text classification projects, then ask for help fixing errors when adapting it to their own data.

Recommended by 1 people across 1 different months, 2013 to 2018.

What it is

A 26-minute screencast by Tim D'Auria of Check Your Assumptions that builds a document classification system from scratch in R using the tm package. It trains a model to identify which presidential candidate (Obama or Romney) delivered unlabeled campaign speeches, covering corpus cleaning, term-document matrices and a k-nearest-neighbour classifier.

What people said

Recommends user3465732 · 2014-03 · Stack Overflow · on “document classification with r”

I have been trying to follow the document classification tutorial on YouTube [this video] using R and it's really interesting, but when I tried to run the first part of the script I keep getting this error Error in FUN(c("obama", "romney")[[1L]], ...) : could not find function "corpus" . I really don't know why that is, but I am hoping someone could help me figure it out. This is the script: #init libs <- c("tm", "plyr", "class") lapply(libs, require, character.only = TRUE) # set options options(stringAsFactors = FALSE) #set parameters candidates <- c("obama","romney") pathname <- "C:\\Users\\admin\\Documents\\speeches" #clean text cleanCorpus <- function(corpus){ corpus.tmp <- tm_map(corpus, rem

Cites user2647221 · 2013-08 · Stack Overflow · on “NA/NaN/Inf in foreign function call (arg 6)”

I am doing a term paper in Text mining using R. Our task is to guess the tone of an article (positive/negative). The articles are stored in respective folders. I need to create a classification system which will learn through training samples. I reused the code from [this video] The entire code except the last line got executed successfully. Following is the code. tone<- c("Positive", "Negative") folderpath <- "C:/Users/Tanmay/Desktop/R practice/Week8" options(stringAsFactors = FALSE) corpus<-Corpus(DirSource(folderpath)) corpuscopy<-corpus summary(corpus) inspect(corpus) #Clean data CleanCorpus <- function(corpus){ corpustemp <- tm_map(corpus, removeNumbers) corpustemp <- tm_map(corpus, removePu

Cites user3725523 · 2014-06 · Stack Overflow · on “R Error in trying to access local data”

I just tried out this quite interesting Youtube-R-tutorial about building a text mining machine: [this video] Currently I have come so far that the whole code I have is # Tutorial: [this video] # init libs <- c("tm", "plyr", "class") lapply(libs, require, character.only = TRUE) # set options options(stringsAsFactors = FALSE) # set parameters candidates <- c("Obama", "Romney") pathname <- "C:/Users/***" # here I pointed out the name for reasons of anonymity # clean text cleanCorpus <- function(corpus){ corpus.tmp <- tm_map(corpus, removePunctuation) corpus.tmp <- tm_map(corpus.tmp, stripWhitespace) corpus.tmp <- tm_map(corpus.tmp, tolower) corpus.tmp <- tm_map(corpus.tmp, removeWords, stopwords("englis

Cites Edin · 2015-01 · Stack Overflow · on “Spam filter in R - error in data frame”

I have to build spam or ham filter in R studio. This is my code so far libs <- c("tm", "plyr", "class") lapply(libs, require, character.only= TRUE) options(StringsAsFactors = FALSE) spamOrHam <- c("spam", "ham") pathname <- ("C:/Users/Edin/Dropbox/FIŠ/2. letnik/Multivariatna analiza/Seminarska/mail") cleanCorpus <- function(corpus){ corpus.tmp <- tm_map(corpus, removePunctuation) corpus.tmp <- tm_map(corpus.tmp, stripWhitespace) corpus.tmp <- tm_map(corpus.tmp, tolower) corpus.tmp <- tm_map(corpus.tmp, removeWords, stopwords("english")) corpus.tmp <- Corpus(VectorSource(corpus.tmp)) return(corpus.tmp) } generateTDM <- function(mail, path){ m.dir <- sprintf("%s/%s", path, mail) m.cor <- Corpu

Cites dhowie · 2018-03 · Stack Overflow · on “How to export rStudio analysis detail”

working on a document classification model using the code provided by Tim DAuria ( [this video] ), but can not figure out how to actually see the detail analysis of the classification on the 'Test' data. I am using the model to help classify contracts by type and want to see the specific classification assigned to the different contracts. For example, the model assigns 15 contracts as "x" type of contract. How can I view those 15 file names? The code below works great for the classification piece. Just posting it for reference. Please help! Really new at this and I'm sure I'm missing something obvious but could not find anything on the web. Classification Code below: #int libs <- c("tm", "plyr","