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

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.

主站蜘蛛池模板: 靖边县| 涞源县| 巴中市| 喜德县| 海丰县| 广元市| 开封县| 乡宁县| 麻阳| 八宿县| 武宣县| 广河县| 大邑县| 泰和县| 渭南市| 政和县| 阜康市| 平和县| 通化市| 呼图壁县| 谷城县| 长治市| 麟游县| 无为县| 龙陵县| 达尔| 江油市| 尼勒克县| 大田县| 临泉县| 永康市| 江北区| 武山县| 中西区| 绍兴市| 孟津县| 沂源县| 分宜县| 固镇县| 宁陵县| 榆树市|