I am trying to fit exponential to my data in r to get regression parameters. I would appreciate if you could please help me with. I have tried nls()
and didn't work, tried different datasets as well. Also, found SSasymp
and it worked but I think it is only for decay.
I want to fit Ct = Cmax + (C0 - Cmax)e^-k.t
if I have decay, where C0
is the mean of first 10 sec of value, Cmax
is the maximum value, and k
is a constant. Therefore I can get k(Cmax - C0)
as the rate of the change.
I want to fit Ct = C0 + (Cmax-C0)*(1-e^-k.t)
if I have growth and get the k
.
Thanks a lot
Note:
Decay:
time:
c(0, 0.319000005722046, 1.34500002861023, 2.11700010299683, 2.65100002288818,
3.19000005722046, 4.19700002670288, 4.99600005149841, 5.36800003051758,
6.45600008964539, 7.24600005149841, 7.77900004386902, 8.31800007820129,
9.34500002861023, 10.1370000839233, 10.4670000076294, 11.5, 12.2760000228882,
12.805999994278, 13.3450000286102, 14.3740000724792, 15.154000043869,
15.4860000610352, 16.5280001163483, 17.3090000152588, 17.8359999656677,
18.3710000514984, 19.3949999809265, 20.1770000457764, 20.4960000514984,
21.5060000419617, 22.2829999923706, 22.8120000362396, 23.3489999771118,
24.3710000514984, 25.1600000858307, 25.5910000801086, 26.6270000934601,
27.4010000228882, 27.933000087738, 28.4660000801086, 29.5030000209808,
30.2890000343323, 30.7009999752045, 31.779000043869, 32.5820000171661,
33.1150000095367, 33.654000043869, 34.6840000152588, 35.4760000705719,
35.8810000419617, 36.9430000782013, 37.7360000610352, 38.2720000743866,
38.8129999637604, 39.8580000400543, 40.6440000534058, 41.143000125885,
42.2030000686646, 42.9730000495911, 43.5090000629425, 44.0510001182556,
45.0810000896454, 45.8849999904633, 46.3410000801086, 47.489000082016,
48.2690000534058, 48.8029999732971, 49.3389999866486, 50.3910000324249,
51.1670000553131, 51.5680000782013, 52.6310000419617, 53.4200000762939,
53.9509999752045, 54.4900000095367, 55.5329999923706, 56.3359999656677,
56.7369999885559, 57.7990000247955, 58.5840001106262, 59.1170001029968,
59.6640000343323, 60.6840000152588, 61.4760000705719, 61.8550000190735,
62.9400000572205, 63.7200000286102, 64.2530000209808, 64.7860000133514,
65.819000005722, 66.6040000915527, 66.9509999752045, 67.9820001125336,
68.7590000629425, 69.3020000457764, 69.8510000705719, 70.8740000724792,
71.6640000343323, 72.0420000553131, 73.1370000839233, 73.9200000762939,
74.4609999656677, 75.0069999694824, 76.0460000038147, 76.8380000591278,
77.2450001239777, 78.319000005722, 79.1080000400543, 79.643000125885,
80.1840000152588, 81.194000005722, 81.9690001010895, 82.2920000553131,
83.3320000171661, 84.143000125885, 84.6770000457764, 85.2160000801086,
86.239000082016, 87.029000043869, 87.4340000152588, 88.5099999904633,
89.3050000667572, 89.8410000801086, 90.3740000724792, 91.3900001049042,
92.1610000133514, 92.6240000724792, 93.7190001010895, 94.5420000553131,
95.0720000267029, 95.614000082016, 96.654000043869, 97.4379999637604,
97.7630000114441, 98.7920000553131, 99.5680000782013, 100.101000070572,
100.638000011444, 101.667999982834, 102.457000017166, 102.848999977112,
103.946000099182, 104.740000009537, 105.272000074387, 105.808000087738,
106.844000101089, 107.647000074387, 107.97200012207, 108.999000072479,
109.77999997139)
value:
c(391.12411366, 391.08100717, 390.94243548, 390.83830459, 390.76617733,
390.69324728, 390.38999998, 390.14939786, 390.0376815, 389.70998253,
389.47173279, 389.31119461, 389.1491491, 389.21559469, 389.26671895,
389.28811414, 389.3549619, 389.40510954, 389.43947037, 389.47427918,
389.04703391, 388.72275693, 388.5853234, 388.15268327, 387.82841051,
387.60917928, 387.38704258, 387.20998907, 387.07478506, 387.01980882,
386.84510585, 386.71052183, 386.61901005, 386.52612006, 386.15278149,
385.86492592, 385.70711689, 385.32912046, 385.04607945, 384.85214866,
384.65748181, 384.39117228, 384.18906771, 384.08326961, 383.80669132,
383.60021075, 383.46332154, 383.32514566, 382.76278914, 382.33080345,
382.10990354, 381.53119168, 381.09810866, 380.80629565, 380.51067106,
380.3812077, 380.28383162, 380.22213205, 380.09077494, 379.99536022,
379.92893917, 379.86177495, 379.21853896, 378.71581941, 378.4316801,
377.71482389, 377.22775015, 376.89366803, 376.55895926, 377.0199162,
377.36026046, 377.53657392, 378.00229948, 378.348741, 378.58160228,
378.81753244, 378.66982901, 378.55622193, 378.49948823, 378.34930228,
378.2384323, 378.16305767, 378.08556017, 377.89134515, 377.74039492,
377.66796687, 377.46130847, 377.31261093, 377.21080971, 377.109201,
376.74048636, 376.4606496, 376.33643738, 375.96886698, 375.69122412,
375.49779962, 375.30187551, 374.88554136, 374.56362855, 374.41020185,
373.96452629, 373.64583614, 373.42523778, 373.20301263, 372.95689249,
372.76951615, 372.67310562, 372.41842969, 372.23150586, 372.10499108,
371.97682247, 372.03639454, 372.08200686, 372.10103861, 372.1623518,
372.21017149, 372.24172397, 372.27350753, 372.17008905, 372.0901371,
372.04914205, 371.94011178, 371.85974481, 371.80549687, 371.75144937,
371.54387045, 371.38618534, 371.29149218, 371.06752863, 370.89899399,
370.79059479, 370.67995194, 370.22531351, 369.8821446, 369.74050264,
369.29024288, 368.95146194, 368.7184661, 368.48371741, 368.24428629,
368.06129047, 367.9700323, 367.71544758, 367.53099783, 367.4071743,
367.28288322, 367.69518211, 368.01515944, 368.14410924, 368.5533401,
368.86423517)
Growth:
time:
c(0, 0.552999973297119, 1.57200002670288, 2.36500000953674, 2.68499994277954,
3.73000001907349, 4.51900005340576, 5.04900002479553, 5.57800006866455,
6.62599992752075, 7.42400002479553, 7.72900009155273, 8.76999998092651,
9.56200003623962, 10.0989999771118, 10.6449999809265, 11.6719999313354,
12.4430000782013, 12.7730000019073, 13.8159999847412, 14.6189999580383,
15.1579999923706, 15.6970000267029, 16.7170000076294, 17.5160000324249,
17.845999956131, 18.8680000305176, 19.6410000324249, 20.1749999523163,
20.7179999351501, 21.7309999465942, 22.5199999809265, 22.933000087738,
24.0160000324249, 24.805999994278, 25.3389999866486, 25.8810000419617,
26.8980000019073, 27.6740000247955, 28.0829999446869, 29.1719999313354,
29.960000038147, 30.4960000514984, 31.0350000858307, 32.0599999427795,
32.8519999980927, 33.2920000553131, 34.3519999980927, 35.1370000839233,
35.6640000343323, 36.1979999542236, 37.2309999465942, 38.029000043869,
38.4830000400543, 39.5920000076294, 40.3759999275208, 40.904000043869,
41.4470000267029, 42.4660000801086, 43.25, 43.5750000476837,
44.5929999351501, 45.3880000114441, 45.9210000038147, 46.4670000076294,
47.4969999790192, 48.2850000858307, 48.6089999675751, 49.6219999790192,
50.3989999294281, 50.9400000572205, 51.4730000495911, 52.4869999885559,
53.2730000019073, 53.6679999828339, 54.7400000095367, 55.5130000114441,
56.0460000038147, 56.5789999961853, 57.6059999465942, 58.3810000419617,
58.7990000247955, 59.8429999351501, 60.6480000019073, 61.183000087738,
61.7239999771118, 62.7530000209808, 63.5360000133514, 63.8450000286102,
64.8680000305176, 65.654000043869, 66.183000087738, 66.7200000286102,
67.7439999580383, 68.5169999599457, 68.9869999885559, 70.1059999465942,
70.8989999294281, 71.433000087738, 71.9739999771118, 72.9900000095367,
73.7990000247955, 74.1280000209808, 75.1319999694824, 75.9210000038147,
76.4560000896454, 77.0060000419617, 78.0169999599457, 78.7950000762939,
79.2009999752045, 80.2960000038147, 81.085000038147, 81.6159999370575,
82.154000043869, 83.1719999313354, 83.960000038147, 84.3849999904633,
85.4539999961853, 86.25, 86.7869999408722, 87.3310000896454,
88.3380000591278, 89.1310000419617, 89.4570000171661, 90.4700000286102,
91.2430000305176, 91.7829999923706, 92.3220000267029, 93.3519999980927,
94.125, 94.5650000572205, 95.7239999771118, 96.5230000019073,
97.0499999523163, 97.5889999866486, 98.625, 99.4210000038147,
99.8559999465942, 100.934000015259, 101.703999996185, 102.239000082016,
102.779000043869, 103.825999975204, 104.628999948502, 105.026000022888,
106.069999933243, 106.845999956131, 107.378999948502, 107.917000055313,
108.930999994278, 109.716000080109)
value:
c(479.10215226, 479.15010973, 479.04382887, 478.96121828, 478.92773784,
478.81885903, 478.73656953, 478.68128682, 478.6261122, 478.85844051,
479.03518717, 479.1025219, 479.33309695, 479.50873458, 479.62744808,
479.74859523, 479.83062229, 479.89212617, 479.91856631, 480.00179695,
480.06601361, 480.10906271, 480.15210838, 479.89960556, 479.70206163,
479.62012341, 479.36714101, 479.17579419, 479.04360975, 478.90920312,
479.12646431, 479.29568234, 479.3840455, 479.61631255, 479.78595373,
479.90026028, 480.0162762, 480.09305768, 480.15159076, 480.18244119,
480.26459024, 480.3240335, 480.3643919, 480.40505769, 480.53912092,
480.64247714, 480.69996964, 480.83846439, 480.94102931, 481.00988704,
481.07978853, 480.73114681, 480.46181544, 480.30858754, 479.93463897,
479.66970123, 479.49149896, 479.30823314, 479.46882493, 479.59266358,
479.6437766, 479.80453027, 479.92978879, 480.01403278, 480.10016777,
480.38149338, 480.59692718, 480.68578179, 480.96245763, 481.17515461,
481.32278277, 481.46850081, 481.63006045, 481.75501361, 481.81804737,
481.9886796, 482.11171933, 482.19639813, 482.28123609, 482.42994263,
482.5419073, 482.60251994, 482.75354473, 482.86984873, 482.94723698,
483.02563203, 482.76213851, 482.56189822, 482.48252108, 482.22084432,
482.01933274, 481.88414206, 481.74639651, 482.04420074, 482.26900236,
482.40568134, 482.73107711, 482.96168337, 483.11668169, 483.27430031,
483.37630106, 483.45769965, 483.49065889, 483.59166323, 483.67096438,
483.72463471, 483.77990884, 483.86058774, 483.92253361, 483.95490772,
484.0422155, 484.105193, 484.14752095, 484.19040833, 484.2177491,
484.23888953, 484.25030659, 484.27904537, 484.30042357, 484.31484737,
484.32942842, 484.41989205, 484.49112871, 484.52041283, 484.61150306,
484.68094616, 484.72936224, 484.77778237, 485.02597763, 485.21207169,
485.31776096, 485.59678909, 485.78914165, 485.91625247, 486.04576866,
486.1223913, 486.18113401, 486.21335426, 486.29293823, 486.3498294,
486.38935835, 486.42933743, 486.40107268, 486.37939394, 486.36867389,
486.34049808, 486.31955938, 486.30517609, 486.29067372, 486.4460626,
486.56608919)
I didn't plot your data. Please take the advice from Allan Cameron seriously. It sounds like you are making a lot of assumptions that might not be correct.
If your assumption of an exponential model is correct, this problem is easy to fit using standard tools if you apply a transformation.
Instead of fitting
Ct = Cmax + (C0 - Cmax)e^-k.t
turn it into a linear equation. Subtract Cmax
from both sides (I removed your assumption of Cmax
being part of the constant multiplier):
(Ct - Cmax) = C0 * exp(-kt)
Take the natural log of both sides:
ln(Ct - Cmax) = ln(C0) - kt
Now it's a simple linear regression with data points [t, ln(Ct - Cmax)]
, intercept ln(C0)
, and slope -k
.
Decay will have a negative value for k
; growth will have a positive value for k
.
Transform you data before you run the regression. Transform it back to plot once you have the constants you need.
All that other stuff you wrote feels like constraining the solution unnecessarily. Let the regression tell you what values minimize the mean squared error. Better than guessing or assuming.
Try this and see what it tells you.
Thanks to Roland, I did a bit more work on your problem.
I plotted the data and saw what it was actually doing. The simple exponential fit I proposed was clearly inadequate.
I applied XGBoost using this code:
import numpy as np
import matplotlib.pyplot as plt
from xgboost import XGBRegressor
if __name__ == '__main__':
x_decay = np.array([
0, 0.319000005722046, 1.34500002861023, 2.11700010299683, 2.65100002288818,
3.19000005722046, 4.19700002670288, 4.99600005149841, 5.36800003051758,
6.45600008964539, 7.24600005149841, 7.77900004386902, 8.31800007820129,
9.34500002861023, 10.1370000839233, 10.4670000076294, 11.5, 12.2760000228882,
12.805999994278, 13.3450000286102, 14.3740000724792, 15.154000043869,
15.4860000610352, 16.5280001163483, 17.3090000152588, 17.8359999656677,
18.3710000514984, 19.3949999809265, 20.1770000457764, 20.4960000514984,
21.5060000419617, 22.2829999923706, 22.8120000362396, 23.3489999771118,
24.3710000514984, 25.1600000858307, 25.5910000801086, 26.6270000934601,
27.4010000228882, 27.933000087738, 28.4660000801086, 29.5030000209808,
30.2890000343323, 30.7009999752045, 31.779000043869, 32.5820000171661,
33.1150000095367, 33.654000043869, 34.6840000152588, 35.4760000705719,
35.8810000419617, 36.9430000782013, 37.7360000610352, 38.2720000743866,
38.8129999637604, 39.8580000400543, 40.6440000534058, 41.143000125885,
42.2030000686646, 42.9730000495911, 43.5090000629425, 44.0510001182556,
45.0810000896454, 45.8849999904633, 46.3410000801086, 47.489000082016,
48.2690000534058, 48.8029999732971, 49.3389999866486, 50.3910000324249,
51.1670000553131, 51.5680000782013, 52.6310000419617, 53.4200000762939,
53.9509999752045, 54.4900000095367, 55.5329999923706, 56.3359999656677,
56.7369999885559, 57.7990000247955, 58.5840001106262, 59.1170001029968,
59.6640000343323, 60.6840000152588, 61.4760000705719, 61.8550000190735,
62.9400000572205, 63.7200000286102, 64.2530000209808, 64.7860000133514,
65.819000005722, 66.6040000915527, 66.9509999752045, 67.9820001125336,
68.7590000629425, 69.3020000457764, 69.8510000705719, 70.8740000724792,
71.6640000343323, 72.0420000553131, 73.1370000839233, 73.9200000762939,
74.4609999656677, 75.0069999694824, 76.0460000038147, 76.8380000591278,
77.2450001239777, 78.319000005722, 79.1080000400543, 79.643000125885,
80.1840000152588, 81.194000005722, 81.9690001010895, 82.2920000553131,
83.3320000171661, 84.143000125885, 84.6770000457764, 85.2160000801086,
86.239000082016, 87.029000043869, 87.4340000152588, 88.5099999904633,
89.3050000667572, 89.8410000801086, 90.3740000724792, 91.3900001049042,
92.1610000133514, 92.6240000724792, 93.7190001010895, 94.5420000553131,
95.0720000267029, 95.614000082016, 96.654000043869, 97.4379999637604,
97.7630000114441, 98.7920000553131, 99.5680000782013, 100.101000070572,
100.638000011444, 101.667999982834, 102.457000017166, 102.848999977112,
103.946000099182, 104.740000009537, 105.272000074387, 105.808000087738,
106.844000101089, 107.647000074387, 107.97200012207, 108.999000072479,
109.77999997139], dtype=float).reshape(-1, 1)
y_decay = np.array([
391.12411366, 391.08100717, 390.94243548, 390.83830459, 390.76617733,
390.69324728, 390.38999998, 390.14939786, 390.0376815, 389.70998253,
389.47173279, 389.31119461, 389.1491491, 389.21559469, 389.26671895,
389.28811414, 389.3549619, 389.40510954, 389.43947037, 389.47427918,
389.04703391, 388.72275693, 388.5853234, 388.15268327, 387.82841051,
387.60917928, 387.38704258, 387.20998907, 387.07478506, 387.01980882,
386.84510585, 386.71052183, 386.61901005, 386.52612006, 386.15278149,
385.86492592, 385.70711689, 385.32912046, 385.04607945, 384.85214866,
384.65748181, 384.39117228, 384.18906771, 384.08326961, 383.80669132,
383.60021075, 383.46332154, 383.32514566, 382.76278914, 382.33080345,
382.10990354, 381.53119168, 381.09810866, 380.80629565, 380.51067106,
380.3812077, 380.28383162, 380.22213205, 380.09077494, 379.99536022,
379.92893917, 379.86177495, 379.21853896, 378.71581941, 378.4316801,
377.71482389, 377.22775015, 376.89366803, 376.55895926, 377.0199162,
377.36026046, 377.53657392, 378.00229948, 378.348741, 378.58160228,
378.81753244, 378.66982901, 378.55622193, 378.49948823, 378.34930228,
378.2384323, 378.16305767, 378.08556017, 377.89134515, 377.74039492,
377.66796687, 377.46130847, 377.31261093, 377.21080971, 377.109201,
376.74048636, 376.4606496, 376.33643738, 375.96886698, 375.69122412,
375.49779962, 375.30187551, 374.88554136, 374.56362855, 374.41020185,
373.96452629, 373.64583614, 373.42523778, 373.20301263, 372.95689249,
372.76951615, 372.67310562, 372.41842969, 372.23150586, 372.10499108,
371.97682247, 372.03639454, 372.08200686, 372.10103861, 372.1623518,
372.21017149, 372.24172397, 372.27350753, 372.17008905, 372.0901371,
372.04914205, 371.94011178, 371.85974481, 371.80549687, 371.75144937,
371.54387045, 371.38618534, 371.29149218, 371.06752863, 370.89899399,
370.79059479, 370.67995194, 370.22531351, 369.8821446, 369.74050264,
369.29024288, 368.95146194, 368.7184661, 368.48371741, 368.24428629,
368.06129047, 367.9700323, 367.71544758, 367.53099783, 367.4071743,
367.28288322, 367.69518211, 368.01515944, 368.14410924, 368.5533401,
368.86423517], dtype=float)
x_growth = np.array([
0, 0.552999973297119, 1.57200002670288, 2.36500000953674, 2.68499994277954,
3.73000001907349, 4.51900005340576, 5.04900002479553, 5.57800006866455,
6.62599992752075, 7.42400002479553, 7.72900009155273, 8.76999998092651,
9.56200003623962, 10.0989999771118, 10.6449999809265, 11.6719999313354,
12.4430000782013, 12.7730000019073, 13.8159999847412, 14.6189999580383,
15.1579999923706, 15.6970000267029, 16.7170000076294, 17.5160000324249,
17.845999956131, 18.8680000305176, 19.6410000324249, 20.1749999523163,
20.7179999351501, 21.7309999465942, 22.5199999809265, 22.933000087738,
24.0160000324249, 24.805999994278, 25.3389999866486, 25.8810000419617,
26.8980000019073, 27.6740000247955, 28.0829999446869, 29.1719999313354,
29.960000038147, 30.4960000514984, 31.0350000858307, 32.0599999427795,
32.8519999980927, 33.2920000553131, 34.3519999980927, 35.1370000839233,
35.6640000343323, 36.1979999542236, 37.2309999465942, 38.029000043869,
38.4830000400543, 39.5920000076294, 40.3759999275208, 40.904000043869,
41.4470000267029, 42.4660000801086, 43.25, 43.5750000476837,
44.5929999351501, 45.3880000114441, 45.9210000038147, 46.4670000076294,
47.4969999790192, 48.2850000858307, 48.6089999675751, 49.6219999790192,
50.3989999294281, 50.9400000572205, 51.4730000495911, 52.4869999885559,
53.2730000019073, 53.6679999828339, 54.7400000095367, 55.5130000114441,
56.0460000038147, 56.5789999961853, 57.6059999465942, 58.3810000419617,
58.7990000247955, 59.8429999351501, 60.6480000019073, 61.183000087738,
61.7239999771118, 62.7530000209808, 63.5360000133514, 63.8450000286102,
64.8680000305176, 65.654000043869, 66.183000087738, 66.7200000286102,
67.7439999580383, 68.5169999599457, 68.9869999885559, 70.1059999465942,
70.8989999294281, 71.433000087738, 71.9739999771118, 72.9900000095367,
73.7990000247955, 74.1280000209808, 75.1319999694824, 75.9210000038147,
76.4560000896454, 77.0060000419617, 78.0169999599457, 78.7950000762939,
79.2009999752045, 80.2960000038147, 81.085000038147, 81.6159999370575,
82.154000043869, 83.1719999313354, 83.960000038147, 84.3849999904633,
85.4539999961853, 86.25, 86.7869999408722, 87.3310000896454,
88.3380000591278, 89.1310000419617, 89.4570000171661, 90.4700000286102,
91.2430000305176, 91.7829999923706, 92.3220000267029, 93.3519999980927,
94.125, 94.5650000572205, 95.7239999771118, 96.5230000019073,
97.0499999523163, 97.5889999866486, 98.625, 99.4210000038147,
99.8559999465942, 100.934000015259, 101.703999996185, 102.239000082016,
102.779000043869, 103.825999975204, 104.628999948502, 105.026000022888,
106.069999933243, 106.845999956131, 107.378999948502, 107.917000055313,
108.930999994278, 109.716000080109], dtype=float).reshape(-1, 1)
y_growth = np.array([
479.10215226, 479.15010973, 479.04382887, 478.96121828, 478.92773784,
478.81885903, 478.73656953, 478.68128682, 478.6261122, 478.85844051,
479.03518717, 479.1025219, 479.33309695, 479.50873458, 479.62744808,
479.74859523, 479.83062229, 479.89212617, 479.91856631, 480.00179695,
480.06601361, 480.10906271, 480.15210838, 479.89960556, 479.70206163,
479.62012341, 479.36714101, 479.17579419, 479.04360975, 478.90920312,
479.12646431, 479.29568234, 479.3840455, 479.61631255, 479.78595373,
479.90026028, 480.0162762, 480.09305768, 480.15159076, 480.18244119,
480.26459024, 480.3240335, 480.3643919, 480.40505769, 480.53912092,
480.64247714, 480.69996964, 480.83846439, 480.94102931, 481.00988704,
481.07978853, 480.73114681, 480.46181544, 480.30858754, 479.93463897,
479.66970123, 479.49149896, 479.30823314, 479.46882493, 479.59266358,
479.6437766, 479.80453027, 479.92978879, 480.01403278, 480.10016777,
480.38149338, 480.59692718, 480.68578179, 480.96245763, 481.17515461,
481.32278277, 481.46850081, 481.63006045, 481.75501361, 481.81804737,
481.9886796, 482.11171933, 482.19639813, 482.28123609, 482.42994263,
482.5419073, 482.60251994, 482.75354473, 482.86984873, 482.94723698,
483.02563203, 482.76213851, 482.56189822, 482.48252108, 482.22084432,
482.01933274, 481.88414206, 481.74639651, 482.04420074, 482.26900236,
482.40568134, 482.73107711, 482.96168337, 483.11668169, 483.27430031,
483.37630106, 483.45769965, 483.49065889, 483.59166323, 483.67096438,
483.72463471, 483.77990884, 483.86058774, 483.92253361, 483.95490772,
484.0422155, 484.105193, 484.14752095, 484.19040833, 484.2177491,
484.23888953, 484.25030659, 484.27904537, 484.30042357, 484.31484737,
484.32942842, 484.41989205, 484.49112871, 484.52041283, 484.61150306,
484.68094616, 484.72936224, 484.77778237, 485.02597763, 485.21207169,
485.31776096, 485.59678909, 485.78914165, 485.91625247, 486.04576866,
486.1223913, 486.18113401, 486.21335426, 486.29293823, 486.3498294,
486.38935835, 486.42933743, 486.40107268, 486.37939394, 486.36867389,
486.34049808, 486.31955938, 486.30517609, 486.29067372, 486.4460626,
486.56608919], dtype=float)
# Define and train XGBoost models
xgb_decay = XGBRegressor(objective='reg:squarederror', n_estimators=100)
xgb_decay.fit(x_decay, y_decay)
y_fit_decay = xgb_decay.predict(np.linspace(0, 110, 110).reshape(-1, 1))
xgb_growth = XGBRegressor(objective='reg:squarederror', n_estimators=100)
xgb_growth.fit(x_growth, y_growth)
y_fit_growth = xgb_growth.predict(np.linspace(0, 110, 110).reshape(-1, 1))
# Plot results
plt.figure(figsize=(10, 5))
# Decay plot
plt.subplot(1, 2, 1)
plt.scatter(x_decay, y_decay, label='Data', color='blue')
plt.plot(np.linspace(0, 110, 110), y_fit_decay, label='XGBoost Fit', color='red')
plt.title('XGBoost Decay Fit')
plt.legend()
# Growth plot
plt.subplot(1, 2, 2)
plt.scatter(x_growth, y_growth, label='Data', color='green')
plt.plot(np.linspace(0, 110, 110), y_fit_growth, label='XGBoost Fit', color='red')
plt.title('XGBoost Growth Fit')
plt.legend()
plt.show()
It produced these two plots. It looks like XGBoost did a great job of fitting the data - perhaps too good. It's certainly overfitting. I don't know if you have more data, or made any effort to split the data you have into train, validation, and test sets. You probably won't have much luck extrapolating accurately beyond t = 110.
I don't know what getting the parameters out of it would look like.