Installation

PyTorch-BSF requires Python 3.10 or later. Install it from PyPI:

pip install pytorch-bsf

This installs only the required dependencies: PyTorch, NumPy and PyYAML. They are enough to fit a model with the default solver (solver="lstsq") or with torch_bsf.fit_sgd(), to predict, to save and load models, and to run the CLI (python -m torch_bsf) without experiment tracking.

The Docker image and the MLflow project install PyTorch-BSF with Lightning and MLflow, so they need neither the lightning nor the mlflow extra below; they do not include the packages of the other extras (SciPy, scikit-learn and matplotlib).

Optional extras

Other features need more packages, which the following extras install. Pick the extras for the features you use, or all for every feature:

pip install "pytorch-bsf[lightning]"
pip install "pytorch-bsf[lightning,mlflow]"
pip install "pytorch-bsf[all]"

Extra

Packages

Features

lightning

lightning

Training with the Lightning trainer: solver="trainer" in torch_bsf.fit() and BezierSimploidRegressor, and --solver=trainer on the command line, including GPUs and distributed training (see Hardware Acceleration). Without it, solver="trainer" raises ImportError.

mlflow

mlflow

Logging the CLI runs to MLflow (--loglevel): python -m torch_bsf logs the parameters, metrics and models, and python -m torch_bsf.model_selection.kfold logs the errors of each fold and their means. Without it, the CLI still fits and saves its outputs (the control points or the predictions), but prints a warning and logs nothing.

sampling

scipy

Quasi-random Sobol sampling with torch_bsf.sampling.simplex_sobol() (see Advanced Sampling).

sklearn

scikit-learn

The scikit-learn estimator BezierSimploidRegressor (see Scikit-learn Integration).

plot

matplotlib, scipy

Plotting fitted models with torch_bsf.plotting (see Bézier Simplex and Simploid Visualization).

all

All of the above

Every feature above.

develop

ruff, pytest, mypy, etc.

Tools to develop PyTorch-BSF itself (linting, type checking and testing); see CONTRIBUTING.md.

For example, to train BezierSimploidRegressor with solver="trainer", install pip install "pytorch-bsf[sklearn,lightning]".

Upgrading from a version that required Lightning and MLflow

Up to version 0.19.0, installing PyTorch-BSF also installed Lightning and MLflow. In later versions they are optional, so upgrading with pip install -U pytorch-bsf alone may change what your code does:

To keep the behavior of the earlier versions, upgrade with both extras:

pip install -U "pytorch-bsf[lightning,mlflow]"

If Lightning and MLflow are already in your environment (e.g., left by the earlier version), PyTorch-BSF keeps using them, but listing the extras records that your project needs them. Code that uses only the default solver="lstsq" or torch_bsf.fit_sgd() and does not log to MLflow needs no extra.