Check result with KDB(k=3)

Same experiment with KDB(k=3), dataset glass, from bayesclass & bayesnet
Had same result 0.841121
This commit is contained in:
Ricardo Montañana Gómez 2023-07-05 20:45:21 +02:00
parent a0114da70c
commit b9201cfeea
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
3 changed files with 11 additions and 5 deletions

2
.vscode/launch.json vendored
View File

@ -8,7 +8,7 @@
"program": "${workspaceFolder}/build/sample/main", "program": "${workspaceFolder}/build/sample/main",
"args": [ "args": [
"-f", "-f",
"iris" "glass"
], ],
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"preLaunchTask": "CMake: build" "preLaunchTask": "CMake: build"

View File

@ -63,7 +63,7 @@ void ArffFiles::load(const string& fileName, bool classLast)
type = ""; type = "";
while (ss >> type_w) while (ss >> type_w)
type += type_w + " "; type += type_w + " ";
attributes.emplace_back(attribute, trim(type)); attributes.emplace_back(trim(attribute), trim(type));
continue; continue;
} }
if (line[0] == '@') { if (line[0] == '@') {
@ -111,8 +111,8 @@ void ArffFiles::generateDataset(bool classLast)
string ArffFiles::trim(const string& source) string ArffFiles::trim(const string& source)
{ {
string s(source); string s(source);
s.erase(0, s.find_first_not_of(" \n\r\t")); s.erase(0, s.find_first_not_of(" '\n\r\t"));
s.erase(s.find_last_not_of(" \n\r\t") + 1); s.erase(s.find_last_not_of(" '\n\r\t") + 1);
return s; return s;
} }

View File

@ -213,6 +213,12 @@ int main(int argc, char** argv)
map<string, int> maxes; map<string, int> maxes;
tie(Xd, maxes) = discretize(X, y, features); tie(Xd, maxes) = discretize(X, y, features);
maxes[className] = *max_element(y.begin(), y.end()) + 1; maxes[className] = *max_element(y.begin(), y.end()) + 1;
cout << "Features: ";
for (auto feature : features) {
cout << "[" << feature << "] ";
}
cout << endl;
cout << "Class name: " << className << endl;
// Build Network // Build Network
auto network = bayesnet::Network(); auto network = bayesnet::Network();
build_network(network, network_name, maxes); build_network(network, network_name, maxes);