diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-30 18:47:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-30 18:47:05 +0000 |
commit | 97e01009d69b8fbebfebf68f51e3d126d0ed43fc (patch) | |
tree | 02e8b836c3a9d89806f3e67d4a5fe9f52dbb0061 /ml/KMeans.h | |
parent | Releasing debian version 1.36.1-1. (diff) | |
download | netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.tar.xz netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.zip |
Merging upstream version 1.37.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | ml/KMeans.h (renamed from ml/kmeans/KMeans.h) | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ml/kmeans/KMeans.h b/ml/KMeans.h index 4ea3b6a89..0398eeb86 100644 --- a/ml/kmeans/KMeans.h +++ b/ml/KMeans.h @@ -9,6 +9,7 @@ #include <mutex> #include "SamplesBuffer.h" +#include "json/single_include/nlohmann/json.hpp" class KMeans { public: @@ -17,8 +18,16 @@ public: MaxDist = std::numeric_limits<CalculatedNumber>::min(); }; - void train(SamplesBuffer &SB, size_t MaxIterations); - CalculatedNumber anomalyScore(SamplesBuffer &SB); + void train(const std::vector<DSample> &Samples, size_t MaxIterations); + CalculatedNumber anomalyScore(const DSample &Sample) const; + + void toJson(nlohmann::json &J) const { + J = nlohmann::json{ + {"CCs", ClusterCenters}, + {"MinDist", MinDist}, + {"MaxDist", MaxDist} + }; + } private: size_t NumClusters; @@ -27,8 +36,6 @@ private: CalculatedNumber MinDist; CalculatedNumber MaxDist; - - std::mutex Mutex; }; #endif /* KMEANS_H */ |