Multiple-target machine learning
Project description
Himalaya implements machine learning linear models in Python, focusing on computational efficiency for large numbers of targets.
Use himalaya if you need a library that:
estimates linear models on large numbers of targets,
runs on CPU and GPU hardware,
provides estimators compatible with scikit-learn’s API.
Example
import numpy as np
n_samples, n_features, n_targets = 10, 5, 4
np.random.seed(0)
X = np.random.randn(n_samples, n_features)
Y = np.random.randn(n_samples, n_targets)
from himalaya.ridge import RidgeCV
model = RidgeCV(alphas=[1, 10, 100])
model.fit(X, Y)
print(model.best_alphas_) # [ 10. 100. 10. 100.]
The model RidgeCV uses the same API as scikit-learn estimators, with methods such as fit, predict, score, etc.
The model is able to efficiently fit a large number of targets (routinely used with 100k targets).
The model selects the best hyperparameter alpha for each target independently.
Check more examples of use of himalaya in the gallery of examples.
Models
Himalaya implements the following models:
Ridge
RidgeCV
GroupRidgeCV
KernelRidge
KernelRidgeCV
WeightedKernelRidge
MultipleKernelRidgeCV
SparseGroupLassoCV
Himalaya backends
Himalaya can be used seamlessly with different backends. The available backends are numpy (default), cupy, and pytorch. To change the backend (e.g. to cupy), call:
from himalaya.backend import set_backend
backend = set_backend("cupy")
and give cupy arrays inputs to the himalaya solvers. For convenience, estimators implementing scikit-learn’s API can cast arrays to the correct input type.
GPU acceleration
To run himalaya on a graphics processing unit (GPU), you can use both cupy or pytorch backends.
To use the cupy backend, call:
from himalaya.backend import set_backend
backend = set_backend("cupy")
data = backend.asarray(data) # cupy arrays are always on GPU
To use the pytorch backend, call:
from himalaya.backend import set_backend
set_backend("torch")
data = backend.asarray(data) # torch tensors are on CPU by default...
data = data.cuda() # ...and you can move them to GPU with the `cuda` method.
# or directly use
set_backend("torch_cuda")
data = backend.asarray(data)
Installation
Dependencies
Himalaya requires:
Python 3
Numpy
Scikit-learn
PyTorch (optional GPU backend)
Cupy (optional GPU backend)
Matplotlib (optional, for visualization only)
Pytest (optional, for testing only)
Standard installation
You may install the latest version of himalaya using the package manager pip, which will automatically download himalaya from the Python Package Index (PyPI):
pip install himalaya
Installation from source
To install himalaya from the latest source (main branch), you may call:
pip install git+https://github.com/gallantlab/himalaya.git
Developers can also install himalaya in editable mode via:
git clone https://github.com/gallantlab/himalaya
cd himalaya
pip install --editable .
Cite this package
If you use himalaya in your work, please cite our (future) publication:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file himalaya-0.3.1.tar.gz
.
File metadata
- Download URL: himalaya-0.3.1.tar.gz
- Upload date:
- Size: 94.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9cc74c4bc02b534645b37ef9b8a9e6b69ecfa447f5ac5f5167b8ed0ca0d0ba7 |
|
MD5 | ed5ac8eb1fe381b390b8b70487019189 |
|
BLAKE2b-256 | 49530483efc24455106cd0e29f17751b8c7fd57d6aba17f7677f96173ba43346 |
File details
Details for the file himalaya-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: himalaya-0.3.1-py3-none-any.whl
- Upload date:
- Size: 75.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cc45b74632ef9cc6df705893ea1c632449ac91d92385e8323b670e17ae7bdb6 |
|
MD5 | bd57b44d81749ead426a49f9143784dd |
|
BLAKE2b-256 | 3f360eb9da747ff7841d058fe756babd17a2a0ab5dfd12e7f9444268500501f9 |