Function to evaluate impact of NIR pre-processing techniques on spectral data
Project description
Function compare_preprocessing can be used on any NIR spectral data if Y values are available.
Y can include one or several variables.
Function evaluates impact of different pre-processing techniques and combinations using multiblock partial least squares (MBPLS). Each block in MBPLS is a pre-processed spectral data.
Different pre-processing techniques evaluated:
- baseline
- de-trend
- EMSC
- MSC
- SNV
- Savitzky Golay derivatives (different polynomial and derivatives orders can be tested as well as the size of the moving window)
Blocks in MBPLS include:
- pre-processing techniques and combinations (several techniques applied to same data)
- original spectral data (starting point)
- 20 blocks of random noise called false signals (reference for destroyed information)
Analyst can choose to only compare scatter corrections techniques or only derivatives or both. It is also possible to set the number of pre-processing techniques which can be applied to same data. By default, only a single pre-processing technique and a combination of 2 are tested. NB: EMSC and MSC can not be applied together
For MBPLS, analyst can choose:
- number of principal components
- to autoscale or center each block
- to autoscale or center Y
Blocks are represented in superloading plots.
Model performances (adjusted R2, RMSECV) and variable importance on projection (VIP) are calculated for each block by cross validation. Number of random picks for cross validation and number of lines predicted in each cross validation can be set by the analyst. Effective rank for each block is calculated as well.
Call function
combination, datasets, datasets0, R2_all, R2adj_all, RMSECV_all, VIP_all, Ef_all, Wt = compare_preprocessing(X0, y)
Input arguments
- X0 (n x k) data to test pre-processing techniques on
- y (n x m) property under study
Optional input arguments
- nbPC: number of principal components for PLS in the MBPLS decomposition (default value=2)
- nb_comb: maximum number of pre-processing techniques applied on same data (default value=2)
- auto_x: autoscale data after applying pre-processing techniques if auto_x=1, if not data centered (default value=1)
- auto_y: autoscale variables to predict if auto_y=1, if not centered (default value=1)
- nb: number of random picks for cross validation
- CVnb: number of samples predicted in each cross validation
- only_sg: only test Savitzky-Golay if only_sg=1 (default value=0)
- svg_order: Savitzky-Golay polynomials orders to test
- svg_deriv: Savitzky-Golay derivatives orders to test
- svg_window: Savitzky-Golay window sizes to test
- sg_op: test only Savitzky-Golay pretreatments with the same order of polynomial and derivative if sg_op=0 (default value=0)
Outputs
- combination: pre-processing options tested
- datasets: data X0 after each pre-processing option and autoscaled or centered
- datasets0: data X0 after each pre-processing option
- R2_all: R2 values for each y variable predicted for each pre-processing option tested (block)
- R2adj_all: Adjusted for each y variable predicted for each pre-processing option tested (block)
- RMSECV_all: Root mean square error by cross validation for each y variable predicted for each pre-processing option tested (block)
- VIP_all: PLS variable importance in projection for each y variable predicted for each pre-processing option tested (block)
- W: Superloadings from MBPLS
Examples
Two full examples, along with datasets are provided in folder 'tests' of 'Download Files'. Please refer to 'NIR_preprocess_example.pdf' for full details
- Example 1: Artificial dataset
- Example 2: Corn dataset
Compatibility
compare_preprocessing tested on Python 3.8 using the following modules:
- numpy 1.19.2
- matplotlib 3.3.2
- copy
- itertools
- RG 0.0.66 (available at: https://pypi.org/project/RG/)
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
Built Distribution
File details
Details for the file NIR_preprocess-0.0.4.tar.gz
.
File metadata
- Download URL: NIR_preprocess-0.0.4.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8abe4d9bc5b9489fc8d7feb945e5acbf1dcaa624edfa9cb8c3604f1a1e0dabfb |
|
MD5 | fd489ea4fad09d3001f11776721d91cf |
|
BLAKE2b-256 | a5c800c7bf800935f16c455ac5dd61151a2dc7b8fea75f24e175429cdf406fbf |
File details
Details for the file NIR_preprocess-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: NIR_preprocess-0.0.4-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cad47e6a8979dba69c3d6637a7586cd5d5111c5b6d92e433d061cb15dc533cf3 |
|
MD5 | f0e512413e881a3dbc47b2efa91b351f |
|
BLAKE2b-256 | a0cd104709a9c053cf2e6efdb843913fed941388b06c996f803b7abcd3cd2923 |