Skip to main content

PyPI - Version GitHub Actions Workflow Status GitHub License

forthebadge forthebadge

lactate-thresholds

A Python package to analyze lactate values and corresponding thresholds. Typically useful in a context when used to determine workout zones.

Test out the UI here.

Installation

pip install lactate_thresholds
# OR
uv add lactate_thresholds
# OR 
# install command for whatever package manager you use

Basic usage

You will need a dataframe that holds your measurement values. Let's start by importing an example dataframe.

import lactate_thresholds as lt
from lactate_thresholds.data import example_data_cycling

df = example_data_cycling()
df
   step  length  intensity  rel_power  heart_rate  lactate_4  lactate_8  cadence  rpe
0     1       8        100        1.3         113        1.0        1.0      102    6
1     2       8        140        1.8         126        1.0        1.0      100    7
2     3       8        180        2.3         137        0.9        0.9      100   10
3     4       8        220        2.8         151        1.0        1.0       98   12
4     5       8        260        3.3         168        1.9        1.9       98   16
5     6       8        300        3.8         181        3.3        3.8       94   18
6     7       8        340        4.3         190        6.4        7.5       92   19

Note that the only cols required are step, length, intensity, heart_rate and lactate. If your columns are not correctly named (in this example the lactate column is missing), you can specify the correct name in the following steps.

results = lt.determine(df, lactate_col='lactate_8')

The above determine function is a convenience function that runs (in the following order):

  • lactate_thresholds.clean_data(df)
  • lactate_thresholds.interpolate(df_clean)
  • lactate_thresholds.methods.determine_ltp(df_clean, df_interpolated)
  • lactate_thresholds.methods.determine_mod_dmax(df_clean, df_interpolated)
  • lactate_thresholds.methods.determine_loglog(df_clean, df_interpolated)
  • lactate_thresholds.methods.determine_obla(df_interpolated, 2)
  • lactate_thresholds.methods.determine_obla(df_interpolated, 4)
  • lactate_thresholds.methods.determine_baseline(df_clean, df_interpolated, 0)
  • lactate_thresholds.types.LactateThresholdResults.calc_lt1_lt2_estimates()

The returned object is an instance of LactateThresholdResults which looks more or less like:

class LactateThresholdResults(BaseModel):
    clean_data: pd.DataFrame
    interpolated_data: pd.DataFrame
    ltp1: LactateTurningPoint | None = None
    ltp2: LactateTurningPoint | None = None
    mod_dmax: ModDMax | None = None
    loglog: LogLog | None = None
    baseline: BaseLinePlus | None = None
    obla_2: OBLA | None = None
    obla_4: OBLA | None = None
    lt1_estimate: ThresholdEstimate | None = None
    lt2_estimate: ThresholdEstimate | None = None

Plotting

Some basic plotting functionalities implemented in Altair are present, most notably:

  • lactate_thresholds.plot.lactate_intensity_plot
  • lactate_thresholds.plot.heart_rate_intensity_plot

For example:

lactate intensity plot

Zone calculation

Basic zone calculations (yet to be verified) are available at:

  • lactate_thresholds.zones.seiler_3_zones
  • lactate_thresholds.zones.seiler_5_zones
  • lactate_thresholds.zones.friel_7_zones_running

Streamlit app

There is a minimal streamlit app built in that you can use to interactively analyse your data.

The app is available through a script. Run it as follows (to be tested after first deploy to pypi):

pipx install lactate_thresholds
lt_app

# OR
uv tool install lactate_thresholds
lt_app

Note that a Dockerfile is also available that runs the streamlit app.

streamlit app

Acknowledgements

A big shout out to lactater that most definitely served as a strong inspiration for this package.

Metadata

Release files for lactate-thresholds 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lactate-thresholds 0.3.8
File Size Uploaded Provenance Actions
lactate_thresholds-0.3.8.tar.gz 452.4 kB Without provenance Details for lactate_thresholds-0.3.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lactate-thresholds 0.3.8
File Interpreter ABI Platform Actions
lactate_thresholds-0.3.8-py3-none-any.whl Python 3 none any Details for lactate_thresholds-0.3.8-py3-none-any.whl

Total release size: 467.8 kB

Release files / lactate_thresholds-0.3.8.tar.gz

Download URL lactate_thresholds-0.3.8.tar.gz
Size 452.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8a4354a51dc15eaed4b59fb02882a61c5b1948320d917362643d2ee39ff718d7
BLAKE2b-256 checksum
How to use checksums
7dd279c96dec52a7a0e69b4fe6015186bfa7e06089be499ffc63aaf365829b04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.7

Release files / lactate_thresholds-0.3.8-py3-none-any.whl

Download URL lactate_thresholds-0.3.8-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6a27e9ae0c1208d977ff894fb67dc35a409dd9778d48aa10754ad2094f811ca
BLAKE2b-256 checksum
How to use checksums
419e13e0263abc2d6b8e5f331e43aa09c695e413a18aedeae69638e5879e3453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.7

Security for lactate-thresholds 0.3.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page