I have built a MLP model using keras to classify text. In order to predict the class of a given text, again I did below steps which I did for "training" set in the model building process
q is some random question in text format
ls is a defined function to convert text into lower case and do stemming
token=itoken(q,preprocess_function=ls,tokenizer=word_tokenizer)
vtxt=create_vocabulary(token,stopwords=stemDocument(stopwords('english')),ngram=c(1,1))
vectorizer=vocab_vectorizer(vtxt)
# #Document term matrix
dtmq=create_dtm(token,vectorizer)
To get TF-IDF, which is parsed in MLP, I have used below steps
Now the dimension of 'dtmq' is (1,35) but my model requires input_shape of 1462, how can I convert the given text in such a way that my MLP model accepts.
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: