Learn R Programming

RTextTools (version 1.3.2)

train_models: makes a model object using the specified algorithms.

Description

Creates a trained model using the specified algorithms.

Usage

train_models(corpus, algorithms, ...)

Arguments

corpus
Class of type matrix_container-class generated by the create_corpus 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
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"))

Run the code above in your browser using DataLab