- 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())
推薦閱讀
- Clojure Data Analysis Cookbook
- 高效能辦公必修課:Word圖文處理
- 零起步輕松學(xué)單片機(jī)技術(shù)(第2版)
- 基于C語(yǔ)言的程序設(shè)計(jì)
- 大數(shù)據(jù)項(xiàng)目管理:從規(guī)劃到實(shí)現(xiàn)
- 大數(shù)據(jù)戰(zhàn)爭(zhēng):人工智能時(shí)代不能不說(shuō)的事
- Seven NoSQL Databases in a Week
- R Machine Learning By Example
- AWS:Security Best Practices on AWS
- 現(xiàn)代機(jī)械運(yùn)動(dòng)控制技術(shù)
- 控制系統(tǒng)計(jì)算機(jī)仿真
- Troubleshooting OpenVPN
- 氣動(dòng)系統(tǒng)裝調(diào)與PLC控制
- DevOps Bootcamp
- Microsoft System Center Confi guration Manager