我被要求对我的一个项目的一组数据进行线性判别分析。我正在使用具有fisherlda 功能的ALGLIB(C++ 版本),但我需要一些帮助来了解如何使用它。
用户回答了一组 6 个问题(答案是 1-7 的数字),这给了我一个示例数据集,例如 {1,2,3,4,5,6}。然后我有 5 类,每类 6 个值,例如 {0.765, 0.895, 1.345, 2.456, 0.789, 5.678}。Fisher lda 函数采用二维值数组并返回另一个一维值数组(我不知道它们的含义)。
据我了解,我需要查看用户回答的哪个课程最适合?
任何帮助理解 LDA 和/或我如何使用此功能将不胜感激。
编辑:
这是我尝试使用的函数的定义:
/*************************************************************************
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);