July 2017
Intermediate to advanced
382 pages
9h 13m
English
From here on out, things are (almost) like they always were. We can use scikit-learn to split the data into training and test sets. (Let's reserve 20% of all data points for testing):
In [13]: 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... )
We can instantiate a new normal Bayes classifier with OpenCV:
In [14]: import cv2... model_norm = cv2.ml.NormalBayesClassifier_create()
However, OpenCV does not know about sparse matrices (at least its Python interface does not). If we were to pass X_train and y_train to the train function like we did earlier, OpenCV would complain that the data matrix is not a NumPy ...
Read now
Unlock full access