Commit Graph

21 Commits

Author SHA1 Message Date
Alejandro Martinez
ee992ad130 Enable Performance Tests for CV charts
Show them in CV charts and use them for fitting,
just like they work in CP charts.
2024-09-19 21:27:51 -03:00
Alejandro Martinez
326e5ff46d Enable translation of model fit summary in CP Chart 2022-02-14 15:39:14 -03:00
Ale Martinez
ea548695b6 deriveExtCPParameters - Initial estimates setup after data verification
deriveExtCPParameters established Initial parameters estimates before
the data verification steps so when data don't meet the minimum
criteria for estimation those initial parameters are returned.
This change moves the initialization step after data verification,
similar to what deriveCPParameters does for the envelope fitting case.
Fixes #3862
2021-04-15 12:21:45 -03:00
Mark Liversedge
323a97fb40 DataFilter - lm()
.. lm(formula, xlist, ylist) - fits a formula to the x,y data using
   the levenberg-marquardt OLS algorithm.

   the formula is expressed as any other expression and the starting
   values must be set beforehand- this is also reinforced by the fact
   the parameters must exist before the formula is declared.

   the fit returns a vector [ success, RMSE, CV).

.. an example, to fit the morton 3p model to meanmax would be:

   # fetch mmp data
   mmp <- meanmax(POWER);
   secs <- seq(1,length(mmp),1);

   # set starting values, then fit Morton 3p to first 20 min data
   cp <- 200; W<-11000; pmax <- 1000;
   fit <- lm((W / (x - (W/(cp-pmax)))) + cp,
             head(secs,1200),
             head(mmp,1200));

.. along the way I needed to refactor the way lmfit is managed and
   also corrected banister to avoid threading issues.

.. also snuck in a sqrt() function as needed for testing and was
   rather an egregious oversight.
2020-03-18 21:06:24 +00:00
Mark Liversedge
7b659e69d8 Add CV alongside RMSE on CP Chart
.. seems silly to not do it, and its relatively useful when comparing
   the different model fits.
2019-07-07 13:33:17 +01:00
Mark Liversedge
0b4d46666d Model CP and W' decay in Morton Model
.. add option to apply a decay factor to CP and W' when plotting
   the model curve in CP Plot.

.. since we always fit to observations <20mins the mostly submax
   points at longer durations in the general population do not
   impact the fit at all.

.. the decay factors for w' and cp have been fit to the results of:

   Effects of Two Hours of Heavy-Intensity Exercise on the Power-
Duration Relationship
   Clark IE, Vanhatalo A, Bailey SJ, Wylie LJ, Kirby BS, Wilkins BW,
Jones AM.
   https://europepmc.org/abstract/med/29521722
2018-11-30 15:56:52 +00:00
Mark Liversedge
b5ed04b7c1 CP Plot show w/kg percentiles
.. should also add 3,7,12,20 concrete percentiles so can review
   regardless of model fit.
2018-11-03 19:21:27 +00:00
Mark Liversedge
50f77a3391 Parameter percentile off by one
.. if you're better than 10% of folks you're not in the 10% percentile.
2018-10-27 12:31:22 +01:00
Mark Liversedge
9fb73099a9 CP Plot Percentiles for CP, W' and Pmax Estimates
.. using analysis from the opendata proejct we have now
   got a normal distribution for CP, W' and Pmax parameters.

.. so we can now plot the percentiles on the CP plot that the
   user's values sit in.
2018-10-27 11:47:15 +01:00
Mark Liversedge
672a16d6fd R2 label use superscript (its squared not 2) 2018-09-25 10:38:34 +01:00
Mark Liversedge
2a6083071f LR Model Fit calculate R2
.. lots of folks understand what R2 means for a linear
   regression so calculate it alongside RMSE when we
   are performing a linear regression.
2018-08-25 07:47:23 +01:00
Mark Liversedge
8a64b65ebb Linear Regress for Work/Time Model Fit
.. add fitting option to fit CP2 model to points using
   a linear regress.

.. kinda ironic that the most common and straight forward
   method for estimating CP/W' is added so late.
2018-08-17 18:39:16 +01:00
Mark Liversedge
39269cb5ca Extended CP Model Search Intervals
.. slight tweak to aerobic interval to match the 7-20min
   interval used by CP2/CP3 and to reflect best practice.
2018-08-12 15:57:41 +01:00
Mark Liversedge
3384114bdc CP 2/3p model interval defaults
.. change the default intervals within the models - these
   are used when estimating automatically via envelope and
   were too long.

.. truncated the data used by the models to avoid using
   MMP data beyond 20 minutes for 2/3p model.

.. results in much more robust estimates in CP History.
2018-08-09 15:59:32 +01:00
Mark Liversedge
7ff5a970df Disable WS/Velo models
.. the fit is wrong and need to look at that
   more closely.

.. in the meantime disabled in CPPlot.
2018-08-07 16:23:55 +01:00
Mark Liversedge
d4cb586850 CP Chart Modelling Improvements
.. CP plot modelling will fallback when insufficient data
   is available to model reliably, with a precedence:

      1. Performance tests
      2. Filtered MMP
      3. All MMP

.. when modelling for a single ride collect bests/performance
   data for the period up to that ride.

   This is so as you select older rides the model reflects the
   training status at that ride, not for the current period.

.. add adhoc season for 'Last 6 weeks' since it is a common
   timeframe to use when tracking impact of training
2018-08-05 12:31:11 +01:00
Mark Liversedge
c79565cbdd Better CP Plot Fit Summary
.. tell user what fit or data was used as there is a cascade back
   depending on the model selected and the availability of data.

.. the summary is also now in grey to indicate it is supplementary.
2018-08-03 12:14:39 +01:00
Mark Liversedge
54b161261e CP plot show info about fit
.. RMSE for now, just to get a basic sense

.. what type of fit was performed (since there is a fallback)

.. how many datapoints were used in the fit and RMSE calculation.
2018-08-02 21:30:24 +01:00
Mark Liversedge
f5055aa0e3 Add LMFIT source to repo
.. makes compilation easier and removes a dependency
   for what is effectively 2 C-source files.

.. additionally, getting the lmfit lib to compile
   on windows with cmake was frought with issues.

.. also fix a debug message left behind by previous
   commit.
2018-05-23 11:24:04 +01:00
Mark Liversedge
ba9bab3993 Add Least-Squares fit to CP Chart - 1 of 2
.. adding an option to select least squares fit to the cp
   chart, in addition to the existing envelope fit.

.. additionally, if filter bests option has been selected
   the least squares fit will use these points rather than
   all the points (since well over 95% will be submaximal).

.. It requires the lmfit library to be available - and this
   has been an non-optional install for over a year - we
   just haven't used it prior to this commit.

.. Each PD model needs to implement three functions to enable
   the least squares fit to work:

   * int nparms() - returns the number of parameters
   * double f(double t, double *parms) - parametric function
   * bool setParms(double *parms) - set the parameters post fit

.. This commit implements it for CP derivatives;
   * Classic CP - 2 parameter model
   * Morton 3 Parameter - 3 parameter model
   * GC Extended CP model - the extended model

   BUT: it is implemented and disabled for eCP for now until
        we can set parameter constraints correctly.

.. A second commit is needed for the remaining models from
   Ward Smith and Mike P. This should also show which of the
   filtered points have been used for curve fitting on the
   chart (maybe a different color)
2018-05-20 18:40:51 +01:00
Mark Liversedge
4b5201c4c5 Restructure source directory
Introducing a directory structure to make it a bit less
daunting for new developers and perhaps even old hands.

The main folders all start with an upper character, so src
files are now located in;

* Core - Core data structures
* Gui - Main GUI elements
* Metrics - Models and Metrics
* FileIO - Device and File I/O
* Charts - All the chart types
* Cloud - Working with Web Resources
* Train - Anything Train View specific
* ANT - Our ANT+ Stack
* Resources - Images, Translations, Web etc

Apologies to anyone who needs to merge across this update.
2016-02-25 14:51:53 +00:00