0

我正在按照本教程进行操作,就像我做训练集一样,但它一直在说同样的事情。有人知道这有什么问题吗?

> #Construct sample document-term matrix con el vectorizer inicial
> sample.it <- itoken(rawsample$Abstract, 
+                     preprocessor = prep_fun, 
+                     tokenizer = tok_fun, 
+                     ids = rawsample$id,
+                     progressbar = F) 
> sample.dtm <- create_dtm (sample.it, vectorizer, vtype = "dgTMatrix", progressbar = FALSE)
> sample.tfidf <- TfIdf$new() #define tfidf model
> sample.tfidf <- fit_transform(sample.dtm, tfidf)
Error in fit_transform.Matrix(sample.dtm, tfidf) : 
  inherits(model, "mlapiTransformation") is not TRUE
> sample.tfidf  = create_dtm(sample.it, vectorizer, vtype = "dgTMatrix", progressbar = FALSE) %>% 
+   transform(tfidf)
Error in transform.Matrix(., tfidf) : 
  inherits(model, "mlapiTransformation") is not TRUE

4

1 回答 1

1
sample.tfidf <- TfIdf$new() #define tfidf model
sample.tfidf <- fit_transform(sample.dtm, tfidf)

你在哪里定义tfidf?可能你需要类似的东西:

model =  TfIdf$new() #define tfidf model
sample.tfidf = fit_transform(sample.dtm, model)

于 2019-10-27T10:58:07.117 回答