R: keyword extraction with naive bayes -
i've got documents , each document i've got keywords. want use these documents train model. data looks follows:
postag <- list() tfidf <- list() labels <- list()
one element of each list represents document. there 50 documents. postag[[1]]
vector part of speech tagging each word in document 1, tfidf[[1]]
vector tfidffactor each word in document 1, labels[[1]]
vector labels (0 = no keyword, 1 = keyword). note: words each document ordered: postag[[1]][1]
pos first word in document 1, tfidf[[1]][1]
tfidffactor same word in document 1, , labels[[1]][1]
says if word keyword.
now want use these 50 documents train (naive bayes) model predicts if word keyword or not. features tfidf factor , pos. me?
you can use e1071 package:
data(iris) m <- naivebayes(species ~., data = iris) predict(m, iris)
note column species
must factor variable example:
iris["species"]<- as.factor(iris["species"])
but in case species
factor already, don't have change it.
Comments
Post a Comment