'Series' object has no attribute 'getformat'

Viewed 757

I'm trying to run MLKnn classifier over my pandas dataframe and when I try to fit the classifier I get this error message:

Series object has no attribute 'getformat'

Here's the code:

from skmultilearn.adapt import MLkNN
from sklearn.model_selection import GridSearchCV

parameters = {'k': range(1,3), 's': [0.5, 0.7, 1.0]}
score = 'f1_macro'

X = dados.drop(['defects'], axis=1)

y = dados['defects']
X_train, X_test, y_train, y_test = train_test_split(X, y,random_state=1)

classifier = GridSearchCV(MLkNN(), parameters,scoring=score)
classifier.fit(X_train, y_train)

my dataframe is as shown below:

dtypes and data head

error message

1 Answers

I tried with your code, and reading here https://github.com/scikit-learn/scikit-learn/blob/95119c13a/sklearn/model_selection/_search.py#L723, it says that your parameters shuold be array like. So I converted it using numpy and the error went away.

Here just a snippet with the conversion I did.

from skmultilearn.adapt import MLkNN
from sklearn.model_selection import GridSearchCV, train_test_split
import numpy as np

parameters = {'k': range(1,3), 's': [0.5, 0.7, 1.0]}
score = 'f1_macro'

X = dados.drop(['defects'], axis=1)
y = dados['defects']

X_train, X_test, y_train, y_test = train_test_split(X, y,random_state=1)
classifier = GridSearchCV(MLkNN(), parameters,scoring=score)
classifier.fit(np.array(X_train), np.array(y_train))
Related