- Machine Learning Quick Reference
- Rahul Kumar
- 55字
- 2021-08-20 10:05:07
Model selection using cross-validation
We can make use of cross-validation to find out which model is performing better by using the following code:
knn = KNeighborsClassifier(n_neighbors=20)
print(cross_val_score(knn, X, y, cv=10, scoring='accuracy').mean())
The 10-fold cross-validation is as follows:
# 10-fold cross-validation with logistic regression
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression()
print(cross_val_score(logreg, X, y, cv=10, scoring='accuracy').mean())
推薦閱讀
- 亮劍.NET:.NET深入體驗與實戰精要
- 大數據項目管理:從規劃到實現
- Hands-On Machine Learning on Google Cloud Platform
- 商戰數據挖掘:你需要了解的數據科學與分析思維
- Cloud Analytics with Microsoft Azure
- Hands-On Cloud Solutions with Azure
- 計算機網絡技術實訓
- 塊數據5.0:數據社會學的理論與方法
- 工業控制系統測試與評價技術
- 項目管理成功利器Project 2007全程解析
- 悟透AutoCAD 2009完全自學手冊
- 面向對象程序設計綜合實踐
- 中國戰略性新興產業研究與發展·增材制造
- 在實戰中成長:C++開發之路
- 電腦上網入門