Learn R Programming

RTextTools (version 1.4.3)

train_models: makes a model object using the specified algorithms.

Description

Creates a trained model using the specified algorithms.

Usage

train_models(container, algorithms, ...)

Arguments

container

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

algorithms

List of algorithms as a character vector (e.g. c("SVM","MAXENT")).

Other parameters to be passed on to train_model.

Value

Returns a list of trained models that can be subsequently used in classify_models to classify new data.

Details

Calls the train_model function for each algorithm you list.

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)
models <- train_models(container, algorithms=c("RF","SVM"))
# }

Run the code above in your browser using DataLab