mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-11-08 13:12:09 +01:00
Added OutlierFinderOld.
This commit is contained in:
parent
5ff5afff48
commit
8f7177aaac
1
SCsub
1
SCsub
@ -57,6 +57,7 @@ sources = [
|
||||
"mlpp/mlp/mlp_old.cpp",
|
||||
"mlpp/pca/pca_old.cpp",
|
||||
"mlpp/uni_lin_reg/uni_lin_reg_old.cpp",
|
||||
"mlpp/outlier_finder/outlier_finder_old.cpp",
|
||||
|
||||
"test/mlpp_tests.cpp",
|
||||
]
|
||||
|
42
mlpp/outlier_finder/outlier_finder_old.cpp
Normal file
42
mlpp/outlier_finder/outlier_finder_old.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// OutlierFinder.cpp
|
||||
//
|
||||
// Created by Marc Melikyan on 11/13/20.
|
||||
//
|
||||
|
||||
#include "outlier_finder_old.h"
|
||||
|
||||
#include "../stat/stat.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
MLPPOutlierFinderOld::MLPPOutlierFinderOld(int threshold) :
|
||||
threshold(threshold) {
|
||||
}
|
||||
|
||||
std::vector<std::vector<real_t>> MLPPOutlierFinderOld::modelSetTest(std::vector<std::vector<real_t>> inputSet) {
|
||||
MLPPStat stat;
|
||||
std::vector<std::vector<real_t>> outliers;
|
||||
outliers.resize(inputSet.size());
|
||||
for (uint32_t i = 0; i < inputSet.size(); i++) {
|
||||
for (uint32_t j = 0; j < inputSet[i].size(); j++) {
|
||||
real_t z = (inputSet[i][j] - stat.mean(inputSet[i])) / stat.standardDeviation(inputSet[i]);
|
||||
if (abs(z) > threshold) {
|
||||
outliers[i].push_back(inputSet[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return outliers;
|
||||
}
|
||||
|
||||
std::vector<real_t> MLPPOutlierFinderOld::modelTest(std::vector<real_t> inputSet) {
|
||||
MLPPStat stat;
|
||||
std::vector<real_t> outliers;
|
||||
for (uint32_t i = 0; i < inputSet.size(); i++) {
|
||||
real_t z = (inputSet[i] - stat.mean(inputSet)) / stat.standardDeviation(inputSet);
|
||||
if (abs(z) > threshold) {
|
||||
outliers.push_back(inputSet[i]);
|
||||
}
|
||||
}
|
||||
return outliers;
|
||||
}
|
29
mlpp/outlier_finder/outlier_finder_old.h
Normal file
29
mlpp/outlier_finder/outlier_finder_old.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#ifndef MLPP_OUTLIER_FINDER_OLD_H
|
||||
#define MLPP_OUTLIER_FINDER_OLD_H
|
||||
|
||||
//
|
||||
// OutlierFinder.hpp
|
||||
//
|
||||
// Created by Marc Melikyan on 11/13/20.
|
||||
//
|
||||
|
||||
#include "core/math/math_defs.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
class MLPPOutlierFinderOld {
|
||||
public:
|
||||
// Cnstr
|
||||
MLPPOutlierFinderOld(int threshold);
|
||||
|
||||
std::vector<std::vector<real_t>> modelSetTest(std::vector<std::vector<real_t>> inputSet);
|
||||
std::vector<real_t> modelTest(std::vector<real_t> inputSet);
|
||||
|
||||
// Variables required
|
||||
int threshold;
|
||||
};
|
||||
|
||||
|
||||
#endif /* OutlierFinder_hpp */
|
Loading…
Reference in New Issue
Block a user