python 如何绘制预测值与真实值

bttbmeg0  于 2023-02-11  发布在  Python
关注(0)|答案(5)|浏览(489)

我刚开始使用matplotlib进行可视化,我想绘制一张机器学习模型的预测值与实际值的图。
我做了一个预测使用随机森林算法,并希望可视化的真实值和预测值的绘图。
我使用了下面的代码,但是图没有清楚地显示预测值和实际值之间的关系。

plt.scatter(y_test1, y_pred_test_Forestreg)
 plt.xlabel('True Values ')
 plt.ylabel('Predictions ')
 plt.axis('equal')
 plt.axis('square')
 plt.xlim([0, plt.xlim()])
 plt.ylim([0, plt.ylim()])
 _ = plt.plot([-100, 100], [-100, 100])

这是我得到的:

这是我所期望的情节:

下面是我想要绘制的数据表。(注:这只是结果的一部分,因为它是不可能包括完整的数据(形状8221,1)在这里。我期待着你的帮助。

True_value  Predicted_value
19.624  15.144
4.685   4.815
2.924   3.038
3.113   3.784
10.512  10.400
9.176   9.066
6.375   5.983
4.412   4.232
8.273   7.917
3.166   3.251
68.971  107.703
181.666 237.296
7.701   8.048
2.447   6.054
131.302 207.189
13.768  13.457
11.623  13.137
8.528   8.807
15.098  17.706
56.473  54.183
59.310  167.495
3.348   3.328
32.844  34.156
578.226 505.921
1.448   1.446
10.062  9.766
7.570   7.265
8.616   8.672
3.674   3.644
3.288   2.931
3.540   3.562
4.560   5.061
5.887   5.541
1.665   1.688
1.871   1.904
1.410   1.439
9.912   403.442
2.935   2.997
12.787  12.957
3.457   3.596
11.299  11.967
8.130   8.460
8.865   11.949
7.540   7.515
60.140  84.870
16.552  17.161
10.865  11.791
6.067   6.578
11.295  16.454
75.891  185.727
10.326  11.284
34.206  107.315
22.264  22.015
3.950   4.260
28.428  27.939
12.290  12.022
5.473   9.635
6.745   7.254
634.100 673.322
15.266  16.482
15.521  43.444
18.474  17.949
3.755   3.572
46.217  69.086
16.910  14.501
2.680   2.753
274.212 316.699
8.235   8.440
6.427   6.307
6.089   5.979
28.649  29.809
4.168   4.382
2.547   2.708
4.315   4.311
7.585   7.409
6.233   6.248
34.533  31.312
10.258  10.079
8.695   9.437
4.033   12.747
4.125   4.098
525.944 219.438
2.579   2.611
523.896 282.774
8.701   8.535
7.240   7.155
176.189 200.219
3.428   3.463
2.585   2.813
27.354  34.487
3.001   3.338
38.852  82.933
12.774  16.158
16.984  17.053
11.137  11.219
4.082   4.084
3.328   3.262
274.311 209.084
6.897   7.223
62.672  114.585
43.145  72.709
2.984   3.033
9.826   10.398
3.516   3.742
7.338   7.184
7.378   7.162
9.957   9.932
6.911   22.346
7.950   10.278
5.116   4.820
7.892   8.124
14.289  18.204
6.993   6.660
19.128  20.634
3.115   3.211
3.542   4.578
21.191  115.314
8.054   8.121
4.050   3.860
9.886   11.048
4.155   6.156
11.709  11.088
8.132   8.471
3.890   3.949
4.378   4.437
6.988   10.504
14.657  25.161
24.183  34.785
10.967  798.643
3.996   4.247
3.198   3.327
156.253 351.941
5.146   5.262
11.318  11.291
16.291  16.949
158.091 203.395
22.975  21.835
5.912   6.467
12.273  12.490
3.539   3.542
16.078  16.097
51.275  80.729
3.488   4.741
2.925   3.088
3.778   3.881
6.571   6.429
2.901   2.811
1.601   2.957
3.696   3.577
31.660  32.617
7.704   8.171
20.296  22.126
4.045   4.334
134.317 190.880
2.555   2.852
5.464   7.617
12.790  12.009
4.284   4.556
6.270   6.779
1.671   1.670
226.813 91.195
72.333  71.087
3.791   3.813
7.525   8.456
2.172   2.399
2.959   2.909
30.524  69.432
2.827   2.830
3.085   3.134
2.872   2.932
3.742   3.929
3.649   3.566
5.980   15.945
2.526   2.584
1.368   1.437
3.601   3.655
10.210  9.142
12.890  13.373
10.297  18.741
4.448   4.461
2.445   2.441
7821.052    209.961
5.288   5.424
6.344   7.370
4.965   4.934
2.613   2.645
3.185   3.252
124.729 167.799
2.405   2.563
30.347  116.190
3.292   3.305
665.125 973.483
4.164   4.251
6.322   6.311
11.213  407.169
95.240  343.970
5.783   5.994
5.373   5.870
19.684  21.314
17.965  25.495
30.212  30.220
61.062  63.275
3.549   3.490
5.964   5.915
21.034  25.812
47.966  47.694
14.440  13.870
5.449   6.194
5.259   5.309
6.598   6.491
104.152 133.026
10.739  10.297
11.346  11.375
17.738  16.433
5.873   5.891
3.844   3.874
3.964   3.939
21.967  22.237
2.246   2.198
17.728  14.837
3.784   3.879
22.299  26.496
644.469 675.529
17.276  18.275
5.231   5.172
18.520  32.575
7.318   7.207
3.755   3.952
283.689 237.367
35.856  38.537
573.022 587.498
28.416  66.907
7.308   7.136
4.968   5.126
10.330  11.180
1.610   1.738
16.856  17.902
42.227  43.223
2.051   2.041
7.593   9.966
7.569   8.319
5.441   5.746
5.972   6.653
3.717   3.599
8.827   9.307
7.706   8.501
3.623   3.295
9.030   13.022
6.355   6.297
7.335   9.017
13.303  12.695
4.113   4.121
3.723   3.737
111.807 898.529
2.851   2.891
11.799  13.946
2394.623    1824.993
4.082   4.092
3.056   3.046
2.624   2.730
3.470   3.984
4.257   5.701
2.896   3.084
2.443   2.478
2.870   2.964
3.321   2.960
2.828   2.932
3.141   3.127
12.469  12.952
16.836  16.809
9.443   9.719
2.554   2.638
5.645   5.492
5.714   5.886
4.343   4.475
14.376  15.382
10.272  27.267
5.985   5.618
4.007   3.866
4.131   4.157
2.406   2.544
6.889   7.021
7.578   7.749
3.672   3.600
906.078 216.823
2.902   3.025
9.181   9.414
8.592   8.066
6.513   18.057
271.303 228.073
5.702   5.848
5.085   5.392
2.616   2.593
3.754   3.874
30.282  35.751
21.143  25.404
14.135  15.484
36.088  40.671
3.123   3.576
4.275   4.755
6.851   6.882
2.818   2.761
2.159   2.164
9.910   9.536
3.049   3.067
4.427   5.804
6.712   6.458
4.494   4.221
3.068   3.197
5.406   5.613
3.227   3.241
24.215  53.796
637.213 286.607
5.956   6.193
1.471   1.628
55.357  40.091
210.939 179.626
10.495  30.618
4.570   4.749
543.716 600.721
149.483 303.777
6.426   8.019
3.584   4.201
5.645   5.716
345.349 248.498
6.279   5.735
3.202   3.244
203.829 195.321
10.781  12.432
4.101   3.965
8.068   8.434
2.857   3.038
3.087   3.080
12.415  12.642
4.565   4.695
549.052 613.451
18.186  23.562
16.835  18.274
4.791   6.422
71.954  70.883
4.768   4.833
3.521   3.604
19.906  17.715
16.679  39.652
130.312 104.834
6.184   6.200
140.157 143.435
3.544   3.559
57.671  98.001
17.373  20.190
7.149   7.182
11.680  11.834
21.702  21.113
22.296  21.578
13.011  13.667
10.163  10.251
4.846   4.961
3.140   3.136
13.378  23.330
2.997   3.053
5.985   5.649
13.253  14.494
11.334  13.650
28.669  28.714
10.286  10.428
9.503   9.448
4.742   4.682
2.221   2.284
3.861   3.902
240.606 291.496
15.891  18.820
8.417   9.890
5.489   5.405
6.948   6.772
5.827   5.797
2.000   2.097
5.365   5.523
21.660  42.945
14.776  14.856
11.559  11.872
113.205 68.657
27.932  58.427
3461.739    1284.346
4.265   4.264
4.679   4.776
4.158   4.167
5.433   5.745
4.630   4.672
3.234   3.273
2.979   3.008
2.973   3.000
65.804  192.535
9.779   9.668
4.859   5.321
25.096  25.863
31.760  32.688
45.694  88.227
9.456   9.014
3.848   3.757
3.219   3.663
3.437   3.555
3.145   3.880
4.071   4.734
9.924   10.470
1.803   2.191
8.169   9.736
2.865   2.903
9.904   56.968
4.630   5.931
9.509   12.341
3.601   3.610
20.892  29.847
12.044  12.784
4.555   4.787
5.870   11.672
6.595   7.227
6.838   6.873
4.685   4.716
5.192   6.754
9.431   16.747
2.668   2.737
13.617  14.081
2.232   2.274
7.903   8.343
2.499   2.615
34.243  48.755
4.698   4.900
3.748   3.432
37.223  66.586
68.727  361.602
25.718  36.754
18.440  18.247
15.377  15.465
3.886   3.931
2.643   2.600
9.831   9.503
39.471  40.691
3.029   3.156
7.123   6.307
9.489   9.209
3.149   3.287
7.776   7.646
3.390   3.544
10.181  14.724
8.250   8.084
193.590 261.347
9.793   12.250
70.579  69.578
7.832   7.399
5.046   5.176
3.968   4.005
9.784   12.865
7.610   7.236
4996.689    2691.915
313.615 422.989
6.895   7.304
3.470   3.484
11.665  18.933
3.292   3.317
1.783   1.947
3.219   3.111
3.985   3.964
3.498   3.610
36.447  36.004
8.682   9.461
5.307   5.283
70.309  68.247
3.070   3.118
24.358  22.845
11.658  16.996
4.120   4.151
4.298   4.632
14.703  27.946
3.584   3.608
821.402 464.270
5.953   6.212
128.394 98.013
19.772  20.482
52.685  56.871
15.331  47.899
3.063   3.138
27.708  29.416
5.710   5.702
5.179   5.176
6.794   7.548
5.535   5.903
7.756   7.542
13.773  15.158
42.209  47.055
9.589   9.636
4.101   4.053
11.070  10.378
9.900   10.381
23.599  27.321
6.342   7.113
237.329 265.999
4.236   4.156
3.725   3.765
3.288   3.761
12.502  13.748
22.315  23.830
460.784 499.877
37.721  59.371
3.329   3.455
2.656   2.734
7.192   13.859
3.141   3.169
16.235  17.393
9.122   11.052
4.592   5.448
4.822   4.917
3.775   3.841
23.833  30.813
3.330   3.408
32.084  43.318
2.922   2.642
9.614   9.788
19.096  19.256
3.442   3.273
4.007   4.938
30.032  30.929
4.988   5.175
3.160   3.197
3.550   3.606
10.242  10.115
3.102   3.137
5.496   5.485
78.592  170.062
20.358  21.758
3.878   4.560
7.540   7.334
3.525   3.586
41.475  42.571
2.526   2.551
284.630 211.248
2.610   2.621
15.534  17.391
20.425  33.944
4.757   4.765
3.913   4.076
3.830   3.574
10.342  9.655
10.169  10.913
30.062  50.935
3.767   3.821
10.695  13.182
3.992   3.987
12.472  12.897
7.534   7.612
5.622   5.747
3.971   3.960
3.435   3.686
1326.840    1219.852
46107.740   316.479
3.811   3.797
2.531   2.616
6.154   5.978
45.078  70.688
36.858  35.887
13.847  14.226
21.346  32.181
16.678  18.144
15.503  15.724
2.691   2.736
27.847  36.464
6.376   6.316
14.914  15.570
9.088   11.115
12.111  13.716
55.573  47.872
16.263  17.161
3.524   3.513
7.709   8.567
5.546   5.526
2.949   2.814
5.711   5.824
1.900   1.992
4.627   4.638
7.726   8.888
1.879   2.139
8.284   8.346
45.501  46.389
9.511   9.486
6.682   7.590
7.960   16.404
2.684   2.647
4.696   4.752
5.750   5.675
15.713  15.559
3.617   3.625
44.469  45.952
20.249  20.487
5.670   6.105
107.327 262.087
8.889   8.471
13.256  13.335
126.793 136.720
137.222 168.966
3.026   3.041
8.653   9.073
3.465   4.198
25.399  44.397
16.268  68.009
7.730   7.676
26.813  63.690
5.427   6.090
3.672   3.716
26.927  32.404
2.879   2.922
488.947 187.509
13.759  17.262
17.620  18.346
3.768   4.381
2.410   2.652
38.413  83.543
3.581   3.688
9.117   8.473
49.507  44.383
12.744  9.823
23.463  15.088
152.177 156.684
35.534  74.871
15.581  12.622
3.262   3.295
3.054   3.089
9.100   11.311
9.668   10.491
2.909   2.924
3.783   3.696
10.671  13.134
5.098   5.271
14.355  131.551
4.601   4.558
73.732  522.207
15.599  16.085
99.343  171.043
9.426   10.030
16.628  18.044
11.698  11.487
3.561   3.583
5.189   5.167
4.687   4.769
12.656  12.308
3.325   3.444
3.948   4.025
60.056  152.943
14.180  16.198
9.861   9.616
63.960  69.110
4.679   4.675
16.040  16.687
7.904   7.643
6.450   6.727
3.803   4.413
2.553   2.739
40.290  97.088
2.708   2.835
425.787 314.400
2.439   2.477
2.785   2.805
3.270   3.284
2.647   2.710
5.165   5.211
48.268  40.837
3.257   3.247
214.791 332.489
5.842   6.338
17.314  17.595
7.217   7.600
11.369  10.983
4.525   12.805
9.691   35.084
7.733   8.054
47.099  44.539
4.428   4.658
3.050   3.160
21.687  21.427
3.499   3.571
4.851   4.774
2.977   3.060
2.545   2.566
3.662   4.037
22.456  22.634
2.181   2.239
326.994 374.272
55.825  55.422
2.393   2.478
4.400   6.259
3.782   3.799
2.809   2.804
9.876   13.799
2.576   2.653
16.874  16.959
21.571  23.953
15.590  17.355
42.106  51.814
10.481  10.497
2.916   2.968
3.334   3.302
2.954   3.059
1.696   1.735
5.395   6.021
5.418   5.255
42.656  49.237
5.596   5.675
3.480   3.554
17.537  21.359
3.228   3.383
58.281  179.127
25.906  63.865
21.146  25.153
4.658   4.720
3.850   3.888
9.028   15.569
4.629   4.711
3.091   3.171
24.311  41.592
2.652   2.698
14.238  14.362
12.500  12.204
3.574   3.627
321.192 6054.332
4.070   4.263
13.435  13.500
2.249   2.341
10.612  10.822
3.224   3.409
27.689  27.566
3.954   4.244
20.670  22.052
6.427   6.765
3.392   3.515
2.920   3.359
14.821  15.202
2.611   2.794
6.555   7.040
9.217   12.450
5.632   5.729
6.226   5.949
4.872   6.035
3.619   4.020
8.413   9.601
1.448   1.504
7.171   7.861
3.952   3.864
3.377   3.390
11.497  12.984
8.768   7.989
11.831  12.099
3.136   3.121
9.831   12.960
9.540   9.640
10.653  11.002
4.646   5.055
18.888  14.569
3.136   3.150
185.894 281.490
30.000  33.611
3.099   3.383
14528.128   194.832
3.533   3.551
60.248  72.399
16.598  15.403
5.506   6.254
2.885   2.785
10.409  10.430
6.957   6.359
10.874  17.594
5.967   6.343
105.277 135.997
173.652 857.814
2.381   3.225
9.035   9.054
2.968   3.385
10.200  10.618
5.132   5.480
462.597 203.613
3.955   4.076
18.293  26.279
3.258   3.353
3.629   3.519
3.624   3.667
4.140   17.326
3.448   3.726
176.988 72.779
21.992  33.420
1.912   1.915
20.365  21.570
2.801   3.024
7.667   9.698
73.205  68.196
11.238  11.440
12.600  12.502
2.826   2.911
13.567  13.484
5.286   5.429
2.749   2.858
7.208   7.190
8.269   8.003
162.883 215.015
4.572   4.541
59.605  95.131
143.216 199.214
11.269  12.128
11.469  14.168
34.084  31.335
6.867   15.177
4.481   4.457
7.499   6.741
4.513   4.767
3.141   3.254
3.221   3.214
2.948   2.875
5.513   5.298
7.164   8.900
13.643  13.920
13.516  15.751
228.455 264.090
18.596  25.985
2.572   2.641
3.588   3.526
184.955 296.952
5.161   5.870
5.834   8.090
3.114   3.125
4.721   4.766
7.596   7.547
17.221  15.741
6.401   6.706
5.301   5.285
5.072   5.416
3.559   7.562
4.951   5.511
13.149  45.857
17.839  20.007
25.825  27.040
2.947   3.143
2.954   2.977
19.163  36.026
6.853   46.787
1234.533    895.424
9.103   9.127
6.063   5.949
4.596   4.656
20.167  36.586
132.208 129.966
64.140  93.127
12.166  11.759
4.699   5.181
4.833   5.464
7.117   36.724
42.634  65.560
4.988   5.685
3.252   3.175
14.238  15.520
5.948   6.027
3.099   3.123
4.190   4.883
40.309  42.843
3.063   3.196
5.789   5.911
2.668   2.714
27.305  24.457
13.130  14.262
5.462   5.335
230.848 297.006
2.131   2.182
2.918   2.999
4.971   5.090
3.121   3.378
2.103   2.115
17.212  16.520
2.063   2.076
17.047  17.497
29.930  48.084
2.474   2.593
19.437  15.786
4.036   4.011
6.311   7.566
32.844  39.152
4.086   4.163
4.841   5.930
216.971 90.661
3.811   4.976
2.958   3.018
10.057  10.921
3.111   3.126
2.402   2.468
103.789 160.448
38.330  41.226
12.148  13.005
3.876   3.643
4.960   4.957
19.842  19.848
16.860  18.693
19.083  25.635
16.207  20.152
10.292  11.449
18.104  19.176
3.244   3.268
6.349   6.967
9.476   9.581
24.041  23.769
3.753   4.275
10.291  13.313
7.082   7.471
9.135   9.262
88.004  113.825
5.438   5.238
427.816 326.175
39.240  72.889
2.434   2.467
2.626   2.742
4.965   5.306
23.282  20.708
2.487   2.595
122.099 118.899
3.201   3.152
8.655   8.895
9.244   9.042
3.264   3.455
21.233  31.791
7.346   9.535
10.145  12.891
3.188   3.207
81.958  75.353
14.312  14.969
111.029 144.639
9.118   10.859
275.693 149.173
4.416   4.747
3.075   3.085
4.944   4.785
3.749   3.844
10.440  15.537
35.442  34.194
1903.978    246.478
7.105   7.157
28.782  42.077
141.881 265.094
4.897   9.252
29.811  39.802
2.399   2.546
15.536  15.934
2.323   2.485
15.379  20.478
8.901   10.844
2.494   2.526
2.943   3.579
3.808   3.828
5.006   5.371
46.338  58.896
6.285   6.131
7.067   7.692
10.146  9.935
18.963  18.006
3.821   3.849
3.374   3.089
4.176   4.267
1.867   1.962
3.029   2.933
10.424  11.745
7.899   14.366
41.736  43.484
203.775 242.494
20.162  38.360
6.337   6.425
4.034   6.067
4.241   4.346
8.871   9.049
2.915   2.928
3.382   3.415
1.808   1.915
2.835   2.913
7.117   7.156
2.290   2.399
8.650   9.025
3.798   3.821
3.474   3.482
2.639   2.792
3.687   3.756
13.404  13.450
6.119   6.688
12.387  16.997
45.936  55.680
11.247  11.161
4.274   4.423
7.325   10.756
29.293  27.371
9.515   19.688
7.857   7.680
5.348   22.322
163.558 178.067
24.362  20.704
20.334  19.389
3.535   3.546
7.405   7.502
30.687  28.936
12.820  13.067
16.036  15.349
4.525   4.644
7.361   7.496
10.054  11.879
7.697   9.671
11.423  11.470
2.973   3.038
1314.315    323.847
112.133 160.072
16.433  23.824
4.906   5.328
7.876   8.760
10.229  9.743
2.814   2.821
257.298 249.414
2.467   2.913
5.176   5.347
5.191   9.566
6.346   6.879
9.219   8.968
8.048   8.219
3.832   3.834
4.459   4.636
25.413  39.491
4.700   4.472
347.022 287.293
1.345   1.381
2.813   2.908
9.625   9.323
3.809   3.995
7.431   22.802
3.661   3.820
5.383   9.702
3.712   3.785
4.763   4.771
8.235   8.958
19.655  23.900
15.520  13.607
7.013   6.968
14.973  15.679
2.384   2.420
4.971   5.077
6.074   6.479
10.907  14.398
10.633  10.592
100.205 272.179
5.507   8.602
3.933   5.477
6.311   6.562
3.729   4.175
19.241  19.845
4.872   4.800
9.470   9.167
13.976  18.381
2.110   2.134
4.407   6.087
12.468  34.135
45.424  50.214
2.512   5.133
22.283  23.099
6.261   6.630
15.590  21.447
23.178  35.645
39.043  36.060
2.670   2.843
19.230  30.284
3.077   3.088
3.273   3.360
3.264   3.304
44.335  210.250
82.392  74.348
3.973   4.747
30.960  70.890
6.265   6.221
7.608   8.167
5.943   797.595
6.186   9.305
10.559  10.650
10.691  11.225
7.879   7.851
21.246  25.182
3.607   3.576
6.703   7.297
106.397 110.987
7.925   15.494
19.990  29.775
7.284   8.833
156.078 174.563
38.052  39.191
5.875   6.148
94.980  570.359
2.569   2.566
2.688   2.770
3.080   3.076
34.402  35.595
3.145   3.269
303.919 241.618
2.988   3.362
2.344   2.479
4.419   4.500
16.500  16.542
3.214   3.219
6.524   6.263
15.548  14.508
49.636  112.217
81.555  95.624
38.713  39.742
35.177  35.511
6.376   6.757
12.303  13.147
15.831  15.487
8.664   8.499
13.038  14.052
76.699  79.075
6.567   6.763
30.068  30.138
4.166   4.190
11.244  11.023
10.033  15.945
8.026   8.410
20.400  24.974
25.895  56.055
5.347   5.551
2.639   2.639
4.799   4.557
10.292  11.111
466.511 201.463
5.570   6.146
3.581   3.887
114.262 240.503
2.394   2.408
14.285  14.559
5.548   6.802
94.413  54.871
5.914   5.657
2.996   2.985
12.743  17.174
64.850  343.782
6.416   6.853
30.839  30.897
6.602   6.345
183.528 206.723
9.141   10.174
3.501   3.512
27.424  87.668
4.738   4.886
2.816   2.760
17.365  30.646
4.007   4.085
7.485   8.774
7.654   7.444
11.835  14.526
294.052 270.140
3.662   3.713
115.129 208.145
4.381   4.253
3.638   4.308
2.752   3.336
3.500   4.949
3.442   3.406
5.175   5.302
5.695   6.043
3.417   3.384
5.643   6.373
7.287   6.973
4.445   5.089
225.768 189.505
3.695   3.759
2.665   2.820
16.550  16.458
17.384  16.734
26.914  31.025
3.397   3.361
3.006   3.054
2.089   2.122
34.676  35.022
10.833  11.133
1049.306    350.535
15.384  28.722
19.489  18.079
775.681 731.995
4.548   5.418
6.270   6.606
68.405  66.981
3.851   4.227
21.010  75.327
26.540  30.676
13.190  13.393
29.683  31.399
86.971  227.074
7.432   7.444
12.055  15.133
99.511  74.751
7.418   8.342
28.807  24.266
52.762  52.212
3.951   4.839
4.244   4.105
3.908   3.852
3.580   3.579
28.467  68.300
11.045  11.432
2.776   2.826
4.181   3.967
7.051   7.164
4.962   4.696
5.242   5.742
2.662   2.931
2.666   2.678
10.889  10.831
2.493   2.534
15.825  18.569
4.334   4.414
16.147  35.420
270.914 298.895
18.300  17.052
5.218   5.480
2.892   2.928
5.884   5.699
4.923   5.001
4.180   4.316
14.932  14.942
41.254  75.577
2.507   2.601
3.261   3.285
3.323   6.875
3.284   3.267
27.438  32.004
19.371  20.212
3.170   3.193
5.018   5.555
42.568  36.890
25.968  30.364
9.335   9.489
272.611 255.764
13.364  13.961
5.729   5.642
12.335  19.017
38.416  207.078
3.702   3.696
48.208  76.352
6.136   7.892
3.452   3.803
3.975   3.951
17.466  19.923
11.703  11.391
82.279  120.894
3.020   3.018
45.694  67.196
3.047   3.248
5.188   5.270
32.589  46.707
3.283   3.296
3.532   3.867
24.104  52.124
11.111  42.011
2.617   2.647
9.136   9.944
3.258   3.267
9.458   24.309
8.300   8.317
16.536  34.283
17.828  18.889
5.224   5.479
20.401  1346.159
18.276  17.085
4.969   5.033
11.977  11.986
10.110  10.653
31.651  31.643
11.656  11.726
ocebsuys

ocebsuys1#

这是我试图理解你的问题,并得到你真正想要的东西,所以假设我们手边有true_value和predicted_value,我会把它们画成这样:

plt.figure(figsize=(10,10))
plt.scatter(true_value, predicted_value, c='crimson')
plt.yscale('log')
plt.xscale('log')

p1 = max(max(predicted_value), max(true_value))
p2 = min(min(predicted_value), min(true_value))
plt.plot([p1, p2], [p1, p2], 'b-')
plt.xlabel('True Values', fontsize=15)
plt.ylabel('Predictions', fontsize=15)
plt.axis('equal')
plt.show()

结果是:

你是否正在寻找这样的东西,是的,我使用对数轴,因为你的值的尺度不同。
希望这是你想要的。

    • PS. -**我真的不确定提供的图表中的点的颜色是什么,或者那些带是什么,但我仍然可以思考这些带的意思,并创建类似的东西,但不确定标记颜色。所以如果你能提供链接到你从哪里得到的图表,我想我可能能够理解到底是什么正在做的图表。
iqjalb3h

iqjalb3h2#

问题是您的值范围从0到60.000。我建议您选择两个选项:您可以将两个轴都转换为对数刻度

g=plt.scatter(y_test1, y_pred_test_Forestreg)
g.axes.set_yscale('log')
g.axes.set_xscale('log')
g.axes.set_xlabel('True Values ')
g.axes.set_ylabel('Predictions ')
g.axes.axis('equal')
g.axes.axis('square')

或者,更好的是,绘制真实值和预测值之间的差异(即预测误差)。

g=plt.plot(y_test1 - y_pred_test_Forestreg,marker='o',linestyle='')
eyh26e7m

eyh26e7m3#

我建议重新调整你的值,因为值太分散了。虽然你的大多数条目小于50,但规模高达60000。一旦你重新调整了你的条目,让我们说0 - 1规模,然后它应该看起来更好。我会使用某种规模。

q3qa4bjr

q3qa4bjr4#

实际上,你可以从这个散点图中获取第一个基本信息:这个模型在极高的输入值上有真实的差的预测。这里的Rmse会很高,你已经可以总结出这个模型很差(如果这些高输入值和低输入值一样重要的话)。如果你不关心高输入值,那么你可以简单地在一个更小的域中查看这个图,改变你的xylim
用相同的因子线性地重新缩放它们,只会产生相同的散点图,但带有不同的标签。你可以将它们归一化到它们的最大值,但我不知道你的散点图的可读性会如何。
如果您的目的只是更好地可视化结果,则可以对实际值和预测值应用一些非线性变换(db?gamma校正?)。

ycggw6v2

ycggw6v25#

要绘制预测标签与实际标签的对比图,我将执行以下操作:
1.假设这些是参数的名称
X_features_main #The X Features
y_label_main #The Y Label
y_predicted_from_X_features_main #The predicted Y-label from X-features I used

plt.scatter(x=X_features_main, y=y_label_main,color='black')  #The X-Features vs. The Real Label
plt.plot(X_features_main, y_predicted_from_X_features_main,color='blue') #The X- Features vs. The predicted label
plt.show()#To show your figures code here

相关问题