Last data update: 2014.03.03

R: saves a maximum entropy model to a file.
save.modelR Documentation

saves a maximum entropy model to a file.

Description

Saves a multinomial logistic regression model of class maxent-class to a specified file. This model can then be loaded using function load.model.

Usage

save.model(model,file)

Arguments

model

An object of class maxent-class, as returned by the maxent function.

file

The path to a file used to save the model.

Author(s)

Timothy P. Jurka <tpjurka@ucdavis.edu>

Examples

# LOAD LIBRARY
library(maxent)

# READ THE DATA, PREPARE THE CORPUS, and CREATE THE MATRIX
data <- read.csv(system.file("data/NYTimes.csv.gz",package="maxent"))
corpus <- Corpus(VectorSource(data$Title[1:150]))
matrix <- DocumentTermMatrix(corpus)

# TRAIN USING SPARSEM REPRESENTATION
sparse <- as.compressed.matrix(matrix)
model <- maxent(sparse[1:100,],as.factor(data$Topic.Code)[1:100])
save.model(model,"myModel")

# TRAIN USING REGULAR MATRIX REPRESENTATION
model <- maxent(as.matrix(matrix)[1:100,],as.factor(data$Topic.Code)[1:100])
save.model(model,"myModel")

Results