open_nipals: An sklearn-compatible Python package for NIPALS dimensionality reduction
open_nipals: An sklearn-compatible Python package for NIPALS dimensionality reduction - Published in JOSS (2026)
Science Score: 87.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 6 DOI reference(s) in README and JOSS metadata -
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords from Contributors
Repository
Basic Info
- Host: GitHub
- Owner: johnsonandjohnson
- License: bsd-3-clause
- Language: Python
- Default Branch: main
- Size: 71.5 MB
Statistics
- Stars: 20
- Watchers: 2
- Forks: 3
- Open Issues: 0
- Releases: 4
Metadata Files
README.md
open_nipals PCA and PLS package
This package implements the nonlinear iterative partial least squares (NIPALS) algorithm for principal component analysis (PCA) and partial least squares (PLS) regression in a scikit-learn compatible fashion.
In contrast to orthodox methods for PCA and PLS, the NIPALS algorithm is an iterative method, allowing free tuning of desired numerical performance and precision.
Moreover, it naturally integrates with Nelson's Single Component Projection method for missing data imputation.
Quickstart
Install the package with pip install open-nipals.
Training a NipalsPCA model can look as simple as:
```python
from sklearn.preprocessing import StandardScaler
from open_nipals.nipalsPCA import NipalsPCA
input data frame df
standard-scale data
scaler = StandardScaler() scaleddata = scaler.fittransform(df)
train PCA model
model = NipalsPCA() transformeddata = model.fittransform(X=data) ```
A minimal example of fitting a NipalsPLS model:
```python
from sklearn.preprocessing import StandardScaler
from open_nipals.nipalsPLS import NipalsPLS
input data frames dfx, dfy
standard-scale data
scalerx = StandardScaler() scalery = StandardScaler() scaledxdata = scalerx.fittransform(dfx) scaledydata = scalery.fittransform(dfy)
train PLS model
model = NipalsPLS() transformedxdata, transformedydata = model.fittransform(X=scaledxdata, y=scaledy_data) ```
Key Features and API Overview
Preprocessing
Both the NipalsPCA and NipalsPLS classes expect a numpy array as an input with rows as samples and columns as features.
Additionally, these array columns should have zero mean for best performance; typically this is done with a sklearn StandardScaler object.
Note that it is highly encouraged to mean-center the input data before training an open_nipals model on it.
Note: If the input data is a pandas dataframe, you can fit and instantiate an ArrangeData object which will ensure all future datasets come to the appropriate shape and column order.
```python from open_nipals.utils import ArrangeData import pandas as pd from sklearn.preprocessing import StandardScaler
Load some arbitrary data
df = pd.readcsv('mydata.csv')
Invoke preprocessing pipeline
arrdat = ArrangeData() scaler = StandardScaler()
Both scaler and arrdat should be saved for future use
data = scaler.fittransform(arrdat.fittransform(df))
data is ready to model
```
Model fitting and transforming
The number of components can be specified as an argument to the constructor, with the default n_components=2.
After fitting, components can be added or removed by the set_components() method without having to fit the entire model again from scratch.
Components that were once fitted but not needed any more are saved for possible later use.
Functions of the scikit-learn API implemented by open_nipals:
fit()for model fittingtransform()for transforming data given a fitted modelfit_transform()as a combination offit()andtransform()- a pseudo-inverse transformation
inverse_transform(), making the model predict how the data would look like
PLS prediction
One particular feature of PLS models is that they can predict dependent variables. To this end, run model.predict(), where either a matrix of X data X,
or a matrix of X scores scores_x need to be given as arguments, e.g.
python
predicted_y_data = model.predict(X=data_x)
Distances
In-model distances (IMD) and out-of-model distances (OOMD) are metrics of model accuracy. They can be calculated for PCA and PLS models with: ```python
Must be scaled data
hotellingt2 = model.calcimd(input_array = data)
also must be scaled, default metric is QResiduals or 'QRes'
dmodx = model.calcoomd(inputarray = data, metric = "DModX") ```
Explainability
Similar to scikit-learn, the attribute explained_variance_ratio_ measures the ratio of variance that each component of the model explains.
NipalsPLS has two of those arrays, one for the X and one for the y data.
Note that the NIPALS algorithm avoids calculating eigenvalues, therefore they are not accessible as the explained_variance_ attribute.
Additionally, the regression vector can be calculated for a NipalsPLS model with get_reg_vector().
The regression vector is a measure of how relevant each X feature is for the prediction of the y data.
References
PLS algorithm implemented from Chapter 6 of:
Chiang, Leo H., Evan L. Russell, and Richard D. Braatz. Fault detection and diagnosis in industrial systems. Springer Science & Business Media, 2000.
One of the most concise definitions can be found in this paper on page 7:
Geladi, P.; Kowalski, B. R. Partial Least-Squares Regression: A Tutorial. Analytica Chimica Acta 1986, 185, 1–17. https://doi.org/10.1016/0003-2670(86)80028-9.
For the transformation part also see:
Nelson, P. R. C.; Taylor, P. A.; MacGregor, J. F. Missing data methods in PCA and PLS: Score calculations with incomplete observations. Chemometrics and Intelligent Laboratory Systems 1996, 35(1), 45-65.
Documentation
An online version of the documentation is hosted at ReadTheDocs.
Contributing
If you would like to contribute to open_nipals, please check out our github repo.
For contribution guidelines please refer to the CONTRIBUTING.md in the repo, or the contributor's guide in the online documentation.
License
open_nipals is distributed under the BSD 3-clause license.
Citation
This documentation refers to open_nipals v2.0.1.
An archived version of the code can be found under this DOI 10.5281/zenodo.18375840.
Owner
- Name: Johnson & Johnson
- Login: johnsonandjohnson
- Kind: organization
- Repositories: 29
- Profile: https://github.com/johnsonandjohnson
JOSS Publication
open_nipals: An sklearn-compatible Python package for NIPALS dimensionality reduction
Authors
Tags
multivariate analysis machine learning dimensionality reduction principal component analysis partial least squares regressionGitHub Events
Total
- Release event: 1
- Delete event: 4
- Member event: 1
- Pull request event: 5
- Fork event: 1
- Issues event: 8
- Watch event: 13
- Issue comment event: 9
- Push event: 49
- Pull request review event: 2
- Create event: 4
Last Year
- Release event: 1
- Delete event: 3
- Member event: 1
- Pull request event: 2
- Issues event: 4
- Watch event: 3
- Issue comment event: 6
- Push event: 21
- Pull request review event: 2
- Create event: 2
Committers
Last synced: about 1 month ago
Top Committers
| Name | Commits | |
|---|---|---|
| Niels Schlusser | 9****r | 11 |
| nielsschlusser | 7 | |
| Ryan Wall | r****9@i****m | 2 |
| nielsschlusser | n****s@i****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: about 1 month ago
All Time
- Total issues: 7
- Total pull requests: 5
- Average time to close issues: 5 months
- Average time to close pull requests: about 2 months
- Total issue authors: 3
- Total pull request authors: 1
- Average comments per issue: 3.14
- Average comments per pull request: 0.2
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 5
- Pull requests: 3
- Average time to close issues: 7 months
- Average time to close pull requests: 2 months
- Issue authors: 2
- Pull request authors: 1
- Average comments per issue: 4.0
- Average comments per pull request: 0.33
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- rsenne (3)
- arden13 (3)
- Ing-MarieL (1)
Pull Request Authors
- nielsschlusser (5)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 52 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
pypi.org: open-nipals
A package to support dimensionality reduction methods.
- Homepage: https://github.com/johnsonandjohnson/open_nipals
- Documentation: https://open-nipals.readthedocs.io/en/latest/
- License: BSD 3-Clause License
-
Latest release: 2.0.2
published 3 months ago
Rankings
Maintainers (1)
Dependencies
- sphinx >=3.2.1
