#include "utils.h" pair, map> discretize(vector &X, mdlp::labels_t &y, vector features) { vector Xd; map maxes; auto fimdlp = mdlp::CPPFImdlp(); for (int i = 0; i < X.size(); i++) { fimdlp.fit(X[i], y); mdlp::labels_t &xd = fimdlp.transform(X[i]); maxes[features[i]] = *max_element(xd.begin(), xd.end()) + 1; Xd.push_back(xd); } return {Xd, maxes}; } tuple>, vector, vector, string, map>> loadFile(string name) { auto handler = ArffFiles(); handler.load(PATH + static_cast(name) + ".arff"); // Get Dataset X, y vector &X = handler.getX(); mdlp::labels_t &y = handler.getY(); // Get className & Features auto className = handler.getClassName(); vector features; for (auto feature: handler.getAttributes()) { features.push_back(feature.first); } // Discretize Dataset vector Xd; map maxes; tie(Xd, maxes) = discretize(X, y, features); maxes[className] = *max_element(y.begin(), y. end()) + 1; map> states; for (auto feature: features) { states[feature] = vector(maxes[feature]); } states[className] = vector(maxes[className]); return {Xd, y, features, className, states}; }