September 2019
Intermediate to advanced
420 pages
10h 29m
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 as we did earlier, OpenCV would complain that the data matrix is not a NumPy array. ...
Read now
Unlock full access