train_models: makes a model object using the specified algorithms.

Description Usage Arguments Details Value Author(s) Examples

View source: R/train_models.R

Description

Creates a trained model using the specified algorithms.

Usage

1
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.

Details

Calls the train_model function for each algorithm you list.

Value

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

Author(s)

Wouter Van Atteveldt <wouter@vanatteveldt.com>

Examples

1
2
3
4
5
6
7
8
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"))

Example output

Loading required package: SparseM

Attaching package:SparseMThe following object is masked frompackage:base:

    backsolve

Warning messages:
1: In TermDocumentMatrix.SimpleCorpus(x, control) :
  custom functions are ignored
2: In TermDocumentMatrix.SimpleCorpus(x, control) :
  custom tokenizer is ignored

RTextTools documentation built on April 26, 2020, 9:05 a.m.