- Machine Learning with Swift
- Alexander Sosnovshchenko
- 250字
- 2021-06-24 18:54:59
K-fold cross-validation
This method was invented and gained popularity in those days when the big date was not yet a problem, everyone had little data, but still needed to build reliable models. First thing we do is shuffle our dataset well, and then divide it randomly into several equal parts, say 10 (this is the k in k-fold). We hold out the first part as a test set, and on the remaining nine parts we train the model. The trained model is then assessed on the test set that did not participate in the training as usual. Next, we hold out the second of 10 parts, and train the model on the remaining nine (including those previously served as a test set). We validate the new model again on the part that did not participate in the training. We continue this process until each of the 10 parts is in the role of the test set. The final quality metrics are determined by the averaging metrics from each of the 10 tests:
In []: from sklearn.model_selection import cross_val_score scores = cross_val_score(tree_model, features, df.label, cv=10) np.mean(scores) Out[]: 0.88300000000000001 In []: plot = plt.bar(range(1,11), scores) Out[]:

From the preceding graph, you can see that the model's accuracy depends on how you split the data, but not much. By taking the average and variance of the cross-validation results, you can make a sense of how well your model can generalize on different data, and how stable it is.
- Learning SQL Server Reporting Services 2012
- Windows phone 7.5 application development with F#
- 網絡服務器配置與管理(第3版)
- Intel FPGA/CPLD設計(高級篇)
- 計算機應用與維護基礎教程
- 數字邏輯(第3版)
- 微服務分布式架構基礎與實戰:基于Spring Boot + Spring Cloud
- 固態存儲:原理、架構與數據安全
- 電腦高級維修及故障排除實戰
- OpenGL Game Development By Example
- 計算機組裝維修與外設配置(高等職業院校教改示范教材·計算機系列)
- 筆記本電腦應用技巧
- Hands-On Artificial Intelligence for Banking
- 單片機技術及應用
- Blender Game Engine:Beginner's Guide