'How to incorporate gridsearch for hyperparameter tuning for Corex topic modeling?

I want to use the gridsearch to find the n_hidden/n_topic and also anchor_strength but I don't know how to incorporate it into Corex model.

Below is typic code for Corex

anchored_topic_model = ct.Corex(n_hidden=num_topics, seed=1)
anchored_topic_model.fit(doc_word, words=words, anchors=anchor_words, anchor_strength=3)

I tried below codes but did not work at all.

search_params = {'n_topics': [20, 50, 100, 200], 'anchor_strength': [2,3,4]}
corex = ct.Corex()
model = GridSearchCV(corex, param_grid=search_params)
model.fit(doc_word, words=words, anchors=anchor_words)

TypeError: If no scoring is specified, the estimator passed should have a 'score' method. The estimator <corextopic.corextopic.Corex object at 0x7ffd8424ab50> does not.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source