Я получаю эту ошибку Выражение: индекс вектора вне диапазона каждый раз Я пытаюсь запустить
введите здесь описание изображения
Я не понимаю, где мне нужно исправить.
Правило OneR — это набор правил, все из которых основаны на значении ОДНОГО атрибута. Это также должно вывести частоту ошибок правила (набора) oneR в обучающем наборе
#include
#include
#include
#include
#include
using namespace std;
// Define structures to hold ARFF data
struct Instance {
vector attributes;
string classLabel;
};
struct ARFFData {
vector attributeNames;
vector attributeValues;
vector classLabels;
vector instances;
};
// Function to parse ARFF file
...
}
// Function to calculate error rate of OneR rule
double calculateErrorRate(const ARFFData& data, const string& attribute, const string& classLabel) {
// Implement error rate calculation logic here
return 0.0; // Placeholder, replace with actual calculation
}
// Function to find the best OneR rule
pair findOneRRule(const ARFFData& data) {
// Implement OneR algorithm logic here
string bestAttribute;
double minErrorRate = 1.0; // Initialize with maximum error rate
// Iterate over attributes and find the one with the minimum error rate
for (const auto& attribute : data.attributeNames) {
// Calculate error rate for this attribute
double errorRate = calculateErrorRate(data, attribute, data.classLabels[0]);
// Update best attribute if error rate is lower
if (errorRate < minErrorRate) {
m....
}
return make_pair(bestAttribute, minErrorRate);
}
int main() {
// Parse input ARFF file
ARFFData data = parseARFF("input.arff");
// Find the best OneR rule
pair oneRRule = findOneRRule(data);
// Print the OneR output
cout
Подробнее здесь: https://stackoverflow.com/questions/783 ... le-and-gen