July 2017
Intermediate to advanced
382 pages
9h 13m
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:
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, like 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 you ...
Read now
Unlock full access