【发布时间】:2019-12-21 15:22:49
【问题描述】:
我使用函数 train_test_split() 对训练数据和测试数据进行了拆分,得到以下结果。
print(X_train)
+--------------------+
| fre loc |
+--------------------+
| 1.208531 0.010000 |
| 0.169742 0.010000 |
| 0.119691 0.010000 |
| 0.151515 0.010000 |
| 0.632653 0.010000 |
| 0.104000 1.125000 |
| 3.313433 1.076923 |
| 0.323899 0.010000 |
| 3.513011 1.100000 |
| 0.184971 0.010000 |
| 0.158470 0.010000 |
| 0.175258 0.010000 |
| 0.149038 0.010000 |
| 0.158879 0.010000 |
+--------------------+
print(X_test)
+--------------------+
| fre loc |
+--------------------+
| 1.208531 0.010000 |
| 0.169742 0.010000 |
| 0.119691 0.010000 |
| 0.151515 0.010000 |
| 0.632653 0.010000 |
| 0.104000 1.125000 |
| 3.313433 1.076923 |
+--------------------+
print(y_train)
+----------------+
| Critical Value |
+----------------+
| 1.208531 |
| 0.000000 |
| 0.000000 |
| 0.000000 |
| 0.632653 |
| 1.125000 |
| 4.390356 |
| 0.000000 |
| 4.613011 |
| 0.000000 |
| 0.000000 |
| 0.000000 |
| 0.000000 |
| 0.000000 |
+----------------+
print(y_test)
+----------------+
| Critical Value |
+----------------+
| 1.208531 |
| 0.000000 |
| 0.000000 |
| 0.000000 |
| 0.632653 |
| 1.125000 |
| 4.390356 |
+----------------+
然后我按以下方式执行 Gradient Boosting Regressor,
est_knc= GradientBoostingRegressor()
est_knc.fit(X_train, y_train)
pred = est_knc.score(X_test, y_test)
print(pred)
并得到输出,
0.8879530974429752
到这里还好。现在我想绘制它,但它让我很困惑,我无法理解为了使用上述数据绘制散点图,我必须传递什么以及如何传递参数。我是可视化的新手。 :(
【问题讨论】:
标签: python-3.x pandas dataframe matplotlib plot