gpt4 book ai didi

c++ - 使用 alglib 进行线性判别分析

转载 作者:行者123 更新时间:2023-11-28 02:23:05 24 4
gpt4 key购买 nike

有人要求我对我的一个项目的一组数据执行线性判别分析。我正在使用具有 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);

最佳答案

您正在使用 fisherlda 函数,它是 LDA 算法的一个实现。

LDA(线性判别分析)旨在找到最能表征或区分两类或多类对象或事件的特征的线性组合。

假设这条线y=wx(这里w,x都代表一个矩阵),所以fisherlad的给定结果是一维系数数组w.然后你可以通过这条线来确定答案属于哪个类.

关于c++ - 使用 alglib 进行线性判别分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31648223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com