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

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.

主站蜘蛛池模板: 峨眉山市| 油尖旺区| 揭阳市| 广昌县| 青岛市| 石台县| 尚义县| 彰化县| 高台县| 犍为县| 泗水县| 卓资县| 城固县| 泗洪县| 汾阳市| 牟定县| 渑池县| 舒兰市| 张家界市| 东辽县| 江门市| 五家渠市| 临沂市| 宁津县| 色达县| 嫩江县| 泽州县| 滁州市| 凤阳县| 莒南县| 恩施市| 南川市| 马龙县| 宜兰县| 尼木县| 佛冈县| 秦皇岛市| 雷波县| 宜宾市| 石阡县| 绵阳市|