create_container {RTextTools} | R Documentation |
creates a container for training, classifying, and analyzing documents.
Description
Given a DocumentTermMatrix
from the tm package and corresponding document labels, creates a container of class matrix_container-class
that can be used for training and classification (i.e. train_model
, train_models
, classify_model
, classify_models
)
Usage
create_container(matrix, labels, trainSize=NULL, testSize=NULL, virgin)
Arguments
matrix |
A document-term matrix of class |
labels |
A |
trainSize |
A range (e.g. |
testSize |
A range (e.g. |
virgin |
A logical ( |
Value
A container of class matrix_container-class
that can be passed into other functions such as train_model
, train_models
, classify_model
, classify_models
, and create_analytics
.
Author(s)
Timothy P. Jurka <tpjurka@ucdavis.edu>, Loren Collingwood <loren.collingwood@gmail.com>
Examples
library(RTextTools)
data(NYTimes)
data <- NYTimes[sample(1:3100,size=100,replace=FALSE),]
matrix <- create_matrix(cbind(data["Title"],data["Subject"]), language="english",
removeNumbers=TRUE, stemWords=FALSE, weighting=tm::weightTfIdf)
container <- create_container(matrix,data$Topic.Code,trainSize=1:75, testSize=76:100,
virgin=FALSE)