SIMPLISMA example

In this example, we perform the PCA dimensionality reduction of a spectra dataset

Import the package

import spectrochempy as scp

Load and annotate the dataset

print("Dataset (Jaumot et al., Chemometr. Intell. Lab. 76 (2005) 101-110)):")
lnd = scp.read_matlab("matlabdata/als2004dataset.MAT", merge=False)
for mat in lnd:
    print("    " + mat.name, str(mat.shape))

ds = lnd[-1]
_ = ds.plot()

Add metadata for a nicer display:

ds.title = "absorbance"
ds.units = "absorbance"
ds.set_coordset(None, None)
ds.y.title = "elution time"
ds.x.title = "wavelength"
ds.y.units = "hours"
ds.x.units = "nm"

Fit the SIMPLISMA model

print("Fit SIMPLISMA on {}\n".format(ds.name))
simpl = scp.SIMPLISMA(n_components=20, tol=0.2, noise=3, log_level="INFO")
_ = simpl.fit(ds)

Visualize the results

Concentration profiles:

_ = simpl.C.T.plot(title="Concentration")

Pure component spectra:

_ = simpl.components.plot(title="Pure profiles")

Merit plot after reconstruction:

_ = simpl.plot_merit(offset=0, nb_traces=5)

Uncomment the following line to display all figures when running the script directly with Python.

# scp.show()

Total running time of the script: ( 0 minutes 0.000 seconds)