July 2017
Intermediate to advanced
382 pages
9h 13m
English
We can compare the result to a true naïve Bayes classifier by asking scikit-learn for help:
In [13]: from sklearn import naive_bayes... model_naive = naive_bayes.GaussianNB()
As usual, training the classifier is done via the fit method:
In [14]: model_naive.fit(X_train, y_train)Out[14]: GaussianNB(priors=None)
Scoring the classifier is built in:
In [15]: model_naive.score(X_test, y_test)Out[15]: 1.0
Again a perfect score! However, in contrast to OpenCV, this classifier's predict_proba method returns true probability values, because all values are between 0 and 1, and because all rows add up to 1:
In [16]: yprob = model_naive.predict_proba(X_test)... yprob.round(2)Out[16]: array([[ ...
Read now
Unlock full access