Installation¶
Requirements¶
- Python: 3.9 or higher (the minimum supported by PyTorch 2.5)
- PyTorch: 2.5 or higher (
torch>=2.5.1inrequirements.txt) - NumPy: for numerical operations
- SciPy: special functions and distributions (the von Mises-Fisher Bessel functions, chi-squared quantiles, Hungarian label matching)
- Matplotlib and seaborn:
tgmm.plotting, whichimport tgmmloads - tqdm: progress bars in
HDBSCAN
import tgmm imports all of the above at start-up, so all must be installed. If a plain pip install tgmm does
not pull them in automatically, install them explicitly:
Installation Methods¶
From PyPI (Recommended)¶
The easiest way to install tgmm is using pip:
This will install the latest stable release along with all required dependencies.
From Source (Development)¶
For the latest features or if you want to contribute:
# Clone the repository
git clone https://github.com/adriansousapoza/tgmm.git
cd tgmm
# Install in editable mode
pip install -e .
The -e flag installs in editable mode, so changes to the source code are immediately available.
With GPU Support¶
tgmm automatically uses CUDA if available. To enable GPU acceleration:
-
Install CUDA-enabled PyTorch following the official PyTorch installation guide
-
Verify CUDA availability:
-
Use GPU in tgmm:
Optional Dependencies¶
For running the tutorial notebooks (scikit-learn is used by some notebooks for datasets and PCA, pandas for the
select_model(...).to_dataframe() tables):
pip install jupyter scikit-learn pandas tqdm
# from a source checkout, the "examples" extra installs tqdm and pandas:
pip install -e ".[examples]"
For running the test suite (mpmath supplies reference Bessel values for the von Mises-Fisher tests):
For building this documentation:
pip install -e ".[docs]" # mkdocs, mkdocs-material, mkdocstrings, mkdocs-jupyter, pymdown-extensions
mkdocs serve
Verification¶
Verify your installation:
import tgmm
print(f"tgmm version: {tgmm.__version__}")
# Test basic functionality
from tgmm import GaussianMixture
import torch
X = torch.randn(100, 2)
gmm = GaussianMixture(n_components=3, n_features=2)
gmm.fit(X)
labels = gmm.predict(X)
print(f"Fitted GMM with {gmm.n_components} components")
print(f"Converged: {gmm.converged_}")
Troubleshooting¶
Import Errors¶
If you encounter import errors:
# Ensure all dependencies are installed
pip install torch numpy scipy matplotlib seaborn tqdm
# Reinstall tgmm
pip uninstall tgmm
pip install tgmm
CUDA Errors¶
If you have CUDA-related issues:
-
Check PyTorch CUDA installation:
-
Fall back to CPU:
Version Conflicts¶
If you have version conflicts with dependencies:
# Create a fresh virtual environment
python -m venv tgmm_env
source tgmm_env/bin/activate # On Windows: tgmm_env\Scripts\activate
# Install tgmm
pip install tgmm
Next Steps¶
- Quick Start Guide - Fit your first model
- User Guide - The models and the mathematics behind them
- Tutorials - Runnable notebooks
- API Reference - Complete API documentation