Learn R Programming

RTextTools (version 1.3.8)

classify_models: makes predictions from a train_models() object.

Description

Uses a trained model from the train_models function to classify new data.

Usage

classify_models(corpus, models, ...)

Arguments

corpus
Class of type matrix_container-class generated by the create_corpus function.
models
List of models to be used for classification generated by train_models.
...
Other parameters to be passed on to classify_model.

Details

Use the list returned by train_models to use multiple models for classification.

Examples

Run this code
library(RTextTools)
data <- read_data(system.file("data/NYTimes.csv.gz",package="RTextTools"),type="csv")
data <- data[sample(1:3100,size=100,replace=FALSE),]
matrix <- create_matrix(cbind(data$Title,data$Subject), language="english", 
removeNumbers=TRUE, stemWords=FALSE, weighting=weightTfIdf)
corpus <- create_corpus(matrix,data$Topic.Code,trainSize=1:75, testSize=76:100, 
virgin=FALSE)
models <- train_models(corpus, algorithms=c("MAXENT","SVM"))
results <- classify_models(corpus, models)

Run the code above in your browser using DataLab