#pragma once #include #include #include #include namespace platform { using json = nlohmann::ordered_json; struct WTL { int win; int tie; int loss; }; struct FriedmanResult { double statistic; double criticalValue; long double pvalue; bool reject; }; struct HolmLine { std::string model; long double pvalue; double rank; WTL wtl; bool reject; }; struct HolmResult { std::string model; std::vector holmLines; }; class Statistics { public: Statistics(const std::vector& models, const std::vector& datasets, const json& data, double significance = 0.05, bool output = true); bool friedmanTest(); void postHocHolmTest(bool friedmanResult); FriedmanResult& getFriedmanResult(); HolmResult& getHolmResult(); std::map>& getRanks(); private: void fit(); void computeRanks(); void computeWTL(); const std::vector& models; const std::vector& datasets; const json& data; double significance; bool output; bool fitted = false; int nModels = 0; int nDatasets = 0; int controlIdx = 0; std::map wtl; std::map ranks; int maxModelName = 0; int maxDatasetName = 0; FriedmanResult friedmanResult; HolmResult holmResult; std::map> ranksModels; }; }