I've been asked to perform a linear discriminant analysis on a set of data for one of my projects. I'm using ALGLIB (C++ version) which has a fisherlda function but I need some help understanding how to use it.
The user answers a set of 6 questions (answers are a number from 1-7) which gives me an example data set of eg {1,2,3,4,5,6}. I then have 5 classes of 6 values each eg {0.765, 0.895, 1.345, 2.456, 0.789, 5.678}. The fisher lda function takes a 2 dimensional array of values and returns another 1d array of values (that I have no idea what they mean).
As I understand it I need to see to which class the users answers best fit?
Any help understanding LDA and/or how I can use this function would be greatly appreciated.
EDIT:
Here's the definition of the function I'm trying to use:
/*************************************************************************
Multiclass Fisher LDA
Subroutine finds coefficients of linear combination which optimally separates
training set on classes.
INPUT PARAMETERS:
XY - training set, array[0..NPoints-1,0..NVars].
First NVars columns store values of independent
variables, next column stores number of class (from 0
to NClasses-1) which dataset element belongs to. Fractional
values are rounded to nearest integer.
NPoints - training set size, NPoints>=0
NVars - number of independent variables, NVars>=1
NClasses - number of classes, NClasses>=2
OUTPUT PARAMETERS:
Info - return code:
* -4, if internal EVD subroutine hasn't converged
* -2, if there is a point with class number
outside of [0..NClasses-1].
* -1, if incorrect parameters was passed (NPoints<0,
NVars<1, NClasses<2)
* 1, if task has been solved
* 2, if there was a multicollinearity in training set,
but task has been solved.
W - linear combination coefficients, array[0..NVars-1]
-- ALGLIB --
Copyright 31.05.2008 by Bochkanov Sergey
*************************************************************************/
void fisherlda(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nclasses, ae_int_t &info, real_1d_array &w);
You are using fisherlda function which is an implementation of LDA algorithm.
LDA(Linear Discriminant Analysis) is aimed to find a linear combination of features that best characterizes or separates two or more classes of objects or events.
Assume the line y=wx(w,x both stand for a matrix here),so the given result of fisherlad is a 1d array of coefficients which is w.Then you can use this line to determine which class the answers belong.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.