Commit 0211a79f authored by Jussi Lindgren's avatar Jussi Lindgren

Plugins: Misc fixes to LDA classifier training

- Fixed a bug in the bias computation
- Covariance is now properly computed from the whole dataset
- Added a test for feature vector and classifier dimension compatibility
- Renamed some variables and made some const for clarity
parent 7023a893
......@@ -55,8 +55,8 @@ namespace OpenViBEPlugins
// Debug method. Prints the matrix to the logManager. May be disabled in implementation.
void dumpMatrix(OpenViBE::Kernel::ILogManager& pMgr, const MatrixXdRowMajor& mat, const OpenViBE::CString& desc);
std::vector < OpenViBE::float64 > m_oLabelList;
std::vector < CAlgorithmLDADiscriminantFunction > m_oComputationHelperList;
std::vector < OpenViBE::float64 > m_vLabelList;
std::vector < CAlgorithmLDADiscriminantFunction > m_vDiscriminantFunctions;
Eigen::MatrixXd m_oCoefficients;
Eigen::MatrixXd m_oWeights;
......
......@@ -25,7 +25,7 @@ CAlgorithmLDADiscriminantFunction::CAlgorithmLDADiscriminantFunction():m_f64Bias
{
}
void CAlgorithmLDADiscriminantFunction::setWeight(VectorXd &rWeigth)
void CAlgorithmLDADiscriminantFunction::setWeight(const VectorXd &rWeigth)
{
m_oWeight = rWeigth;
}
......@@ -35,7 +35,7 @@ void CAlgorithmLDADiscriminantFunction::setBias(float64 f64Bias)
m_f64Bias = f64Bias;
}
float64 CAlgorithmLDADiscriminantFunction::getValue(VectorXd &rFeatureVector)
float64 CAlgorithmLDADiscriminantFunction::getValue(const VectorXd &rFeatureVector)
{
return (m_oWeight.transpose() * rFeatureVector)(0) + m_f64Bias;
}
......@@ -45,7 +45,7 @@ uint32 CAlgorithmLDADiscriminantFunction::getWeightVectorSize()
return m_oWeight.size();
}
boolean CAlgorithmLDADiscriminantFunction::loadConfiguration(XML::IXMLNode *pConfiguration)
boolean CAlgorithmLDADiscriminantFunction::loadConfiguration(const XML::IXMLNode *pConfiguration)
{
std::stringstream l_sBias(pConfiguration->getChildByName(c_sBiasNodeName)->getPCData());
l_sBias >> m_f64Bias;
......
......@@ -21,14 +21,14 @@ namespace OpenViBEPlugins
public:
CAlgorithmLDADiscriminantFunction();
void setWeight(Eigen::VectorXd &rWeigth);
void setWeight(const Eigen::VectorXd &rWeigth);
void setBias(OpenViBE::float64 f64Bias);
//Return the class membership of the feature vector
OpenViBE::float64 getValue(Eigen::VectorXd &rFeatureVector);
OpenViBE::float64 getValue(const Eigen::VectorXd &rFeatureVector);
OpenViBE::uint32 getWeightVectorSize(void);
OpenViBE::boolean loadConfiguration(XML::IXMLNode* pConfiguration);
OpenViBE::boolean loadConfiguration(const XML::IXMLNode* pConfiguration);
XML::IXMLNode* getConfiguration(void);
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment