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

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.

主站蜘蛛池模板: 大庆市| 息烽县| 靖江市| 泸溪县| 乌什县| 静宁县| 新营市| 八宿县| 昆明市| 漯河市| 怀远县| 满城县| 西乡县| 原阳县| 鄂伦春自治旗| 嘉禾县| 丽水市| 阿克苏市| 石门县| 秦皇岛市| 陆良县| 清苑县| 永安市| 久治县| 垫江县| 河曲县| 梧州市| 芮城县| 山东省| 安阳县| 昭通市| 麟游县| 彩票| 进贤县| 大姚县| 淮安市| 上思县| 仙桃市| 大竹县| 承德县| 宁强县|