An implementation of the most common partial least squares algorithms as multi-block methods
Project description
An easy to use Python package for (Multiblock) Partial Least Squares prediction modelling of univariate or multivariate outcomes. Four state of the art algorithms have been implemented and optimized for robust performance on large data matrices. The package has been designed to be able to handle missing data, such that application is straight forward using the commonly known Scikit-learn API and its model selection toolbox.
The documentation is available at https://mbpls.readthedocs.io and elaborate (real-world) Jupyter Notebook examples can be found at https://github.com/DTUComputeStatisticsAndDataAnalysis/MBPLS/tree/master/examples
This package can be cited using the following reference.
Baum et al., (2019). Multiblock PLS: Block dependent prediction modeling for Python. Journal of Open Source Software, 4(34), 1190
Installation
- Install the package for Python3 using the following command. Some dependencies might require an upgrade (scikit-learn, numpy and scipy).$ pip install mbpls
- Now you can import the MBPLS class by typingfrom mbpls.mbpls import MBPLS
Quick Start
Use the mbpls package for Partial Least Squares (PLS) prediction modeling
import numpy as np
from mbpls.mbpls import MBPLS
num_samples = 40
num_features = 200
# Generate random data matrix X
x = np.random.rand(num_samples, num_features)
# Generate random reference vector y
y = np.random.rand(num_samples,1)
# Establish prediction model using 2 latent variables (components)
pls = MBPLS(n_components=2)
pls.fit(x,y)
y_pred = pls.predict(x)
The mbpls package for Multiblock Partial Least Squares (MB-PLS) prediction modeling
import numpy as np
from mbpls.mbpls import MBPLS
num_samples = 40
num_features_x1 = 200
num_features_x2 = 250
# Generate two random data matrices X1 and X2 (two blocks)
x1 = np.random.rand(num_samples, num_features_x1)
x2 = np.random.rand(num_samples, num_features_x2)
# Generate random reference vector y
y = np.random.rand(num_samples, 1)
# Establish prediction model using 3 latent variables (components)
mbpls = MBPLS(n_components=3)
mbpls.fit([x1, x2],y)
y_pred = mbpls.predict([x1, x2])
# Use built-in plot method for exploratory analysis of multiblock pls models
mbpls.plot(num_components=3)
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 mbpls-1.0.4.tar.gz
.
File metadata
- Download URL: mbpls-1.0.4.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ca5ae20c9ad8965fed511141488840a309accbb292de7eab1b53a0f816765df |
|
MD5 | da967d9007f51f0e3d58e92a72b86690 |
|
BLAKE2b-256 | b370073ad2a35586a84740776c141aceb174b9010a6953bdd8875a6a701d6018 |
File details
Details for the file mbpls-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: mbpls-1.0.4-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f389929f04da086c086b11c30d9101edd9c19375ac3ec5b3ae1d43deed43824 |
|
MD5 | 0f6e4f9e21ef1879f10b4dbe3c89c271 |
|
BLAKE2b-256 | aebe9a2e529591ac67b9df9506bb0429acbea927c59e165f24c168a443747f00 |