Issue
I'm practicing about classifications. I could see iris
has both attribute when I printed it. But I still getting same error.
from sklearn import datasets
from sklearn.metrics import classification_report
from sklearn.naive_bayes import GaussianNB
from sklearn.model_selection import train_test_split
iris = datasets.load_iris(),
X = iris.data
y = iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
nb_classifier = GaussianNB()
nb_classifier.fit(X_train, y_train)
y_pred = nb_classifier.predict(X_test)
print(classification_report(y_test, y_pred))
Solution
Remove the ,
at the end of
iris = datasets.load_iris(),
Otherwise iris
becomes a tuple with one element. Your line is identical to:
iris = (datasets.load_iris(),)
Answered By - Yevhen Kuzmovych
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.