This article demonstrates an example of using machine learning techniques on spectral data to construct a classification model for identifying samples .
The image below visualizes the mid-infrared spectroscopy (FT-IR) data of strawberry puree.
The red spectrum on the left represents strawberry puree, while the blue spectrum on the right represents non-strawberry puree (puree derived from fruits that do not contain strawberries).

The red (strawberry) and blue (non-strawberry) spectra show similar shapes overall, but differences in absorbance (Y-axis value) are observed in certain wavenumber regions.
Therefore, we will construct a machine learning model that takes absorbance data at multiple wavenumbers as input and outputs (labels) "strawberry" or "non-strawberry" to distinguish between the two.
Furthermore, we will examine which wavenumber ranges are useful for distinguishing these based on the obtained model.
Data Details
The data consists of mid-infrared (MIR) FT-IR spectral data obtained from strawberry puree (strawberry) and non-strawberry fruit puree (non-strawberry) (sources are listed at the end of the blog).
Absorbance was measured for each sample in the wavenumber region of 900–1800 cm⁻¹ , and a total of 983 spectral data were obtained for both strawberry and non-strawberry samples.
The figure below shows the spectral data of strawberries (red, N=351) and non-strawberries (N=632) superimposed. As mentioned earlier, the spectral shapes themselves are similar, but differences can be seen in specific wavenumber regions.

Using machine learning techniques, we attempt to distinguish between strawberries and non-strawberries by capturing differences across multiple wavenumbers in this spectral data.
Data structure
The data used for the analysis is structured as follows:
A column called "Category" is provided to distinguish between strawberries and non-strawberries, and this corresponds to the label in the classification model.
The other columns contain the absorbance at each wavenumber, and in this data, spectral information for 235 wavenumber points is used as explanatory variables.

*The following instructions will use the features of JMP Pro.
Furthermore, the 983 rows of data are randomly split, with 75% used as training data and 25% as validation data.
In JMP Pro, by going to [Analyze] > [Predictive Model] > [Create Validation Column] and specifying "Category" as the [Stratification] column, you can create a "Validation" column that divides the data so that the proportion of training data and validation data is roughly equal at each Category level, as shown in the figure below.

Dimensionality reduction of spectral data using functional principal component analysis
As in this example, spectral data is multivariate data with many continuous variables, so it is common practice to use principal component analysis (PCA) to reduce its dimensionality and visually confirm whether the groups can be separated.
However, here we will use functional principal component analysis (FPCA) to treat the entire spectrum as a "function" and attempt to classify it based on the differences in its shape.
JMP Pro allows you to perform this functional principal component analysis using a platform called "Functional Data Explorer" .
To perform functional principal component analysis, we first fit a suitable wavelet function to each spectrum, representing the spectrum as a single function. Then, we extract the differences in function shape as principal components.
The figure below shows the report obtained by fitting a wavelet model to the spectral data and performing functional principal component analysis. The "score plot" output here should be considered a functional version of the principal component analysis plot. The function's shape is reduced to two dimensions, and the coordinates of each of the 983 samples are plotted.

This means that samples located close together will have similar spectral shapes, while samples located far apart will have different spectral shapes.
Looking at the score plot, we can see that strawberries (red) are concentrated near the center, while non-strawberries (blue) are more widely dispersed.
While complete classification is difficult using only these two axes, the bias in the distribution, particularly in one direction of the principal components, suggests that differences in spectral shape may be multivariately influencing the classification.
Building classification models using machine learning techniques
Now the real work begins. There are various methods for classification models in machine learning, but using a "model screening" platform allows you to apply multiple models to the same data and compare their performance.
For this dataset, in "Model Screening," specify the following columns: [Y, Target Variable], [X, Explanatory Variable], and [Validation]. By specifying the validation column, you can fit the model to the training data and then validate its performance with the validation data.
In the "Method" section in the lower left, select the model you want to apply. Here, you select a method related to classification models.

When all the models checked with these settings are applied, the goodness-of-fit statistics for each method on the "Validation" data are displayed as follows. By default, they are sorted in descending order of "Entropy R-squared".

The results show that "neural boosting" (a neural network with improved prediction accuracy through boosting) yielded the best results in all goodness-of-fit statistics.
The R-squared value is close to 1, and the misclassification rate is 0.0041, which is less than 1%. This indicates that the 235 spectral variables are used to almost perfectly distinguish between strawberries and non-strawberries.
Note: In "Model Screening," the maximum number of parameters to estimate is limited to 450 .
Therefore, for spectral data with an even larger number of wavenumber points, please use a separate platform.
Evaluation of key variables using the best model
Check the application report for the "Neural Boosting" method that performs best.
The report displays goodness-of-fit statistics and confusion matrices (two-way tables showing the correspondence between observed and predicted categories of separation) for both the training and validation data.

The confusion matrix shows that there is only one misclassification in both the training and validation datasets.
So, in the end, which wave frequency was important for classifying strawberries from non-strawberries ?
Neural networks are a method that prioritizes predictive performance, and because the prediction formula is complex, it is not easy to directly interpret the contribution of each explanatory variable.
However, JMP provides a function that uses random number simulation to evaluate the factors that contribute to prediction.
From the "Neural" report, view the "Prediction Profile," and then select the "Assess Variable Importance" option from the Prediction Profile.
The following report summarizes the assessment of variable importance and shows a predictive profile color-coded based on "total effect." From these results, we can see that wavenumbers 1802.564, 899.327, and 1312.346 cm⁻¹ contribute most significantly to the prediction, in that order.

*Total effect: The overall importance of the effect when combined with other related factors.
Finally, using the values from the "Summary Report," we present a bar graph with wavenumber on the horizontal axis and total effect on the vertical axis. From this graph, we can see that there are multiple wavenumber regions where the total effect is large.

These regions strongly contribute to the prediction, suggesting they contain spectral information crucial for distinguishing between strawberries and non-strawberries.
These results suggest that by referring to the wavenumber region where the overall effect is greatest, it becomes possible to consider the information derived from chemical structure that contributes to the classification.
References and data sources
Use of Fourier transform infrared spectroscopy and partial least squares regression for the detection of adulteration of strawberry purees" Holland JK, Kemsley EK, Wilson RH. (1998). Journal of the Science of Food and Agriculture, 76, 263-269
by Naohiro Masukawa (JMP Japan)
Naohiro Masukawa - JMP User Community