NLP: Getting the top 5 or top 10 predictions

I am working on a social networking application and I have to make its news feed better. For example: If someone searches for 'suggest me some good books', it should yield some names.

Now, I have used the Infersent algo (to begin with) in order for my model to be able to answer questions.

I am getting only the best output that my model could predict viz., 'Alchemist'.

I want at least 4 or 5 other outputs, other words, the top five predictions.

I know that Xgboost has the ability to do this activity in some sorts, but I am not sure how I should use that in my problem.

Any heads up?

My apologies, I cannot share any code but I would really appreciate ideas and suggestions.

Thank you,

Topic data-science-model text-mining social-network-analysis nlp

Category Data Science


Welcome to datascience stackexchange. The answer you are probably looking for is, top 'k' most similar based on the search query.

I am going to assume here, that your input query is vectorized using the same vectorizer that was used to vectorize your catalog. Given these vectors, you could perform a cosine similarity for example with all the ones present in the catalog and could return back the top 'k' similar ones.

Let me know if this helps. I could elaborate more in case you have further questions.


There's predict_proba method in xgboost. You get probabilites for each class, sort them and take top 5.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.