|
12345678910111213141516171819202122232425262728293031323334353637 |
- #include "Evaluator.h"
- #include <easylogging++.h>
- #include "SystemConfig.h"
-
-
- Evaluator::Evaluator()
- {
- //initialize Linear Regression Analysis on Residual Current Register
- CappedStorage* storageP = DataModel::Instance()->getPermanentData(ModbusRegister::BENDER_Residual_current);
- if(storageP != nullptr){
- MLAlgorithms.push_back(std::make_unique<MLLinReg>(storageP));
- }
- else
- LOG(ERROR) << "Tried to invoke ML-Algorithm on non permanent or non existing parameter storage";
-
- }
-
- inline std::ostream& operator<<(std::ostream& os, std::vector<float>& vec) {
- std::for_each(vec.begin(), vec.end(), [&os](float a) {os << a << " "; });
- return os;
- }
-
-
- //update all registered models
- std::vector<MLAlert> Evaluator::evaluate()
- {
- std::vector<MLAlert> alerts;
- for(auto &a: MLAlgorithms){
- MLAlert alert = a->updateModel();
- if(alert.type != CustomAlertTypes::NO_ALERT)
- alerts.push_back(alert);
- }
- for(auto &a: alerts)
- LOG(WARNING) << a.message;
- return alerts;
- }
-
|