Mostrando entradas con la etiqueta Discriminantes. Mostrar todas las entradas
Mostrando entradas con la etiqueta Discriminantes. Mostrar todas las entradas

24 jul 2019

GOOD PRODUCT EVALUATION

 When we create a Good Product Model we want to test it with new samples knowing if they are good or bad. There is of course an uncertain area that we can calculate from experience we get from several evaluation.

In this Excel plot we see the values for "Max Peak T", for the training set (samples before Mars 2019) and new batches we consider are fine from Mars to June. There is a set of bad samples prepared with mixtures out of tolerance for a certain component or components of the mixture.

As we can see the model works in some cases but there are other that are misclassified, so we have to try other treatments or models to check if we can classify them better. Anyway there is always an uncertain zone and we have to check for confidence levels of the prediction.

29 mar 2019

DC2 maximun distance Win ISI algorithm (using R)

DC2 maximum distance algorithm is one of the Identification methods where the mean and standard deviation spectra of the training set spectra are calculated.

The unknown spectra is centered with the mean training spectra and after are divided by the standard deviation spectra, so we get a spectra matrix of the distances.
We can see some high distances for the samples with high difference respect to the mean (samples 1,2 and 3)

After we only have to calculate the maximum value (distance) of this matrix for every row (spectrum)

We can determine a cutoff of 3 by default, but it can be different if needed

18 ene 2019

Using RMS statistic in discriminant analysis (.dc4)

In the case we want to check if a certain spectrum belongs to a certain product we can create an algorithm with PCA in such a way that this algorithm try to reconstruct the unknown spectrum with the scores of this unknown spectrum on the PCA space of the product, and the loadings of the product. So we have the reconstructed spectrum of the unknown and the original spectrum of the unknown.
 
If we subtract one from the another we get the Residual spectrum which is really informative. We can calculate the RMS value of this spectrum to see if the unknown spectrum is really well reconstructed so the RMS values is small (RMS is used as statistic to check the noise in the diagnostics of the instrument).
 
Find the right cutoff to check if the sample is well reconstructed depends of the type of sample and sample presentation.
 
Win ISI multiply the RMS by 1000, so the default value for this cutoff which is 100 in reality is 0.1, anyway a smaller or higher value can be used depending of the application.
 
This type of discrimination is known as RMS-X residual in Win ISI 4 and create ".dc4" models.
 
We see in next posts other ways to use this RMS residual.

4 sept 2015

Looking to the Residual Matrix


The first plot shows in blue color the residual Matrix "E", after developing a principal components calculation with SVD of some samples of wheat flour without any additive (training set).
Additive (ascorbic acid) was added to the flour in certain levels (50, 100, 200 and 500 ppm) to build a validation set. After acquiring the spectra, I reconstruct these spectra with the loading matrix "P" calculates with the SVD using the training samples. First I calculate the scores anf after the reconstructed spectra multiplying the scores with the P transpose matrix.
Once I get the reconstructed spectra, I subtract the reconstructed from the original validation set, and I get the residuals, that I overplot with red color over the blue ones.
I can see that the RMS is higher, and there is some shape different from the random noise of the blue spectra, so the good product model can be tuned to reject this validation set with some RMS cutoff.
Does this shape something from the spectra from the pure additive?
 
 

In green color we can see the spectra of the ascorbic acid, and I convert it into the residuals scale, and where I see certain similarities is in the band at 2250 nm, where all the peaks from the residuals of the validation set, and the ascorbic peak have the same shape.
Anyway this is a simply study about how residuals could help us to determine if the samples can be considered as Good Product, or they are out of specifications and further investigation is needed studying the residuals to determine the cause.

27 may 2015

NIR used to study Mixtures (Part 1)

When developing a mixture of ingredients we use a to live some time to be sure that the mixture is fine and if we divide the mixed batch into several subsamples, the spectra of all the subsamples are similar each other in a certain level. If we see differences, we consider that the mixture is not completed and we can continue mixing. There is a point at a certain time where the mixture cannot be improve and after that point it can became worse to certain levels. We must be sure that we finish the mixture as closer to that point as possible.
If we get a library of spectra with those characteristics we can keep it and compare new batches in order to check if the spectrum at that time match with the spectra from the library.
In a mixture is also important that the quantities of every ingredient is correct, maybe we miss to add an ingredient, we add it in the wrong proportions,  or by mistake an ingredient which does not form part of the formula. Why not to detect even a cross contaminant, or other issues.
If we develop a model based on good spectra, and prepare a realistic cutoff we can check all the batches and detect if the PASS or FAIL the Identification or Qualification Test.
There can be cases where we can know what the problem was looking to the spectra. One simple example is to add to a mixture an ingredient which should not be there... let´s suppose "Dextrose", and I acquire the spectrum of this mixture, after I subtract this spectrum from the average spectrum of all the good spectra in the library (let´s say the ideal spectrum)…..you will see how the difference spectrum is the Dextrose itself, or very similar with a high correlation to the samples in the Dextrose product.
You can see also this with more complex techniques as Principal Component Analysisn (PCAs), where we have a reconstructed spectrum and a residual spectrum as well. Can we see any features in the residual spectrum which tell us what is the ingredient or ingredients not explained by the model? Maybe is the spectra of an adulterant, wrong ingredient added by mistake,...

27 mar 2014

NIPALS: X residuals


This diagram shows the spectra reconstruction. We have the T matrix which showsunder the plots the first´s four samples with the scores values respect to five  PCs. We can see how the the score of the first sample respect to PC1 is negative, so when we multiply this value by every  value of the first loading, we change the sign of the values and the result change.
This happens also in the cases of PC2 and PC4, is not the case of PC3, with positive score value, so the shape of the result is the same.
Finally we can add the four results spectra to see the reconstructed first sample.The difference between the reconstructed and the original is the residual. Win ISI called this residual as the X residual.
This type of reconstruction is very useful in the discriminant analysis, the unknown sample is reconstructed with different models, the sample is identified in the group with the lowest X residual.

17 jul 2011

Residual Variance

We´ve been talking about how to use the PCs, and how to reconstruct the original spectrum from its PC scores and the eigenvectors. After this we compared the reconstructed spectrum to the original one to get a residual value:

Residual (R) = Spectrum original – Spectrum reconstructed

If the PCs space represent the 100% of the variance of the training set, then the residual would be zero for the training set samples, but this is not the case.
The variance for the residual spectrum is:

Vr = RT.R

This variance can be used as an indicator if a sample belongs to a spectra population. This is the method known as “Residual Variance”.