I have two pandas dataframes. one df(or X) with word2vec embeddings, with shape (50000,200). and another dataframe (or sparse matrix) with 0s and 1s filled. this df is the output of sklearn.preprocessing.MultiLabelBinarizer, so filled with only 1s and 0s in every column and shape of this df is (50000, 102).
I have tried fitting a skmultilearn.adapt.mlknn on this data, as shown below:
from skmultilearn.adapt import MLkNN
classifier = MLkNN(k=3)
# train
classifier.fit(X=x_train_w2v.to_numpy(), y=y_train.to_numpy())
the error I get is:
TypeError Traceback (most recent call last)
<ipython-input-36-5ae90a2db4ec> in <module>
5 # # train
6
----> 7 clf_mlknn.fit(X=x_train_w2v.to_numpy(),y=y_train.to_numpy())
8 # predict
9 # predict_mlknn_wv = classifier_new.predict(x_test_mlknn)
~\Anaconda3\lib\site-packages\skmultilearn\adapt\mlknn.py in fit(self, X, y)
216 self._prior_prob_true, self._prior_prob_false = self._compute_prior(self._label_cache)
217 # Computing the posterior probabilities
--> 218 self._cond_prob_true, self._cond_prob_false = self._compute_cond(X, self._label_cache)
219 return self
220
~\Anaconda3\lib\site-packages\skmultilearn\adapt\mlknn.py in _compute_cond(self, X, y)
163 """
164
--> 165 self.knn_ = NearestNeighbors(self.k).fit(X)
166 c = sparse.lil_matrix((self._num_labels, self.k + 1), dtype='i8')
167 cn = sparse.lil_matrix((self._num_labels, self.k + 1), dtype='i8')
TypeError: __init__() takes 1 positional argument but 2 were given
from the source code, i could see that NearestNeighbors
was being fit only with X, which can also be seen in above error in the line that starts with --> 165
. I presume that is what generating the error.
How do I fix this error and fit MLkNN properly?