- Machine Learning for OpenCV
- Michael Beyeler
- 113字
- 2021-07-02 19:47:25
Splitting the data into training and test sets
We learned in the previous chapter that it is essential to keep training and test data separate. We can easily split the data using one of scikit-learn's many helper functions:
In [11]: X_train, X_test, y_train, y_test = model_selection.train_test_split(
... data, target, test_size=0.1, random_state=42
... )
Here we want to split the data into 90 percent training data and 10 percent test data, which we specify with test_size=0.1. By inspecting the return arguments, we note that we ended up with exactly 90 training data points and 10 test data points:
In [12]: X_train.shape, y_train.shape
Out[12]: ((90, 4), (90,))
In [13]: X_test.shape, y_test.shape
Out[13]: ((10, 4), (10,))
推薦閱讀
- Java從入門到精通(第5版)
- iOS編程基礎:Swift、Xcode和Cocoa入門指南
- C語言課程設計
- Mastering Unity 2D Game Development(Second Edition)
- Quantum Computing and Blockchain in Business
- Hands-On Neural Network Programming with C#
- Python數據可視化之美:專業圖表繪制指南(全彩)
- Delphi開發典型模塊大全(修訂版)
- AMP:Building Accelerated Mobile Pages
- SSH框架企業級應用實戰
- 面向對象程序設計及C++(第3版)
- Qt 5.12實戰
- Mastering React Test:Driven Development
- iOS應用逆向工程:分析與實戰
- VB語言程序設計教程(第2版)