scores = cross_val_score(clf1, X, y, cv=3,scoring='accuracy', n_jobs=-1)
- Fast parameter optimization with randomized search
- from Python: Real World Machine Learning
- Publisher: Packt Publishing
- Released: November 2016
This is wrong. You are using the testing data to do the cross-validation. You should have used accuracy = accuracy_score(y, pred2) to compute the prediction accuracy. Then the true accuracy is around 0.83, not the claimed 0.92.
Share this highlighthttp://www.safaribooksonline.com/a/python-real-world/5746096/