Learn R Programming

RTextTools (version 1.4.3)

classify_model: makes predictions from a train_model() object.

Description

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

Usage

classify_model(container, model, s=0.01, ...)

Arguments

container

Class of type matrix_container-class generated by the create_container function.

model

Slot for trained SVM, SLDA, boosting, bagging, RandomForests, glmnet, decision tree, neural network, or maximum entropy model generated by train_model.

s

Penalty parameter lambda for glmnet classification.

Additional parameters to be passed into the predict function of any algorithm.

Value

Returns a data.frame of predicted codes and probabilities for the specified algorithm.

Details

Only one model may be passed in at a time for classification. See train_models and classify_models to train and classify using multiple algorithms.

Examples

Run this code
# NOT RUN {
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)
svm_model <- train_model(container,"SVM")
svm_results <- classify_model(container,svm_model)
# }

Run the code above in your browser using DataLab