官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 潮安县| 临清市| 通海县| 罗江县| 大田县| 台江县| 东辽县| 莱州市| 韩城市| 奈曼旗| 海林市| 南宁市| 察雅县| 剑川县| 丹凤县| 中西区| 鄯善县| 特克斯县| 土默特右旗| 万盛区| 新兴县| 绥化市| 鄯善县| 乡城县| 富阳市| 盖州市| 同仁县| 广宁县| 杭州市| 简阳市| 莱西市| 湄潭县| 池州市| 灌阳县| 疏附县| 鲁山县| 称多县| 嘉禾县| 布尔津县| 湘潭市| 油尖旺区|