September 2019
Intermediate to advanced
420 pages
10h 29m
English
The next step is to split the data points into training and test sets, as we have done before. But, before we do that, we have to prepare the data for OpenCV as follows:
We can achieve this with the following code:
In [4]: import numpy as np... X = X.astype(np.float32)... y = y * 2 - 1
Now we can pass the data to scikit-learn's train_test_split function as we did in the earlier chapters:
In [5]: from sklearn import model_selection as ms... X_train, X_test, y_train, y_test = ms.train_test_split(... X, y, test_size=0.2, random_state=42... )
Here, I chose to reserve 20 percent of all data points for the test set, but ...
Read now
Unlock full access