我正在为一些机械工程问题做一个模型。我有12项投入/特点和19项产出/答复。我有一个数据集,它总共包含100个数据点(我知道它不是很大的数据集)。问题是,我知道这些输入和输出之间的关系不是线性的。然而,当我对我的数据点进行一次线性回归时,我得到了一个非常高的R^2 (R^2=0.95)。而且,我的想法是,随着多项式度的增加,模型的R^2应该改进,但在我的情况下没有发生这种情况。
我的问题是:我的模型真的是线性模型还是做错了什么?非线性模型能很好地适应线性模型吗?不管怎么说,我能很有信心我的模型真的是线性的吗?(2)为什么R^2的值不随多项式度的增加而增加?
scaler = preprocessing.MinMaxScaler()
names = X.columns
d = scaler.fit_transform(X)
scaled_df = pd.DataFrame(d, columns=names)
X_normalized, y_for_normalized = scaled_df[[ "Part's Z-Height (mm)","Part's Weight (N)","Part's Solid Volume (cm^3)","Part's Surface Area (cm^2)","Material's Density (g/cm^3)","Layer Height (mm)","Infill Density (%)","Nozzle/Printing Temperature (C)","Platform Temperature (C)","Printing/Scanning Speed (mm/s)","Part's Orientation (Support's height) (mm)","Part's Orientation (Support's volume) (cm^3)"]], data_set [["Climate change (kg CO2 eq.)","Climate change, incl biogenic carbon (kg CO2 eq.)","Fine Particulate Matter Formation (kg PM2.5 eq.)","Fossil depletion (kg oil eq.)","Freshwater Consumption (m^3)","Freshwater ecotoxicity (kg 1,4-DB eq.)","Freshwater Eutrophication (kg P eq.)","Human toxicity, cancer (kg 1,4-DB eq.)","Human toxicity, non-cancer (kg 1,4-DB eq.)","Ionizing Radiation (Bq. C-60 eq. to air)","Land use (Annual crop eq. yr)","Marine ecotoxicity (kg 1,4-DB eq.)","Marine Eutrophication (kg N eq.)","Metal depletion (kg Cu eq.)","Photochemical Ozone Formation, Ecosystem (kg NOx eq.)","Photochemical Ozone Formation, Human Health (kg NOx eq.)","Stratospheric Ozone Depletion (kg CFC-11 eq.)","Terrestrial Acidification (kg SO2 eq.)","Terrestrial ecotoxicity (kg 1,4-DB eq.)"]]
Normalized_matrix = pd.concat([X_normalized,y_for_normalized],axis=1)
Normalized_matrix
Part's Z-Height (mm) Part's Weight (N) Part's Solid Volume (cm^3) Part's Surface Area (cm^2) Material's Density (g/cm^3) Layer Height (mm) Infill Density (%) Nozzle/Printing Temperature (C) Platform Temperature (C) Printing/Scanning Speed (mm/s) Part's Orientation (Support's height) (mm) Part's Orientation (Support's volume) (cm^3) Climate change (kg CO2 eq.) Climate change, incl biogenic carbon (kg CO2 eq.) Fine Particulate Matter Formation (kg PM2.5 eq.) Fossil depletion (kg oil eq.) Freshwater Consumption (m^3) Freshwater ecotoxicity (kg 1,4-DB eq.) Freshwater Eutrophication (kg P eq.) Human toxicity, cancer (kg 1,4-DB eq.) Human toxicity, non-cancer (kg 1,4-DB eq.) Ionizing Radiation (Bq. C-60 eq. to air) Land use (Annual crop eq. yr) Marine ecotoxicity (kg 1,4-DB eq.) Marine Eutrophication (kg N eq.) Metal depletion (kg Cu eq.) Photochemical Ozone Formation, Ecosystem (kg NOx eq.) Photochemical Ozone Formation, Human Health (kg NOx eq.) Stratospheric Ozone Depletion (kg CFC-11 eq.) Terrestrial Acidification (kg SO2 eq.) Terrestrial ecotoxicity (kg 1,4-DB eq.)
0 0.258287 0.022303 0.005030 0.000000 1.0 0.0 0.00 0.0 0.0 0.666667 0.308259 0.040088 0.0778 0.0426 0.000039 0.0179 0.0933 0.000175 2.910000e-07 0.000892 0.001290 0.000541 0.034000 0.000101 2.750000e-06 0.000412 0.000152 0.000152 8.720000e-08 0.000118 0.00919
1 0.258287 0.022303 0.005030 0.000000 1.0 0.2 0.00 0.0 0.0 0.666667 0.308259 0.036597 0.0620 0.0274 0.000036 0.0171 0.0464 0.000171 2.820000e-07 0.000443 0.001120 0.000520 0.033100 0.000098 2.670000e-06 0.000251 0.000144 0.000143 8.450000e-08 0.000111 0.00665
2 0.258287 0.027728 0.009557 0.000000 1.0 0.4 0.00 0.0 0.0 0.666667 0.131007 0.031013 0.0573 0.0226 0.000035 0.0169 0.0311 0.000172 2.810000e-07 0.000297 0.001070 0.000518 0.033100 0.000098 2.670000e-06 0.000200 0.000142 0.000141 8.440000e-08 0.000109 0.00587
3 0.258287 0.027125 0.009054 0.000000 1.0 0.6 0.00 0.0 0.0 0.666667 0.131007 0.031013 0.0550 0.0203 0.000035 0.0168 0.0239 0.000172 2.800000e-07 0.000228 0.001040 0.000517 0.033000 0.000098 2.670000e-06 0.000175 0.000141 0.000140 8.420000e-08 0.000108 0.00548
4 0.258287 0.028330 0.010060 0.000000 1.0 1.0 0.00 0.0 0.0 0.666667 0.308259 0.031711 0.0530 0.0180 0.000035 0.0169 0.0165 0.000173 2.820000e-07 0.000157 0.001020 0.000519 0.033200 0.000098 2.680000e-06 0.000150 0.000141 0.000140 8.460000e-08 0.000108 0.00512
5 0.258287 0.022303 0.005030 0.000000 1.0 0.0 0.00 0.0 0.0 0.000000 0.308259 0.040088 0.0803 0.0450 0.000039 0.0180 0.1010 0.000175 2.920000e-07 0.000965 0.001320 0.000542 0.034000 0.000102 2.750000e-06 0.000438 0.000154 0.000153 8.730000e-08 0.000119 0.00960
6 0.258287 0.062086 0.038226 0.000000 1.0 0.0 0.25 0.0 0.0 0.666667 0.308259 0.040088 0.0935 0.0503 0.000047 0.0219 0.1080 0.000214 3.560000e-07 0.001040 0.001560 0.000662 0.041700 0.000124 3.370000e-06 0.000484 0.000186 0.000185 1.070000e-07 0.000144 0.01100
7 0.137212 0.021700 0.004527 0.000000 1.0 0.0 0.00 0.0 0.0 0.666667 0.109655 0.030314 0.0713 0.0379 0.000036 0.0169 0.0806 0.000166 2.750000e-07 0.000770 0.001200 0.000511 0.032200 0.000096 2.600000e-06 0.000364 0.000144 0.000143 8.250000e-08 0.000111 0.00830
8 0.137212 0.021700 0.004527 0.000000 1.0 0.2 0.00 0.0 0.0 0.666667 0.109655 0.029616 0.0584 0.0251 0.000034 0.0164 0.0407 0.000165 2.700000e-07 0.000389 0.001060 0.000499 0.031800 0.000094 2.570000e-06 0.000228 0.000138 0.000137 8.120000e-08 0.000106 0.00619
9 0.137212 0.028330 0.010060 0.000000 1.0 0.4 0.00 0.0 0.0 0.666667 0.109655 0.028918 0.0564 0.0219 0.000035 0.0168 0.0291 0.000171 2.790000e-07 0.000278 0.001050 0.000514 0.032800 0.000097 2.650000e-06 0.000192 0.000141 0.000140 8.380000e-08 0.000108 0.00573
10 0.137212 0.028330 0.010060 0.000000 1.0 0.6 0.00 0.0 0.0 0.666667 0.109655 0.028220 0.0540 0.0196 0.000034 0.0166 0.0221 0.000170 2.770000e-07 0.000211 0.001030 0.000511 0.032700 0.000097 2.640000e-06 0.000168 0.000140 0.000139 8.330000e-08 0.000107 0.00535
11 0.137212 0.027728 0.009557 0.000000 1.0 1.0 0.00 0.0 0.0 0.666667 0.109655 0.027522 0.0514 0.0172 0.000034 0.0164 0.0150 0.000169 2.750000e-07 0.000143 0.000996 0.000506 0.032400 0.000096 2.610000e-06 0.000143 0.000138 0.000137 8.260000e-08 0.000106 0.00494
12 0.137212 0.021700 0.004527 0.000000 1.0 0.0 0.00 0.0 0.0 0.000000 0.109655 0.030314 0.0739 0.0405 0.000036 0.0170 0.0887 0.000166 2.760000e-07 0.000848 0.001230 0.000513 0.032200 0.000096 2.610000e-06 0.000391 0.000145 0.000144 8.270000e-08 0.000112 0.00873
13 0.137212 0.061483 0.037723 0.000000 1.0 0.0 0.25 0.0 0.0 0.666667 0.109655 0.030314 0.0868 0.0454 0.000045 0.0209 0.0949 0.000205 3.410000e-07 0.000907 0.001470 0.000632 0.039800 0.000119 3.220000e-06 0.000434 0.000177 0.000176 1.020000e-07 0.000137 0.01000
14 0.077118 0.021700 0.004527 0.039373 1.0 0.0 0.00 0.0 0.0 0.666667 0.040474 0.054050 0.0837 0.0461 0.000041 0.0191 0.1020 0.000186 3.100000e-07 0.000972 0.001380 0.000576 0.036200 0.000108 2.930000e-06 0.000447 0.000163 0.000162 9.290000e-08 0.000126 0.00992
15 0.077118 0.021700 0.004527 0.039373 1.0 0.0 0.00 0.0 0.0 0.000000 0.040474 0.054050 0.0864 0.0488 0.000041 0.0192 0.1100 0.000186 3.110000e-07 0.001050 0.001410 0.000579 0.036300 0.000108 2.930000e-06 0.000475 0.000164 0.000163 9.310000e-08 0.000127 0.01040
16 0.077118 0.021700 0.004527 0.039373 1.0 0.0 0.00 0.0 0.0 0.333333 0.040474 0.054050 0.0849 0.0473 0.000041 0.0192 0.1060 0.000186 3.110000e-07 0.001010 0.001400 0.000577 0.036300 0.000108 2.930000e-06 0.000459 0.000163 0.000162 9.300000e-08 0.000127 0.01010
17 0.077118 0.021700 0.004527 0.039373 1.0 0.0 0.00 0.0 0.0 0.866667 0.040474 0.054050 0.0831 0.0455 0.000041 0.0191 0.0999 0.000186 3.100000e-07 0.000955 0.001380 0.000576 0.036200 0.000108 2.930000e-06 0.000440 0.000163 0.000162 9.290000e-08 0.000126 0.00982
18 0.077118 0.021700 0.004527 0.039373 1.0 0.0 0.00 0.0 0.0 1.000000 0.040474 0.054050 0.0828 0.0453 0.000041 0.0191 0.0990 0.000186 3.100000e-07 0.000946 0.001380 0.000576 0.036200 0.000108 2.930000e-06 0.000437 0.000162 0.000161 9.280000e-08 0.000126 0.00977
19 0.077118 0.121157 0.087518 0.039373 1.0 0.0 1.00 0.0 0.0 0.666667 0.040474 0.054050 0.1260 0.0682 0.000063 0.0292 0.1480 0.000285 4.750000e-07 0.001410 0.002090 0.000881 0.055500 0.000165 4.480000e-06 0.000658 0.000248 0.000247 1.420000e-07 0.000192 0.01480
20 0.474185 0.016275 0.000000 0.039373 1.0 0.0 0.00 0.0 0.0 0.666667 0.636497 0.074296 0.0930 0.0530 0.000044 0.0205 0.1210 0.000198 3.310000e-07 0.001150 0.001520 0.000617 0.038700 0.000116 3.120000e-06 0.000517 0.000175 0.000174 9.920000e-08 0.000136 0.01120
21 0.474185 0.016275 0.000000 0.039373 1.0 0.0 0.00 0.0 0.0 0.000000 0.636497 0.074296 0.0951 0.0552 0.000045 0.0206 0.1270 0.000198 3.320000e-07 0.001220 0.001540 0.000618 0.038700 0.000116 3.130000e-06 0.000540 0.000176 0.000175 9.940000e-08 0.000136 0.01160
22 0.474185 0.016275 0.000000 0.039373 1.0 0.0 0.00 0.0 0.0 0.333333 0.636497 0.074296 0.0939 0.0539 0.000044 0.0205 0.1230 0.000198 3.320000e-07 0.001180 0.001530 0.000617 0.038700 0.000116 3.130000e-06 0.000526 0.000175 0.000174 9.930000e-08 0.000136 0.01130
23 0.474185 0.016275 0.000000 0.039373 1.0 0.0 0.00 0.0 0.0 0.866667 0.636497 0.074296 0.0925 0.0526 0.000044 0.0205 0.1190 0.000198 3.310000e-07 0.001140 0.001510 0.000616 0.038600 0.000116 3.120000e-06 0.000512 0.000175 0.000174 9.920000e-08 0.000135 0.01110
24 0.474185 0.016275 0.000000 0.039373 1.0 0.0 0.00 0.0 0.0 1.000000 0.636497 0.074296 0.0923 0.0523 0.000044 0.0205 0.1180 0.000198 3.310000e-07 0.001130 0.001510 0.000616 0.038600 0.000115 3.120000e-06 0.000510 0.000175 0.000174 9.920000e-08 0.000135 0.01110
25 0.474185 0.121760 0.088021 0.039373 1.0 0.0 1.00 0.0 0.0 0.666667 0.636497 0.074296 0.1390 0.0782 0.000067 0.0313 0.1750 0.000304 5.060000e-07 0.001670 0.002290 0.000941 0.059100 0.000177 4.780000e-06 0.000760 0.000266 0.000265 1.520000e-07 0.000207 0.01670
26 0.615385 0.150090 0.111661 0.239088 1.0 0.0 0.00 0.0 0.0 0.666667 0.563468 0.084768 0.1350 0.0664 0.000073 0.0343 0.1300 0.000340 5.620000e-07 0.001240 0.002340 0.001040 0.065800 0.000196 5.320000e-06 0.000626 0.000290 0.000289 1.690000e-07 0.000224 0.01520
27 0.615385 0.150090 0.111661 0.239088 1.0 0.0 0.00 0.0 0.0 0.000000 0.563468 0.084768 0.1400 0.0714 0.000073 0.0345 0.1450 0.000340 5.630000e-07 0.001390 0.002390 0.001040 0.066000 0.000196 5.330000e-06 0.000679 0.000292 0.000291 1.690000e-07 0.000226 0.01600
28 0.615385 0.263412 0.206221 0.239088 1.0 0.0 0.25 0.0 0.0 0.666667 0.563468 0.084768 0.1770 0.0860 0.000096 0.0455 0.1630 0.000453 7.480000e-07 0.001580 0.003090 0.001380 0.087600 0.000260 7.080000e-06 0.000807 0.000385 0.000383 2.240000e-07 0.000297 0.01980
29 0.615385 0.376733 0.300782 0.239088 1.0 0.0 0.50 0.0 0.0 0.666667 0.563468 0.084768 0.2180 0.1030 0.000120 0.0567 0.1940 0.000566 9.330000e-07 0.001850 0.003820 0.001730 0.109000 0.000325 8.830000e-06 0.000966 0.000480 0.000477 2.800000e-07 0.000370 0.02410
30 0.615385 0.489451 0.394839 0.239088 1.0 0.0 0.75 0.0 0.0 0.666667 0.563468 0.084768 0.2580 0.1210 0.000143 0.0679 0.2240 0.000678 1.120000e-06 0.002140 0.004550 0.002070 0.131000 0.000389 1.060000e-05 0.001130 0.000574 0.000570 3.350000e-07 0.000442 0.02840
31 0.615385 0.601567 0.488393 0.239088 1.0 0.0 1.00 0.0 0.0 0.666667 0.563468 0.084768 0.3320 0.1730 0.000171 0.0803 0.3590 0.000790 1.310000e-06 0.003430 0.005630 0.002430 0.153000 0.000456 1.240000e-05 0.001650 0.000681 0.000677 3.930000e-07 0.000527 0.03830
32 0.000000 0.156118 0.116691 0.239088 1.0 0.0 0.00 0.0 0.0 0.666667 0.000000 0.000993 0.1090 0.0537 0.000059 0.0276 0.1050 0.000274 4.530000e-07 0.001000 0.001890 0.000839 0.053100 0.000158 4.290000e-06 0.000506 0.000234 0.000233 1.360000e-07 0.000181 0.01230
33 0.000000 0.156118 0.116691 0.239088 1.0 0.0 0.00 0.0 0.0 0.000000 0.000000 0.000993 0.1140 0.0591 0.000059 0.0278 0.1220 0.000274 4.550000e-07 0.001170 0.001950 0.000843 0.053200 0.000158 4.300000e-06 0.000564 0.000236 0.000235 1.360000e-07 0.000183 0.01310
34 0.000000 0.267631 0.209742 0.239088 1.0 0.0 0.25 0.0 0.0 0.666667 0.000000 0.000993 0.1490 0.0713 0.000082 0.0387 0.1350 0.000385 6.350000e-07 0.001290 0.002610 0.001180 0.074500 0.000221 6.020000e-06 0.000667 0.000327 0.000325 1.900000e-07 0.000252 0.01650
35 0.000000 0.379144 0.302793 0.239088 1.0 0.0 0.50 0.0 0.0 0.666667 0.000000 0.000993 0.1900 0.0900 0.000105 0.0497 0.1680 0.000496 8.180000e-07 0.001600 0.003340 0.001510 0.095900 0.000285 7.750000e-06 0.000840 0.000420 0.000418 2.450000e-07 0.000324 0.02100
36 0.000000 0.491260 0.396348 0.239088 1.0 0.0 0.75 0.0 0.0 0.666667 0.000000 0.000993 0.2310 0.1080 0.000128 0.0608 0.1990 0.000608 1.000000e-06 0.001900 0.004070 0.001850 0.117000 0.000349 9.480000e-06 0.001010 0.000514 0.000511 3.000000e-07 0.000396 0.02540
37 0.000000 0.601567 0.488393 0.239088 1.0 0.0 1.00 0.0 0.0 0.666667 0.000000 0.000993 0.3020 0.1570 0.000156 0.0729 0.3260 0.000718 1.190000e-06 0.003120 0.005120 0.002210 0.139000 0.000415 1.130000e-05 0.001500 0.000619 0.000616 3.570000e-07 0.000479 0.03480
38 0.500000 0.435202 0.349571 1.000000 1.0 0.0 0.00 0.0 0.0 0.666667 0.025434 0.000993 0.2220 0.1110 0.000118 0.0557 0.2200 0.000552 9.130000e-07 0.002100 0.003830 0.001690 0.107000 0.000318 8.640000e-06 0.001050 0.000472 0.000469 2.740000e-07 0.000365 0.02510
39 0.500000 0.435202 0.349571 1.000000 1.0 0.0 0.00 0.0 0.0 0.000000 0.025434 0.000993 0.2330 0.1220 0.000120 0.0561 0.2540 0.000552 9.160000e-07 0.002430 0.003950 0.001700 0.107000 0.000319 8.660000e-06 0.001160 0.000477 0.000474 2.750000e-07 0.000369 0.02690
40 0.500000 0.630500 0.512536 1.000000 1.0 0.0 0.25 0.0 0.0 0.666667 0.025434 0.000993 0.2960 0.1460 0.000159 0.0752 0.2850 0.000747 1.230000e-06 0.002720 0.005140 0.002280 0.144000 0.000430 1.170000e-05 0.001370 0.000637 0.000633 3.700000e-07 0.000491 0.03330
41 0.500410 0.423749 0.340014 1.000000 1.0 0.0 0.00 0.0 0.0 0.666667 0.809761 1.000000 0.5250 0.2420 0.000294 0.1400 0.4370 0.001400 2.300000e-06 0.004170 0.009300 0.004260 0.270000 0.000802 2.180000e-05 0.002250 0.001180 0.001170 6.910000e-07 0.000910 0.05730
42 0.500410 0.423749 0.340014 1.000000 1.0 0.0 0.00 0.0 0.0 0.000000 0.809761 1.000000 0.5360 0.2530 0.000296 0.1400 0.4710 0.001400 2.310000e-06 0.004510 0.009420 0.004270 0.270000 0.000803 2.180000e-05 0.002360 0.001190 0.001180 6.920000e-07 0.000914 0.05920
43 0.500410 0.622061 0.505494 1.000000 1.0 0.0 0.25 0.0 0.0 0.666667 0.809761 1.000000 0.6000 0.2780 0.000336 0.1600 0.5020 0.001600 2.630000e-06 0.004790 0.010600 0.004860 0.308000 0.000915 2.490000e-05 0.002570 0.001350 0.001340 7.880000e-07 0.001040 0.06560
44 0.425661 0.066305 0.041747 0.113434 1.0 0.0 0.00 0.0 0.0 0.666667 0.423123 0.076390 0.1060 0.0557 0.000054 0.0254 0.1170 0.000250 4.140000e-07 0.001120 0.001790 0.000769 0.048500 0.000144 3.920000e-06 0.000533 0.000216 0.000215 1.240000e-07 0.000167 0.01230
45 0.425661 0.066305 0.041747 0.113434 1.0 0.2 0.00 0.0 0.0 0.666667 0.423123 0.076390 0.0877 0.0373 0.000052 0.0247 0.0593 0.000249 4.090000e-07 0.000567 0.001600 0.000755 0.048000 0.000142 3.880000e-06 0.000338 0.000208 0.000207 1.230000e-07 0.000160 0.00925
46 0.425661 0.074744 0.048789 0.113434 1.0 0.4 0.00 0.0 0.0 0.666667 0.423123 0.075692 0.0841 0.0322 0.000052 0.0252 0.0416 0.000257 4.200000e-07 0.000398 0.001580 0.000774 0.049400 0.000146 3.990000e-06 0.000282 0.000212 0.000211 1.260000e-07 0.000163 0.00851
47 1.000000 0.111513 0.079471 0.113434 1.0 0.0 0.25 0.0 0.0 0.666667 1.000000 0.024729 0.1060 0.0557 0.000054 0.0255 0.1170 0.000250 4.150000e-07 0.001120 0.001800 0.000771 0.048600 0.000145 3.930000e-06 0.000534 0.000216 0.000215 1.240000e-07 0.000167 0.01230
48 1.000000 0.165763 0.124739 0.113434 1.0 0.0 0.50 0.0 0.0 0.666667 1.000000 0.024729 0.1270 0.0659 0.000066 0.0309 0.1360 0.000304 5.040000e-07 0.001300 0.002160 0.000936 0.059000 0.000176 4.770000e-06 0.000629 0.000262 0.000261 1.510000e-07 0.000203 0.01460
49 1.000000 0.219409 0.169504 0.113434 1.0 0.0 0.75 0.0 0.0 0.666667 1.000000 0.024729 0.1480 0.0760 0.000077 0.0363 0.1560 0.000358 5.930000e-07 0.001490 0.002530 0.001100 0.069400 0.000206 5.600000e-06 0.000723 0.000308 0.000306 1.780000e-07 0.000238 0.01700
50 0.258287 0.001206 0.006287 0.000000 0.0 0.0 0.00 1.0 1.0 0.666667 0.329916 0.040786 0.0588 0.0588 0.000015 0.0189 0.0969 0.000009 8.040000e-08 0.000951 0.002830 0.000129 0.001070 0.000024 7.110000e-07 0.000342 0.000060 0.000059 3.110000e-08 0.000044 0.01240
51 0.258287 0.001206 0.006287 0.000000 0.0 0.2 0.00 1.0 1.0 0.666667 0.308259 0.036624 0.0423 0.0422 0.000012 0.0179 0.0467 0.000009 7.420000e-08 0.000470 0.002610 0.000115 0.000694 0.000021 6.660000e-07 0.000171 0.000053 0.000051 2.930000e-08 0.000038 0.00957
52 0.258287 0.001206 0.006287 0.000000 0.0 0.0 0.00 1.0 1.0 0.000000 0.329916 0.040786 0.0613 0.0612 0.000015 0.0190 0.1050 0.000009 8.110000e-08 0.001030 0.002860 0.000131 0.001130 0.000024 7.160000e-07 0.000368 0.000061 0.000060 3.130000e-08 0.000045 0.01280
53 0.258287 0.001206 0.006287 0.000000 0.0 0.0 0.00 1.0 1.0 0.333333 0.329916 0.040786 0.0599 0.0598 0.000015 0.0190 0.1000 0.000009 8.070000e-08 0.000982 0.002840 0.000130 0.001100 0.000024 7.130000e-07 0.000353 0.000061 0.000059 3.120000e-08 0.000045 0.01250
54 0.137212 0.000000 0.005088 0.000000 0.0 0.0 0.00 1.0 1.0 0.666667 0.109655 0.029965 0.0519 0.0519 0.000013 0.0176 0.0806 0.000009 7.450000e-08 0.000793 0.002620 0.000119 0.000929 0.000022 6.610000e-07 0.000286 0.000055 0.000054 2.900000e-08 0.000040 0.01110
55 0.137212 0.000000 0.005088 0.000000 0.0 0.2 0.00 1.0 1.0 0.666667 0.109655 0.027468 0.0386 0.0385 0.000012 0.0169 0.0398 0.000008 6.980000e-08 0.000403 0.002450 0.000108 0.000625 0.000020 6.280000e-07 0.000147 0.000049 0.000048 2.760000e-08 0.000035 0.00882
56 0.137212 0.000000 0.005088 0.000000 0.0 0.0 0.00 1.0 1.0 0.000000 0.109655 0.029965 0.0545 0.0545 0.000014 0.0177 0.0887 0.000009 7.530000e-08 0.000871 0.002650 0.000121 0.000989 0.000022 6.660000e-07 0.000314 0.000056 0.000055 2.920000e-08 0.000041 0.01150
57 0.137212 0.000000 0.005088 0.000000 0.0 0.0 0.00 1.0 1.0 0.333333 0.109655 0.029965 0.0530 0.0530 0.000014 0.0177 0.0840 0.000009 7.480000e-08 0.000826 0.002640 0.000120 0.000955 0.000022 6.630000e-07 0.000298 0.000056 0.000055 2.910000e-08 0.000041 0.01120
58 0.077118 0.001808 0.006887 0.039373 0.0 0.0 0.00 1.0 1.0 0.666667 0.040474 0.052439 0.0617 0.0616 0.000016 0.0200 0.1010 0.000010 8.510000e-08 0.000987 0.003000 0.000137 0.001120 0.000025 7.530000e-07 0.000355 0.000064 0.000062 3.300000e-08 0.000047 0.01300
59 0.077118 0.001808 0.006887 0.039373 0.0 0.2 0.00 1.0 1.0 0.666667 0.040474 0.051607 0.0456 0.0455 0.000013 0.0194 0.0503 0.000009 8.000000e-08 0.000507 0.002810 0.000124 0.000749 0.000023 7.180000e-07 0.000185 0.000057 0.000055 3.160000e-08 0.000041 0.01030
60 0.077118 0.001808 0.006887 0.039373 0.0 0.0 0.00 1.0 1.0 0.000000 0.040474 0.052439 0.0645 0.0644 0.000016 0.0201 0.1090 0.000010 8.590000e-08 0.001070 0.003030 0.000139 0.001180 0.000025 7.580000e-07 0.000385 0.000065 0.000063 3.320000e-08 0.000048 0.01340
61 0.077118 0.001808 0.006887 0.039373 0.0 0.0 0.00 1.0 1.0 0.333333 0.040474 0.052439 0.0629 0.0628 0.000016 0.0201 0.1040 0.000010 8.540000e-08 0.001020 0.003010 0.000138 0.001150 0.000025 7.550000e-07 0.000368 0.000064 0.000063 3.310000e-08 0.000047 0.01320
62 0.474185 0.000000 0.005088 0.039373 0.0 0.0 0.00 1.0 1.0 0.666667 0.636497 0.075746 0.0717 0.0717 0.000018 0.0221 0.1230 0.000011 9.440000e-08 0.001210 0.003330 0.000153 0.001320 0.000028 8.330000e-07 0.000433 0.000072 0.000070 3.640000e-08 0.000053 0.01490
63 0.474185 0.000000 0.005088 0.039373 0.0 0.2 0.00 1.0 1.0 0.666667 0.636497 0.061595 0.0487 0.0486 0.000014 0.0201 0.0568 0.000010 8.320000e-08 0.000570 0.002930 0.000130 0.000810 0.000024 7.460000e-07 0.000207 0.000059 0.000058 3.280000e-08 0.000043 0.01090
64 0.474185 0.000000 0.005088 0.039373 0.0 0.0 0.00 1.0 1.0 0.000000 0.636497 0.075746 0.0741 0.0740 0.000018 0.0222 0.1310 0.000011 9.510000e-08 0.001280 0.003350 0.000155 0.001380 0.000028 8.370000e-07 0.000459 0.000073 0.000071 3.660000e-08 0.000054 0.01530
65 0.474185 0.000000 0.005088 0.039373 0.0 0.0 0.00 1.0 1.0 0.333333 0.636497 0.075746 0.0727 0.0726 0.000018 0.0221 0.1260 0.000011 9.470000e-08 0.001240 0.003340 0.000154 0.001350 0.000028 8.340000e-07 0.000444 0.000072 0.000070 3.650000e-08 0.000053 0.01510
66 0.615385 0.107294 0.111835 0.239088 0.0 0.0 0.00 1.0 1.0 0.000000 0.563468 0.086567 0.0987 0.0986 0.000027 0.0360 0.1400 0.000017 1.510000e-07 0.001390 0.005320 0.000239 0.001720 0.000044 1.350000e-06 0.000501 0.000110 0.000108 5.910000e-08 0.000080 0.02140
67 0.615385 0.107294 0.111835 0.239088 0.0 0.0 0.00 1.0 1.0 0.333333 0.563468 0.086567 0.0959 0.0958 0.000026 0.0359 0.1310 0.000017 1.500000e-07 0.001300 0.005290 0.000237 0.001660 0.000044 1.340000e-06 0.000471 0.000109 0.000107 5.880000e-08 0.000079 0.02100
68 0.615385 0.201929 0.205989 0.239088 0.0 0.0 0.25 1.0 1.0 0.666667 0.563468 0.086567 0.1240 0.1230 0.000034 0.0476 0.1620 0.000023 1.980000e-07 0.001610 0.006980 0.000312 0.002120 0.000058 1.770000e-06 0.000585 0.000143 0.000140 7.790000e-08 0.000104 0.02720
69 0.615385 0.297167 0.300743 0.239088 0.0 0.0 0.50 1.0 1.0 0.666667 0.563468 0.086567 0.1490 0.1490 0.000042 0.0592 0.1860 0.000029 2.460000e-07 0.001860 0.008660 0.000385 0.002520 0.000071 2.200000e-06 0.000673 0.000177 0.000173 9.680000e-08 0.000127 0.03310
70 0.615385 0.391802 0.394897 0.239088 0.0 0.0 0.75 1.0 1.0 0.666667 0.563468 0.086567 0.1760 0.1760 0.000050 0.0708 0.2150 0.000034 2.940000e-07 0.002150 0.010400 0.000459 0.002960 0.000085 2.630000e-06 0.000781 0.000211 0.000206 1.160000e-07 0.000152 0.03920
71 0.615385 0.485232 0.487851 0.239088 0.0 0.0 1.00 1.0 1.0 0.666667 0.563468 0.086567 0.2370 0.2360 0.000063 0.0836 0.3500 0.000041 3.520000e-07 0.003460 0.012400 0.000559 0.004180 0.000103 3.130000e-06 0.001250 0.000259 0.000253 1.370000e-07 0.000188 0.05090
72 0.000000 0.112116 0.116633 0.239088 0.0 0.0 0.00 1.0 1.0 0.000000 0.000000 0.001665 0.0828 0.0827 0.000022 0.0291 0.1230 0.000014 1.220000e-07 0.001220 0.004310 0.000194 0.001460 0.000036 1.090000e-06 0.000439 0.000090 0.000088 4.770000e-08 0.000066 0.01780
73 0.000000 0.112116 0.116633 0.239088 0.0 0.0 0.00 1.0 1.0 0.333333 0.000000 0.001665 0.0797 0.0796 0.000021 0.0290 0.1140 0.000014 1.210000e-07 0.001130 0.004280 0.000192 0.001390 0.000035 1.080000e-06 0.000407 0.000089 0.000087 4.750000e-08 0.000064 0.01730
74 0.000000 0.205546 0.209588 0.239088 0.0 0.0 0.25 1.0 1.0 0.666667 0.000000 0.001665 0.1040 0.1040 0.000029 0.0404 0.1360 0.000020 1.680000e-07 0.001350 0.005920 0.000264 0.001780 0.000049 1.500000e-06 0.000489 0.000122 0.000119 6.600000e-08 0.000088 0.02300
75 0.000000 0.298975 0.302542 0.239088 0.0 0.0 0.50 1.0 1.0 0.666667 0.000000 0.001665 0.1320 0.1320 0.000037 0.0519 0.1670 0.000025 2.160000e-07 0.001670 0.007600 0.000338 0.002240 0.000063 1.930000e-06 0.000605 0.000155 0.000152 8.480000e-08 0.000112 0.02920
76 0.000000 0.393008 0.396096 0.239088 0.0 0.0 0.75 1.0 1.0 0.666667 0.000000 0.001665 0.1590 0.1590 0.000045 0.0635 0.1990 0.000031 2.640000e-07 0.001980 0.009280 0.000413 0.002690 0.000077 2.360000e-06 0.000720 0.000190 0.000185 1.040000e-07 0.000137 0.03540
77 0.000000 0.484629 0.487251 0.239088 0.0 0.0 1.00 1.0 1.0 0.666667 0.000000 0.001665 0.2160 0.2160 0.000057 0.0759 0.3230 0.000037 3.190000e-07 0.003190 0.011200 0.000508 0.003830 0.000093 2.840000e-06 0.001150 0.000235 0.000230 1.250000e-07 0.000171 0.04640
78 0.500000 0.347800 0.351118 1.000000 0.0 0.0 0.00 1.0 1.0 0.666667 0.025434 0.000832 0.1590 0.1580 0.000043 0.0583 0.2230 0.000028 2.440000e-07 0.002210 0.008600 0.000386 0.002770 0.000071 2.180000e-06 0.000799 0.000178 0.000174 9.550000e-08 0.000129 0.03450
79 0.500000 0.343580 0.346920 1.000000 0.0 0.2 0.00 1.0 1.0 0.666667 0.025434 0.000832 0.1230 0.1220 0.000037 0.0565 0.1130 0.000027 2.320000e-07 0.001150 0.008150 0.000356 0.001940 0.000067 2.090000e-06 0.000424 0.000162 0.000158 9.200000e-08 0.000115 0.02850
80 0.500000 0.357444 0.360713 1.000000 0.0 0.4 0.00 1.0 1.0 0.666667 0.025434 0.000832 0.1150 0.1140 0.000037 0.0577 0.0793 0.000028 2.350000e-07 0.000837 0.008270 0.000358 0.001730 0.000067 2.130000e-06 0.000312 0.000162 0.000158 9.380000e-08 0.000115 0.02740
81 0.500000 0.354430 0.357715 1.000000 0.0 0.6 0.00 1.0 1.0 0.666667 0.025434 0.000000 0.1080 0.1070 0.000036 0.0570 0.0598 0.000027 2.320000e-07 0.000649 0.008140 0.000351 0.001580 0.000066 2.100000e-06 0.000245 0.000158 0.000154 9.260000e-08 0.000111 0.02620
82 0.500000 0.342978 0.346321 1.000000 0.0 1.0 0.00 1.0 1.0 0.666667 0.025434 0.000832 0.0994 0.0992 0.000034 0.0555 0.0402 0.000027 2.250000e-07 0.000460 0.007890 0.000338 0.001410 0.000064 2.040000e-06 0.000178 0.000152 0.000148 9.000000e-08 0.000107 0.02460
83 0.500000 0.839060 0.839879 1.000000 0.0 0.0 0.75 1.0 1.0 0.666667 0.025434 0.000832 0.3090 0.3090 0.000085 0.1190 0.4070 0.000058 4.970000e-07 0.004050 0.017500 0.000780 0.005300 0.000144 4.440000e-06 0.001470 0.000359 0.000351 1.950000e-07 0.000259 0.06810
84 0.500000 1.000000 1.000000 1.000000 0.0 0.0 1.00 1.0 1.0 0.666667 0.025434 0.000832 0.4070 0.4060 0.000106 0.1410 0.6170 0.000069 5.940000e-07 0.006090 0.020900 0.000945 0.007230 0.000174 5.270000e-06 0.002190 0.000439 0.000429 2.310000e-07 0.000320 0.08700
85 1.000000 0.344183 0.347520 1.000000 0.0 0.0 0.00 1.0 1.0 0.666667 0.790521 0.220578 0.2170 0.2160 0.000058 0.0779 0.3140 0.000038 3.270000e-07 0.003100 0.011500 0.000518 0.003800 0.000096 2.910000e-06 0.001120 0.000240 0.000234 1.280000e-07 0.000174 0.04680
86 1.000000 0.362869 0.366111 1.000000 0.0 1.0 0.00 1.0 1.0 0.666667 0.790521 0.192278 0.1340 0.1330 0.000046 0.0746 0.0542 0.000036 3.020000e-07 0.000621 0.010600 0.000455 0.001890 0.000086 2.740000e-06 0.000239 0.000205 0.000199 1.210000e-07 0.000143 0.03310
87 1.000000 0.509946 0.512439 1.000000 0.0 0.0 0.25 1.0 1.0 0.666667 0.790521 0.220578 0.2720 0.2720 0.000073 0.0986 0.3900 0.000048 4.140000e-07 0.003860 0.014600 0.000655 0.004760 0.000121 3.680000e-06 0.001390 0.000303 0.000296 1.620000e-07 0.000220 0.05890
88 1.000000 0.675708 0.677358 1.000000 0.0 0.0 0.50 1.0 1.0 0.666667 0.790521 0.220578 0.3200 0.3190 0.000087 0.1190 0.4420 0.000058 4.980000e-07 0.004380 0.017500 0.000785 0.005540 0.000145 4.440000e-06 0.001580 0.000362 0.000354 1.950000e-07 0.000263 0.06970
89 1.000000 0.840868 0.841678 1.000000 0.0 0.0 0.75 1.0 1.0 0.666667 0.790521 0.220578 0.3660 0.3650 0.000100 0.1390 0.4890 0.000068 5.810000e-07 0.004860 0.020500 0.000914 0.006290 0.000169 5.190000e-06 0.001760 0.000421 0.000412 2.280000e-07 0.000305 0.08030
lin_regressor = LinearRegression()
# pass the order of your polynomial here
poly = PolynomialFeatures(1)
# convert to be used further to linear regression
X_transform = poly.fit_transform(x_train)
# fit this to Linear Regressor
linear_regg=lin_regressor.fit(X_transform,y_train)
linear_regg.coef_
# get the predictions
X_test_transform = poly.fit_transform(x_test)
y_preds_polynomial_regressor = lin_regressor.predict(X_test_transform)
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
from sklearn.metrics import r2_score
crossvalidation_poly = KFold(n_splits=10, shuffle=True)
for i in range(1,11):
poly_cross_validation = PolynomialFeatures(degree=i)
X_current = poly.fit_transform(X_normalized)
model = lin_regressor.fit(X_current, y_for_normalized)
scores = cross_val_score(model, X_current,y_for_normalized, scoring='r2', cv=crossvalidation_poly,
n_jobs=1)
print("\n\nDegree-"+str(i)+" polynomial: R^2 for every fold: " + str(np.abs(scores)))
print('\033[1m'+"Degree-"+str(i)+'\033[1m'+"polynomial: Average R^2 for all the folds: " + str(np.mean(np.abs(scores))) + '\033[0m'+ ", STD: " + str(np.std(scores)))
Degree-1 polynomial: R^2 for every fold: [0.76295904 0.96271418 0.94310536 0.91732566 0.96612939 0.97031929
0.9913522 0.99347979 0.87728285 0.96961128]
Degree-1polynomial: Average R^2 for all the folds: 0.9354279053365726, STD: 0.06639546264706242
Degree-2 polynomial: R^2 for every fold: [0.91315584 0.98834316 0.95305722 0.96135075 0.95088178 0.98469973
0.85601024 0.93466868 0.90153858 0.98206352]
Degree-2polynomial: Average R^2 for all the folds: 0.9425769506851147, STD: 0.04008167950913074
Degree-3 polynomial: R^2 for every fold: [0.99193642 0.94930724 0.97407922 0.98482365 0.95087103 0.96237042
0.8981392 0.97702263 0.98042845 0.9590484 ]
Degree-3polynomial: Average R^2 for all the folds: 0.9628026644379586, STD: 0.0254830753054201
Degree-4 polynomial: R^2 for every fold: [0.98440571 0.97680078 0.95419355 0.98656256 0.9258109 0.93366813
0.96516026 0.961787 0.98939286 0.93072549]
Degree-4polynomial: Average R^2 for all the folds: 0.9608507236588766, STD: 0.022853823542880715发布于 2022-08-05 03:09:44
在增加多项式度时,R2没有增加的必要,因为R2基本上意味着精度。当你增加多项式度时,线的形状发生了一点变化,这就是为什么在增加的时候,它不需要完全符合这种关系。
https://stackoverflow.com/questions/73244128
复制相似问题