Last data update: 2014.03.03
|
R: loads a maximum entropy model from a file.
load.model | R Documentation |
loads a maximum entropy model from a file.
Description
Loads a multinomial logistic regression model of class maxent-class given a file created by function save.model .
Usage
load.model(file)
Arguments
file |
The path to a file created by function save.model .
|
Value
Returns an object of class maxent-class with two slots.
model |
A character vector containing the trained maximum entropy model.
|
weights |
A data.frame listing all the weights in three columns: Weight , Label , and Feature .
|
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")
saved_model <- load.model("myModel")
results <- predict(saved_model,sparse[101:150,])
Results
|