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 |
|---|---|---|
|
|
Training with the Lightning trainer: |
|
|
Logging the CLI runs to MLflow ( |
|
|
Quasi-random Sobol sampling with |
|
|
The scikit-learn estimator |
|
|
Plotting fitted models with |
|
All of the above |
Every feature above. |
|
|
Tools to develop PyTorch-BSF itself (linting, type checking and testing); see |
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:
Code that uses
solver="trainer"(intorch_bsf.fit(),torch_bsf.fit_kfold(),BezierSimploidRegressoror the automatic degree selection) or--solver=traineron the command line raisesImportError. Install thelightningextra.The CLI (
python -m torch_bsfandpython -m torch_bsf.model_selection.kfold) stops logging to MLflow and prints a warning instead. Install themlflowextra.
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.