Commit 75563503 authored by Alessio Netti's avatar Alessio Netti

Analytics: minor fix to the Regressor and Classifier plugins

parent 834246bb
......@@ -199,12 +199,13 @@ void RegressorOperator::computeFeatureVector(U_Ptr unit) {
uint64_t startTs = endTs - _aggregationWindow;
std::vector<RegressorSBPtr>& inputs = unit->getInputs();
for(idx=0; idx<inputs.size(); idx++) {
_mean=0; _std=0; _diffsum=0; _qtl25=0; _qtl75=0;
_mean=0; _std=0; _diffsum=0; _qtl25=0; _qtl75=0; _latest=0;
_buffer.clear();
if(!_queryEngine.querySensor(inputs[idx]->getName(), startTs, endTs, _buffer, false) || _buffer.empty())
throw std::runtime_error("Operator " + _name + ": cannot read from sensor " + inputs[idx]->getName() + "!");
_latest = _buffer.back().value;
if (inputs[idx]->getTrainingTarget())
_currentTarget = (float)_buffer.back().value;
_currentTarget = (float)_latest;
if(!inputs[idx]->getTrainingTarget() || _includeTarget) {
// Computing MEAN and SUM OF DIFFERENCES
......@@ -245,7 +246,7 @@ void RegressorOperator::computeFeatureVector(U_Ptr unit) {
_currentfVector->at<float>(fIdx + 2) = (float) _diffsum;
_currentfVector->at<float>(fIdx + 3) = (float) _qtl25;
_currentfVector->at<float>(fIdx + 4) = (float) _qtl75;
_currentfVector->at<float>(fIdx + 5) = (float) _buffer[_buffer.size() - 1].value;
_currentfVector->at<float>(fIdx + 5) = (float) _latest;
} else {
fIdx = idx * REG_NUMFEATURES;
_currentfVector->at<float>(fIdx) = 0.0f;
......
......@@ -103,6 +103,7 @@ protected:
int64_t _diffsum;
int64_t _qtl25;
int64_t _qtl75;
int64_t _latest;
// Helper struct to store importance pairs
struct ImportancePair {
......
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