Spectra Lab — chemometrics in your browser
Student access: coming soon. The interactive demo is open now.
Spectra Lab: chemometrics software for near-infrared calibration, in your browser
Partial least squares regression (PLS) and spectral preprocessing (SNV, Savitzky-Golay derivatives) for near infrared spectroscopy (near-infrared, NIR) data: upload spectra, compare preprocessing, validate with RMSECV and RPD, and flag outliers with Hotelling T2. Principal component analysis is coming next. No install, no vendor lock-in.
Works with spectra from any NIR instrument — if you can export it as a table of numbers, Spectra Lab can calibrate on it.
Interactive demo: spectral preprocessing, PLS regression and model validation
Choose a preprocessing method and watch what it does to the spectra, the RMSECV-versus-components curve, the predicted-versus-reference scatter, and the validation metrics. Start with raw spectra, then try SNV: on this real meat data it lowers the error, then compare the derivatives.
Results computed by the Spectra Lab engine on a real public meat dataset (172 training samples, fat % as-is), 5-fold cross-validation.
What is a Savitzky Golay filter (Savitzky-Golay algorithm)?
A Savitzky Golay filter (also written Savitzky-Golay; the Savitzky-Golay algorithm or Savitzky-Golay smoothing) fits a low-order polynomial to a short moving window of points along each spectrum. The fitted value smooths noise; the fitted slope or curvature gives the first or second derivative, which removes baseline offsets and slopes before partial least squares regression. Window size and polynomial order set the trade-off between noise removal and losing real absorption features. In the demo above, compare "SG 1st derivative" and "SG 2nd derivative" with the raw spectra to see that trade-off on real data.
Tour the Lab
Six screens take you from a raw CSV to a filed validation report. Pick a step on the left; on a phone the tabs scroll sideways.
Upload a CSV with one row per sample and your reference values alongside the wavelengths. Spectra Lab previews the table so you can check the columns, the row count and the reference range before anything is computed.
Real datasets, real results
We ran real public NIR datasets through Spectra Lab, the same engine students use, not just simulated teaching spectra. The results line up with published work, and each one teaches a lesson worth repeating yourself.
Cross-validation says 0.87; a season the model never saw says about 1.0. Our results match the published 1.01 on the full data.
Same model, same day: error more than doubles on samples outside the range it was trained on.
The spectrum sees the wet sample, so calibrate as-is and convert for reporting. Background: As-Is vs. Dry Matter in NIR.


Data: mango dry matter from Anderson, Walsh, Subedi and Hayes (2020), Postharvest Biology and Technology 168, dataset CC BY 4.0 (Mendeley Data, doi 10.17632/46htwnp833), teaching subset of 600 + 100 spectra, 684-990 nm. Meat: public-domain dataset of 240 finely chopped meat samples, 850-1050 nm transmission, fat, moisture and protein by wet chemistry (reported as-is). Results computed by Spectra Lab, PLS with 5-fold cross-validation.
Learn by practicing
Spectra Lab is built for learning by doing. Every concept comes as a short exercise with a goal, the steps, what you should see and why it matters, and the workbench explains each step as you go.
- Your first model. Import spectra, train PLS and read RMSECV, R2 and RPD.
- When preprocessing hurts. Compare raw spectra with SNV and see a model fall apart.
- Derivatives and baselines. Savitzky-Golay 1st vs 2nd derivative: baseline removed, noise added.
- Get a second opinion. Score new spectra against a model and see which samples get flagged.
- Try your own data. Import your CSV, train raw and one preprocessing, compare RPD.
Next, with the real datasets above: inside vs outside the calibration range, a new season, and as-is vs dry-matter basis.

Problems Spectra Lab solves
These are the questions analysts and statisticians keep asking about calibration. Here is what the Lab does about each one today.
“Which preprocessing should I use?”
Compare methods side by side on your own spectra and see the error change; the demo shows SNV can destroy a signal.
“How many PLS components should I keep?”
The RMSECV-per-component curve and the chosen minimum, so over-fitting is visible.
“My RMSECV looks good, will it hold on new samples?”
RMSECV, R2 CV, RPD and bias side by side, plus Second Opinion on new spectra.
Coming next: a separate test-set partition by lot or date.“Is this sample an outlier or a real product?”
Hotelling T2 and Q residual flags per sample.
“The software is expensive or tied to one instrument.”
Runs in the browser on CSV from any instrument; no installation.
“It worked on one instrument and fails on another.”
The course lesson on calibration transfer is available today.
Coming next: calibration transfer (slope/bias and standardization).Based on recurring questions from analysts and statisticians in public Q&A forums and the calibration literature.
Free chemometrics resources on SpectroScience
Calculators
Model diagnostics, calibration method selector and feasibility checker
NIR Calibration and Chemometrics guide
NIR laboratory guide
NIR glossary
NIR vs wet chemistry
Practice quizzes
PDF: NIR cheat sheet
PDF: NIR glossary
PDF: NIR troubleshooting guide
What you can do with Spectra Lab chemometrics software
Import spectra (CSV)
Upload your spectral data as a CSV file with one row per sample, alongside the reference values you already measured with wet chemistry.
Preprocess (SNV, Savitzky-Golay 1st and 2nd derivative)
Standard normal variate and Savitzky-Golay 1st and 2nd derivatives, applied consistently to every spectrum and compared side by side. Multiplicative scatter correction and baseline correction are coming.
Calibrate (PLS regression with cross-validation)
Build partial least squares regression models against your reference values, with cross-validation that keeps the component count honest.
Validate and second-opinion (RMSECV, RPD, bias, T2/Q outliers, PDF report)
Get RMSECV, RPD and bias in one view, inspect Hotelling T2 and Q residual outlier diagnostics, and export a PDF report you can file with the method.
From calibration curve to NIR calibration in near infrared spectroscopy
A single-wavelength calibration curve goes back to the Beer-Lambert law: absorbance is proportional to concentration, so one wavelength and a linear fit can quantify one analyte in a clean matrix. Real samples are not clean. Scattering, particle size, temperature and overlapping absorption bands break the single-wavelength assumption.
Multivariate calibration solves this by using hundreds of wavelengths at once and letting partial least squares regression find the combinations that carry the information and reject the rest. Spectra Lab walks that whole path for you: Beer-Lambert calculator, NIR calibration methods compared: MLR, PCR, PLS and ANN, and How to build a PLS model in practice: from raw spectra to validated calibration.
What is partial least squares regression? PLS vs principal component analysis (PCA), in plain words
PCA: what is in my spectra?
Principal component analysis is exploration. It finds the directions of largest variance in the spectral data and shows you whether your samples cluster, drift or split into groups. There is no reference value involved. Use it to understand your set, find outliers and see whether your calibration population is really one population.
How to run PCA on NIR spectra step by step · How to interpret a PCA score plot
PLS: what is in my spectra that predicts moisture?
Partial least squares regression is prediction with a purpose. It rotates the same kind of components, but it chooses them so that they also explain your reference values. That is why PLS regression usually beats PCA followed by regression when you actually want a number out of the instrument.
Model validation like a lab manager: RMSECV, RPD, bias and Hotelling T2
A calibration is only as good as its validation. Spectra Lab reports the numbers a lab manager asks for, and lets you pull them into a report you can defend in an audit.
- RMSECV
- Root mean square error of cross-validation: the error you should expect on new samples from the same population, computed by leaving samples out and predicting them back.
- RMSEP and bias
- When you have an independent test set you also get RMSEP, and the bias tells you whether the model is systematically high or low rather than just noisy.
- RPD thresholds
- RPD is the ratio of reference standard deviation to prediction error. As a rule of thumb, below about 2.5 a model is only good enough for screening, and above about 3 it can be considered for quantitative use.
- Hotelling T2 and Q outliers
- T2 flags samples that sit far from the calibration centre; Q residuals flag samples the model cannot reconstruct. Together they separate unusual samples from bad spectra.
Read more: Cross-validation in NIR calibration: leave-one-out vs k-fold · Choosing the right NIR calibration validation approach · How to detect NIR spectral outliers.
Learning path: the course lessons that teach each step
Spectra Lab is the practice bench for the NIR spectroscopy course. Each stage of the workflow maps to a lesson that explains the theory behind it.
-
Import and clean spectraLesson 25: Sample PreparationSee it in the curriculum →
-
Preprocessing and scatter correctionLesson 21: Reading the NIR SpectrumSee it in the curriculum →
-
PCA and score plotsLesson 22: What Is ChemometricsSee it in the curriculum →
-
PLS regression and component choiceLesson 23: Introduction to CalibrationSee it in the curriculum →
-
Validation, RMSECV, RPD and biasLesson 24: Validation TechniquesSee it in the curriculum →
-
Outliers, T2 and Q diagnosticsLesson 31: Troubleshooting and Problem SolvingSee it in the curriculum →
New to NIR and chemometrics? Get learner access with the NIR course.
Read the articles behind each step
Field-tested explanations from the SpectroScience blog, each paired with something you can try in Spectra Lab.
-
PLS Regression for NIR: Step-by-Step Guide for Food and Feed CalibrationRead the article →
-
Why Does R² Lie? Understanding RPD, SEP, and RMSEP in NIR AccuracyRead the article →
-
NIR Calibration Overfitting: Why It Happens and Three Validation MethodsRead the article →
-
Why Do NIR Outliers Appear — and When Should You Remove Them?Read the article →
-
Why Does Your Reference Method Limit NIR Accuracy? Lab Error Study ExplainedRead the article →
-
As-Is vs. Dry Matter in NIR: Understanding the Key DifferencesRead the article →
Frequently asked questions
What is partial least squares regression?
What is a Savitzky-Golay filter used for in spectroscopy?
Is Spectra Lab free?
Which instruments' spectra work with Spectra Lab?
What file format does Spectra Lab accept?
Is my data private?
PLS or PLS-DA?
How many samples do I need?
How many components should I use in a PLS regression?
What if RMSEP or RMSECV has no clear minimum?
Should I mean-center or autoscale spectra before PLS?
How much variance should PCA capture?
How do I know a new sample is within my calibration?
Can I cross-validate with replicate scans?
Spectra Lab is coming soon for students
Student access is not open yet. NIR course students will be the first to know when it opens. Until then, try the free demo above and learn the method behind every button in the course.