add oneR to main #2

Merged
Trianta merged 8 commits from oneR into main 2024-04-17 21:35:56 -05:00
Showing only changes of commit 9a164e9370 - Show all commits

View File

@ -220,19 +220,22 @@ namespace ARFF {
results.emplace(value, 0); results.emplace(value, 0);
} }
for (int i = 0; i < attribute->values.size(); ++i) { for (int i = 0; i < attribute->values.size(); ++i) {
int resultsTotal = 0;
if (attribute->values[i] == "?") { continue; } if (attribute->values[i] == "?") { continue; }
for (auto instance = database.begin(); instance != database.end(); ++instance) { for (auto instance = database.begin(); instance != database.end(); ++instance) {
if (instance->values[attributePos] != attribute->values[i]) { continue; } if (instance->values[attributePos] != attribute->values[i]) { continue; }
++results[instance->values.back()]; ++results[instance->values.back()];
resultsTotal++;
} }
debug::Log(kTrace, "Results:"); debug::Log(kTrace, "Results:");
for (auto it : results) { debug::Log(kTrace, "\t" + it.first + ": " + std::to_string(it.second)); } for (auto it : results) { debug::Log(kTrace, "\t" + it.first + ": " + std::to_string(it.second)); }
int lowest = 9999; float lowest;
float lowestRate = 1.0f;
std::string bestResult = results.begin()->first; std::string bestResult = results.begin()->first;
for (auto it = results.begin(); it != results.end(); ++it) { for (auto it = results.begin(); it != results.end(); ++it) {
if (it->second < lowest) { if (((resultsTotal - it->second) / float(resultsTotal)) < lowestRate) {
lowest = it->second; lowestRate = ((resultsTotal - it->second) / float(resultsTotal));
} else { lowest = resultsTotal - it->second;
bestResult = it->first; bestResult = it->first;
} }
} }