Register MLPPGaussMarkovChecker to the ClassDB, and fixed warnings.

This commit is contained in:
Relintai 2023-02-12 16:23:51 +01:00
parent c060318c6b
commit 0e75773261
3 changed files with 25 additions and 16 deletions

View File

@ -8,7 +8,6 @@
#include "../stat/stat.h"
#include <iostream>
void MLPPGaussMarkovChecker::checkGMConditions(std::vector<real_t> eps) {
bool condition1 = arithmeticMean(eps);
bool condition2 = homoscedasticity(eps);
@ -24,34 +23,38 @@ void MLPPGaussMarkovChecker::checkGMConditions(std::vector<real_t> eps) {
bool MLPPGaussMarkovChecker::arithmeticMean(std::vector<real_t> eps) {
MLPPStat stat;
if (stat.mean(eps) == 0) {
return 1;
return true;
} else {
return 0;
return false;
}
}
bool MLPPGaussMarkovChecker::homoscedasticity(std::vector<real_t> eps) {
MLPPStat stat;
real_t currentVar = (eps[0] - stat.mean(eps)) * (eps[0] - stat.mean(eps)) / eps.size();
for (int i = 0; i < eps.size(); i++) {
for (uint32_t i = 0; i < eps.size(); i++) {
if (currentVar != (eps[i] - stat.mean(eps)) * (eps[i] - stat.mean(eps)) / eps.size()) {
return 0;
return false;
}
}
return 1;
return true;
}
bool MLPPGaussMarkovChecker::exogeneity(std::vector<real_t> eps) {
MLPPStat stat;
for (int i = 0; i < eps.size(); i++) {
for (int j = 0; j < eps.size(); j++) {
for (uint32_t i = 0; i < eps.size(); i++) {
for (uint32_t j = 0; j < eps.size(); j++) {
if (i != j) {
if ((eps[i] - stat.mean(eps)) * (eps[j] - stat.mean(eps)) / eps.size() != 0) {
return 0;
return false;
}
}
}
}
return 1;
}
return true;
}
void MLPPGaussMarkovChecker::_bind_methods() {
}

View File

@ -10,11 +10,14 @@
#include "core/math/math_defs.h"
#include "core/object/reference.h"
#include <string>
#include <vector>
class MLPPGaussMarkovChecker : public Reference {
GDCLASS(MLPPGaussMarkovChecker, Reference);
class MLPPGaussMarkovChecker {
public:
void checkGMConditions(std::vector<real_t> eps);
@ -22,8 +25,9 @@ public:
bool arithmeticMean(std::vector<real_t> eps); // 1) Arithmetic Mean of 0.
bool homoscedasticity(std::vector<real_t> eps); // 2) Homoscedasticity
bool exogeneity(std::vector<real_t> eps); // 3) Cov of any 2 non-equal eps values = 0.
private:
protected:
static void _bind_methods();
};
#endif /* GaussMarkovChecker_hpp */

View File

@ -35,6 +35,7 @@ SOFTWARE.
#include "mlpp/stat/stat.h"
#include "mlpp/numerical_analysis/numerical_analysis.h"
#include "mlpp/hypothesis_testing/hypothesis_testing.h"
#include "mlpp/gauss_markov_checker/gauss_markov_checker.h"
#include "mlpp/hidden_layer/hidden_layer.h"
#include "mlpp/multi_output_layer/multi_output_layer.h"
@ -74,6 +75,7 @@ void register_pmlpp_types(ModuleRegistrationLevel p_level) {
ClassDB::register_class<MLPPStat>();
ClassDB::register_class<MLPPNumericalAnalysis>();
ClassDB::register_class<MLPPHypothesisTesting>();
ClassDB::register_class<MLPPGaussMarkovChecker>();
ClassDB::register_class<MLPPHiddenLayer>();
ClassDB::register_class<MLPPOutputLayer>();