- Machine Learning for OpenCV
- Michael Beyeler
- 101字
- 2025-04-04 18:50:48
Testing the classifier
Let's see for ourselves by calculating the accuracy score on the training set:
In [19]: ret, y_pred = lr.predict(X_train)
In [20]: metrics.accuracy_score(y_train, y_pred)
Out[20]: 1.0
Perfect score! However, this only means that the model was able to perfectly memorize the training dataset. This does not mean that the model would be able to classify a new, unseen data point. For this, we need to check the test dataset:
In [21]: ret, y_pred = lr.predict(X_test)
... metrics.accuracy_score(y_test, y_pred)
Out[21]: 1.0
Luckily, we get another perfect score! Now we can be sure that the model we built is truly awesome.