I am using the sklearn_api of gensim to create an estimator for a Word2vec model to pass it to sklearn's gridsearch . My code is as follows :
from gensim.sklearn_api import W2VTransformer
from sklearn.model_selection import GridSearchCV
s_obj = W2VTransformer(size=100,min_count=1,window=5)
parameters = {'size':(100,150,200),'min_count':(1,2,4),'alpha':(0.025,0.015)}
s_model = GridSearchCV(s_obj,parameters,cv=2)
s_model.fit(sentences)
print(s_model.best_params_)
Running the above code, I get the following error:
"If no scoring is specified, the estimator passed should have a 'score' method. The estimator W2VTransformer(alpha=0.025, batch_words=10000, cbow_mean=1,
hashfxn=<built-in function hash>, hs=0, iter=5,
max_vocab_size=None, min_alpha=0.0001, min_count=1, negative=5,
null_word=0, sample=0.001, seed=1, sg=0, size=100,
sorted_vocab=1, trim_rule=None, window=5, workers=3) does not."
I do not know how to resolve this. I tried using scoring='accuracy'
or scoring='hamming'
but they don't seem to work either.
Can someone please help me get rid of this error?