torekp Posted March 31, 2015 Report Share Posted March 31, 2015 (edited) Here's some code I developed for classification problems. The methods used are Multiple Discriminant Analysis, and Partial Least Squares Discriminant Analysis. At least, they're supposed to be. I've tried them and they seem to work, but I offer no guarantees. If anyone finds these really useful, I might try to upgrade them to the point where they'd be fit for the Code Repository. Labview 2012 SP1 Full, requires Matrix/Linear Algebra functions, and many MGI utilities (use VI Package Manager to install MGI utilities). The example data is taken from the classic "IRIS" data set (but for PLS, the Virginica category is omitted: this version of PLS can only do binary classification). Just press "Read File" and then say "Cancel" to get the default example data set for each method. Find some directory somewhere and unzip the zip file there, then open the project. All will be clear, I hope. statsExampl.zip Edited September 1, 2017 by torekp Fix PLS algorithm Quote Link to comment
torekp Posted April 6, 2015 Author Report Share Posted April 6, 2015 (edited) Note: although the PLSDA result for the IRIS data set looks reasonable - it seems to be doing a good job clustering the two categories in different parts of the LatentFactor space - I have had difficulties trying to apply this to my real work. The problem might be in my other, work-related Labview code, but it might be in the above code that I've offered you. If anyone has a Matlab PLSDA code or something that they know for sure works, and if it uses the PLS1 algorithm, and they'd like to compare results to make sure they're identical (or not), that would be nice. I have a vague memory of having done exactly that check with my Multiple Discriminant Analysis algorithm, comparing published results, and seeing agreement. So that one's probably OK. Edited April 6, 2015 by torekp Quote Link to comment
torekp Posted August 31, 2015 Author Report Share Posted August 31, 2015 (edited) The above PLS code has been corrected for one error. Below I attach the one corrected VI. Other errors might remain. PLS1.vi Edited September 1, 2017 by torekp error corrected in PLS1.vi Quote Link to comment
Wouter Posted September 1, 2015 Report Share Posted September 1, 2015 Small note: there is a machine learning toolkit available, https://decibel.ni.com/content/docs/DOC-19328 Quote Link to comment
Lexington Flenner Posted January 25, 2019 Report Share Posted January 25, 2019 (edited) On 9/1/2015 at 12:04 PM, Wouter said: Small note: there is a machine learning toolkit available, https://decibel.ni.com/content/docs/DOC-19328 yes, but either the old version (machine learning toolkit) nor the new the LabVIEW Analytics and Machine Learning Toolkit does contain a PLS1 Algorithm - but both have a PCA.vi so you could do a PCA on the input, and then make a linear regression with the PCA'S scores. That's a PCR: https://en.wikipedia.org/wiki/Principal_component_regression If you had several categorial classes, you have to do for each class a PCA and a linear regression. I think, that's equal to, what a PLS-1 does in one attempt: " ...it finds a linear regression model by projecting the predicted variables and the observable variables to a new space.." https://en.wikipedia.org/wiki/Partial_least_squares_regression On 8/31/2015 at 5:40 PM, torekp said: The above PLS code has been corrected for one error. Below I attach the one corrected VI. Other errors might remain. PLS1.vi I can't get the Discriminat example to work, but I did get torekkp's PLS1.vi to work with my custom data (about 3000 spectra, each one is a 1d array of 1024 bins) looks like it does compute, what it is supposed to do - I compared the scores to the scores of a PLS1 routine I have written once upon a time - Unfortunately, I can't share the data I used, maybe I find the time to put together some online available spectra dataset Edited January 30, 2019 by Lexington Flenner Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.