Skip to main content

Multiple-target machine learning

Project description

Himalaya: Multiple-target linear models

Github Python License Build Codecov Downloads

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.

Himalaya is stable (with particular care for backward compatibility) and open for public use (give it a star!).

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.

Tutorials using himalaya for fMRI

Himalaya was designed primarily for functional magnetic resonance imaging (fMRI) encoding models. In depth tutorials about using himalaya for fMRI encoding models can be found at gallantlab/voxelwise_tutorials.

Models

Himalaya implements the following models:

  • Ridge, RidgeCV

  • KernelRidge, KernelRidgeCV

  • GroupRidgeCV, MultipleKernelRidgeCV, WeightedKernelRidge

  • SparseGroupLassoCV

See the model descriptions in the documentation website.

Himalaya backends

Himalaya can be used seamlessly with different backends. The available backends are numpy (default), cupy, torch, and torch_cuda. To change the backend, call:

from himalaya.backend import set_backend
backend = set_backend("torch")

and give torch 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 either the cupy or the torch_cuda backend:

from himalaya.backend import set_backend
backend = set_backend("cupy")  # or "torch_cuda"

data = backend.asarray(data)

Installation

Dependencies

  • Python 3

  • Numpy

  • Scikit-learn

Optional (GPU backends):

  • PyTorch (1.9+ preferred)

  • Cupy

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 give it a star and cite our (future) publication:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

himalaya-0.3.5.tar.gz (68.6 kB view details)

Uploaded Source

Built Distribution

himalaya-0.3.5-py3-none-any.whl (81.3 kB view details)

Uploaded Python 3

File details

Details for the file himalaya-0.3.5.tar.gz.

File metadata

  • Download URL: himalaya-0.3.5.tar.gz
  • Upload date:
  • Size: 68.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for himalaya-0.3.5.tar.gz
Algorithm Hash digest
SHA256 15fc2ca398e546feff2cca23aa7a54776a3406596ced2e1f295b75ae3b469777
MD5 ad90376739489c5c38a194a15b40bcb9
BLAKE2b-256 7179552f45d78779a1971d3449bebb00815ac483ccab03b2112400d7caa7af0d

See more details on using hashes here.

File details

Details for the file himalaya-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: himalaya-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 81.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for himalaya-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 05961eca140b01b414d06918ba345c4314a229f550e6eb84c454b145ab3c77e7
MD5 6a088dbf33c495ebac8110b48f7830ad
BLAKE2b-256 5d0e5ef74abdd2c1283b1e3b23d917466b551adcea9792e9ab8932e2f2af4158

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page