Description Usage Arguments Value Author(s) References Examples
View source: R/predict.maxent.R
Predicts the expected labels and probability scores of a matrix
of documents given a trained model of class maxent-class
generated by function maxent
.
1 2 |
object |
An object of class |
feature_matrix |
Either a regular |
... |
Not used but needed for compatibility with generic |
Returns a matrix
with the first column containing predicted labels
, and the remaining columns containing probability scores for each unique label.
Timothy P. Jurka <tpjurka@ucdavis.edu>
Y. Tsuruoka. "A simple C++ library for maximum entropy classification." University of Tokyo Department of Computer Science (Tsujii Laboratory), 2011. URL http://www-tsujii.is.s.u-tokyo.ac.jp/~tsuruoka/maxent/.
1 2 3 4 5 6 7 8 9 10 11 12 | # 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/PREDICT USING SPARSEM REPRESENTATION
sparse <- as.compressed.matrix(matrix)
model <- maxent(sparse[1:100,],as.factor(data$Topic.Code)[1:100])
results <- predict(model,sparse[101:150,])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.