All Projects → usnistgov → pyMCR

usnistgov / pyMCR

Licence: other
pyMCR: Multivariate Curve Resolution for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pyMCR

Opencog
A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)
Stars: ✭ 2,132 (+3776.36%)
Mutual labels:  unsupervised-learning, unsupervised-learning-algorithms, unsupervised-machine-learning
NMFADMM
A sparsity aware implementation of "Alternating Direction Method of Multipliers for Non-Negative Matrix Factorization with the Beta-Divergence" (ICASSP 2014).
Stars: ✭ 39 (-29.09%)
Mutual labels:  unsupervised-learning, unsupervised-machine-learning
srVAE
VAE with RealNVP prior and Super-Resolution VAE in PyTorch. Code release for https://arxiv.org/abs/2006.05218.
Stars: ✭ 56 (+1.82%)
Mutual labels:  unsupervised-learning, unsupervised-machine-learning
deepOF
TensorFlow implementation for "Guided Optical Flow Learning"
Stars: ✭ 26 (-52.73%)
Mutual labels:  unsupervised-learning
Dual-CNN-Models-for-Unsupervised-Monocular-Depth-Estimation
Dual CNN Models for Unsupervised Monocular Depth Estimation
Stars: ✭ 36 (-34.55%)
Mutual labels:  unsupervised-learning
arpes
Mirror of PyARPES (gitlab/lanzara-group/python-arpes) the open source ARPES analysis framework
Stars: ✭ 21 (-61.82%)
Mutual labels:  spectroscopy
anomalib
An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.
Stars: ✭ 1,210 (+2100%)
Mutual labels:  unsupervised-learning
M-NMF
An implementation of "Community Preserving Network Embedding" (AAAI 2017)
Stars: ✭ 119 (+116.36%)
Mutual labels:  unsupervised-learning
prospectr
R package: Misc. Functions for Processing and Sample Selection of Spectroscopic Data
Stars: ✭ 26 (-52.73%)
Mutual labels:  spectroscopy
mmselfsup
OpenMMLab Self-Supervised Learning Toolbox and Benchmark
Stars: ✭ 2,315 (+4109.09%)
Mutual labels:  unsupervised-learning
VAENAR-TTS
PyTorch Implementation of VAENAR-TTS: Variational Auto-Encoder based Non-AutoRegressive Text-to-Speech Synthesis.
Stars: ✭ 66 (+20%)
Mutual labels:  unsupervised-learning
USOT
[ICCV2021] Learning to Track Objects from Unlabeled Videos
Stars: ✭ 52 (-5.45%)
Mutual labels:  unsupervised-learning
amr
Official adversarial mixup resynthesis repository
Stars: ✭ 31 (-43.64%)
Mutual labels:  unsupervised-learning
awesome-graph-self-supervised-learning
Awesome Graph Self-Supervised Learning
Stars: ✭ 805 (+1363.64%)
Mutual labels:  unsupervised-learning
sutton-barto-rl-exercises
📖Learning reinforcement learning by implementing the algorithms from reinforcement learning an introduction
Stars: ✭ 77 (+40%)
Mutual labels:  unsupervised-learning
ACTIN
ACTIN is a Python program to calculate stellar activity indices
Stars: ✭ 14 (-74.55%)
Mutual labels:  spectroscopy
strollr2d icassp2017
Image Denoising Codes using STROLLR learning, the Matlab implementation of the paper in ICASSP2017
Stars: ✭ 22 (-60%)
Mutual labels:  unsupervised-learning
IJCAI2018 SSDH
Semantic Structure-based Unsupervised Deep Hashing IJCAI2018
Stars: ✭ 38 (-30.91%)
Mutual labels:  unsupervised-learning
DETReg
Official implementation of the CVPR 2022 paper "DETReg: Unsupervised Pretraining with Region Priors for Object Detection".
Stars: ✭ 273 (+396.36%)
Mutual labels:  unsupervised-learning
qspectra
Quantum simulations of nonlinear spectroscopy and dynamics for molecular aggregates
Stars: ✭ 14 (-74.55%)
Mutual labels:  spectroscopy
pytest Codecov PyPI - Python Version PyPI Project Page Anaconda Cloud NIST Public Domain

pyMCR: Multivariate Curve Resolution in Python

Documentation available online at https://pages.nist.gov/pyMCR

Software DOI: https://doi.org/10.18434/M32064

Manuscript DOI: https://doi.org/10.6028/jres.124.018

pyMCR is a small package for performing multivariate curve resolution. Currently, it implements a simple alternating regression scheme (MCR-AR). The most common implementation is with ordinary least-squares regression, MCR-ALS.

MCR with non-negativity constraints on both matrices is the same as non-negative matrix factorization (NMF). Historically, other names were used for MCR as well:

  • Self modeling mixture analysis (SMMA)
  • Self modeling curve resolution (SMCR)

Available methods:

  • Regressors:
  • Constraints
    • Non-negativity
    • Normalization
    • Zero end-points
    • Zero (approx) end-points of cumulative summation (can specify nodes as well)
    • Non-negativity of cumulative summation
    • Compress or cut values above or below a threshold value
    • Replace sum-across-features samples (e.g., 0 concentration) with prescribed target
    • Enforce a plane ("planarize"). E.g., a concentration image is a plane.
  • Error metrics / Loss function
    • Mean-squared error
  • Other options
    • Fix known targets (C and/or ST, and let others vary)

What it does do:

  • Approximate the concentration and spectral matrices via minimization routines. This is the core the MCR methods.
  • Enable the application of certain constraints in a user-defined order.

What it does not do:

Dependencies

Note: These are the developmental system specs. Older versions of certain packages may work.

  • python >= 3.4
    • Tested with 3.4.6, 3.5.4, 3.6.3, 3.6.5, 3.7.1
  • numpy (1.9.3)
    • Tested with 1.12.1, 1.13.1, 1.13.3, 1.14.3, 1.14.6
  • scipy (1.0.0)
    • Tested with 1.0.0, 1.0.1, 1.1.0
  • scikit-learn, optional (0.2.0)

Known Issues

Installation

Using pip (hard install)

# Only Python 3.* installed
pip install pyMCR

# If you have both Python 2.* and 3.* you may need
pip3 install pyMCR

Using pip (soft install [can update with git])

# Make new directory for pyMCR and enter it
# Clone from github
git clone https://github.com/usnistgov/pyMCR

# Only Python 3.* installed
pip install -e .

# If you have both Python 2.* and 3.* you may need instead
pip3 install -e .

# To update in the future
git pull

Using setuptools

You will need to download the repository or clone the repository with git:

# Make new directory for pyMCR and enter it
# Clone from github
git clone https://github.com/usnistgov/pyMCR

Perform the install:

python setup.py install

Logging

New in pyMCR 0.4.*, the logging module is now automatically loaded and setup during import (via __init__.py) to print messages. You do not need to do the logger setup below.

New in pyMCR 0.3.1, Python's native logging module is now used to capture messages. Though this is not as convenient as print() statements, it has many advantages.

A simple example that prints simplified logging messages to the stdout (command line):

import sys
import logging

# Need to import pymcr or mcr prior to setting up the logger
from pymcr.mcr import McrAR

logger = logging.getLogger('pymcr')
logger.setLevel(logging.DEBUG)

# StdOut is a "stream"; thus, StreamHandler
stdout_handler = logging.StreamHandler(stream=sys.stdout)

# Set the message format. Simple and removing log level or date info
stdout_format = logging.Formatter('%(message)s')  # Just a basic message akin to print statements
stdout_handler.setFormatter(stdout_format)

logger.addHandler(stdout_handler)

# Begin your code for pyMCR below

Usage

from pymcr.mcr import McrAR
mcrar = McrAR()

# MCR assumes a system of the form: D = CS^T
#
# Data that you will provide (hyperspectral context):
# D [n_pixels, n_frequencies]  # Hyperspectral image unraveled in space (2D)
#
# initial_spectra [n_components, n_frequencies]  ## S^T in the literature
# OR
# initial_conc [n_pixels, n_components]   ## C in the literature

# If you have an initial estimate of the spectra
mcrar.fit(D, ST=initial_spectra)

# Otherwise, if you have an initial estimate of the concentrations
mcrar.fit(D, C=initial_conc)

Example Results

Command line and Jupyter notebook examples are provided in the Examples/ folder. Examples of instantiating the McrAR class with different regressors available in the documentation .

From Examples/Demo.ipynb:

./Examples/mcr_spectra_retr.png

./Examples/mcr_conc_retr.png

Citing this Software

If you use pyMCR, citing the following article is much appreciated:

References

LICENSE

This software was developed by employees of the National Institute of Standards and Technology (NIST), an agency of the Federal Government. Pursuant to title 17 United States Code Section 105, works of NIST employees are not subject to copyright protection in the United States and are considered to be in the public domain. Permission to freely use, copy, modify, and distribute this software and its documentation without fee is hereby granted, provided that this notice and disclaimer of warranty appears in all copies.

THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.

Contact

Charles H Camp Jr: [email protected]

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].