Disable Warning messages in python clfs

Disable removing Python env
This commit is contained in:
Ricardo Montañana Gómez 2023-11-16 22:38:46 +01:00
parent 408db2aad5
commit e2249eace7
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
3 changed files with 23 additions and 18 deletions

26
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "sample", "name": "sample",
"program": "${workspaceFolder}/build/sample/BayesNetSample", "program": "${workspaceFolder}/build_debug/sample/BayesNetSample",
"args": [ "args": [
"-d", "-d",
"iris", "iris",
@ -14,7 +14,7 @@
"-s", "-s",
"271", "271",
"-p", "-p",
"/Users/rmontanana/Code/discretizbench/datasets/", "/home/rmontanana/Code/discretizbench/datasets/",
], ],
//"cwd": "${workspaceFolder}/build/sample/", //"cwd": "${workspaceFolder}/build/sample/",
}, },
@ -22,24 +22,24 @@
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "experiment", "name": "experiment",
"program": "${workspaceFolder}/build/src/Platform/b_main", "program": "${workspaceFolder}/build_debug/src/Platform/b_main",
"args": [ "args": [
"-m", "-m",
"STree", "STree",
"--stratified", "--stratified",
"-d", "-d",
"zoo", "iris",
"--discretize" //"--discretize"
// "--hyperparameters", // "--hyperparameters",
// "{\"repeatSparent\": true, \"maxModels\": 12}" // "{\"repeatSparent\": true, \"maxModels\": 12}"
], ],
"cwd": "/Users/rmontanana/Code/odtebench", "cwd": "/home/rmontanana/Code/discretizbench",
}, },
{ {
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "best", "name": "best",
"program": "${workspaceFolder}/build/src/Platform/b_best", "program": "${workspaceFolder}/build_debug/src/Platform/b_best",
"args": [ "args": [
"-m", "-m",
"BoostAODE", "BoostAODE",
@ -47,24 +47,24 @@
"accuracy", "accuracy",
"--build", "--build",
], ],
"cwd": "/Users/rmontanana/Code/discretizbench", "cwd": "/home/rmontanana/Code/discretizbench",
}, },
{ {
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "manage", "name": "manage",
"program": "${workspaceFolder}/build/src/Platform/b_manage", "program": "${workspaceFolder}/build_debug/src/Platform/b_manage",
"args": [ "args": [
"-n", "-n",
"20" "20"
], ],
"cwd": "/Users/rmontanana/Code/discretizbench", "cwd": "/home/rmontanana/Code/discretizbench",
}, },
{ {
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "list", "name": "list",
"program": "${workspaceFolder}/build/src/Platform/b_list", "program": "${workspaceFolder}/build_debug/src/Platform/b_list",
"args": [], "args": [],
//"cwd": "/Users/rmontanana/Code/discretizbench", //"cwd": "/Users/rmontanana/Code/discretizbench",
"cwd": "/home/rmontanana/Code/covbench", "cwd": "/home/rmontanana/Code/covbench",
@ -73,7 +73,7 @@
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "test", "name": "test",
"program": "${workspaceFolder}/build/tests/unit_tests", "program": "${workspaceFolder}/build_debug/tests/unit_tests",
"args": [ "args": [
"-c=\"Metrics Test\"", "-c=\"Metrics Test\"",
// "-s", // "-s",
@ -84,7 +84,7 @@
"name": "Build & debug active file", "name": "Build & debug active file",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/build/bayesnet", "program": "${workspaceFolder}/build_debug/bayesnet",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",

View File

@ -168,8 +168,8 @@ namespace platform {
fold = new StratifiedKFold(nfolds, y, seed); fold = new StratifiedKFold(nfolds, y, seed);
else else
fold = new KFold(nfolds, y.size(0), seed); fold = new KFold(nfolds, y.size(0), seed);
auto clf = Models::instance()->create(model);
for (int nfold = 0; nfold < nfolds; nfold++) { for (int nfold = 0; nfold < nfolds; nfold++) {
auto clf = Models::instance()->create(model);
setModelVersion(clf->getVersion()); setModelVersion(clf->getVersion());
if (hyperparameters.size() != 0) { if (hyperparameters.size() != 0) {
clf->setHyperparameters(hyperparameters); clf->setHyperparameters(hyperparameters);
@ -211,8 +211,8 @@ namespace platform {
result.addTimeTrain(train_time[item].item<double>()); result.addTimeTrain(train_time[item].item<double>());
result.addTimeTest(test_time[item].item<double>()); result.addTimeTest(test_time[item].item<double>());
item++; item++;
clf.reset();
} }
clf.reset();
if (!quiet) if (!quiet)
std::cout << "end. " << flush; std::cout << "end. " << flush;
delete fold; delete fold;

View File

@ -5,6 +5,7 @@
#include <map> #include <map>
#include <sstream> #include <sstream>
#include <boost/python/numpy.hpp> #include <boost/python/numpy.hpp>
#include <iostream>
namespace pywrap { namespace pywrap {
namespace np = boost::python::numpy; namespace np = boost::python::numpy;
@ -19,6 +20,7 @@ namespace pywrap {
if (wrapper == nullptr) { if (wrapper == nullptr) {
wrapper = new PyWrap(); wrapper = new PyWrap();
pyInstance = new CPyInstance(); pyInstance = new CPyInstance();
PyRun_SimpleString("import warnings;warnings.filterwarnings('ignore')");
} }
return wrapper; return wrapper;
} }
@ -59,6 +61,7 @@ namespace pywrap {
void PyWrap::clean(const clfId_t id) void PyWrap::clean(const clfId_t id)
{ {
// Remove Python interpreter if no more modules imported left // Remove Python interpreter if no more modules imported left
// std::cout << "*Cleaning module " << id << std::endl;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
auto result = moduleClassMap.find(id); auto result = moduleClassMap.find(id);
if (result == moduleClassMap.end()) { if (result == moduleClassMap.end()) {
@ -72,9 +75,11 @@ namespace pywrap {
PyErr_Print(); PyErr_Print();
errorAbort("Error cleaning module "); errorAbort("Error cleaning module ");
} }
if (moduleClassMap.empty()) { // if (moduleClassMap.empty()) {
RemoveInstance(); // RemoveInstance();
} // std::cout << "*Python interpreter cleaned" << std::endl;
// }
// std::cout << "*Module " << id << " cleaned" << std::endl;
} }
void PyWrap::errorAbort(const std::string& message) void PyWrap::errorAbort(const std::string& message)
{ {