This is the code and I\'m getting the error in the last line only which is y_pred = classifier.predict(X_test)
. The error I\'m getting is AttributeError:
Because you haven't fitted the classifier
yet. For classifier
to have the model variable available, you need to call
classifier.fit(X_train, y_train)
Although you have used cross_val_score()
over the classifier
, and found out accuracies, but the main point to note here is that the cross_val_score
will clone the supplied model and use them for cross-validation folds. So your original estimator classifier
is untouched and untrained.
You can see the working of cross_val_score
in my other answer here
So put the above mentioned line just above y_pred = classifier.predict(X_test)
line and you are all set. Hope this makes it clear.