- Learning Data Mining with Python(Second Edition)
- Robert Layton
- 97字
- 2021-07-02 23:40:07
Putting it all together
We can now create a workflow by combining the code from the previous sections, using the broken dataset previously calculated:
X_transformed = MinMaxScaler().fit_transform(X_broken)
estimator = KNeighborsClassifier()
transformed_scores = cross_val_score(estimator, X_transformed, y, scoring='accuracy')
print("The average accuracy for is {0:.1f}%".format(np.mean(transformed_scores) * 100))
We now recover our original score of 82.3 percent accuracy. The MinMaxScaler resulted in features of the same scale, meaning that no features overpowered others by simply being bigger values. While the Nearest Neighbor algorithm can be confused with larger features, some algorithms handle scale differences better. In contrast, some are much worse!
推薦閱讀
- ServiceNow Application Development
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- Boost C++ Application Development Cookbook(Second Edition)
- Java Web開發之道
- Mastering C# Concurrency
- Python自然語言處理(微課版)
- Python數據可視化之Matplotlib與Pyecharts實戰
- BIM概論及Revit精講
- HTML5與CSS3基礎教程(第8版)
- Mastering SciPy
- OpenCV 3.0 Computer Vision with Java
- Google Adsense優化實戰
- Visual Basic語言程序設計上機指導與練習(第3版)
- Splunk Essentials
- Java編程指南:語法基礎、面向對象、函數式編程與項目實戰