diff --git a/src/Platform/CMakeLists.txt b/src/Platform/CMakeLists.txt index 3e52c59..26584e7 100644 --- a/src/Platform/CMakeLists.txt +++ b/src/Platform/CMakeLists.txt @@ -19,4 +19,4 @@ else() target_link_libraries(b_best Boost::boost "${XLSXWRITER_LIB}") endif() target_link_libraries(b_list ArffFiles mdlp "${TORCH_LIBRARIES}") -target_link_libraries(testx ArffFiles mdlp BayesNet "${TORCH_LIBRARIES}") \ No newline at end of file +target_link_libraries(testx ArffFiles BayesNet "${TORCH_LIBRARIES}") \ No newline at end of file diff --git a/src/Platform/testx.cpp b/src/Platform/testx.cpp index 1ab1d83..dfd6a21 100644 --- a/src/Platform/testx.cpp +++ b/src/Platform/testx.cpp @@ -1,5 +1,6 @@ #include "Folding.h" #include +#include "nlohmann/json.hpp" #include "map" #include #include @@ -8,6 +9,8 @@ #include "ArffFiles.h" #include "CPPFImdlp.h" #include "CFS.h" +#include "IWSS.h" +#include "FCBF.h" using namespace std; using namespace platform; @@ -209,6 +212,7 @@ int main() // cout << endl; // net.fit(raw.dataset, raw.weights, raw.featurest, raw.classNamet, raw.statest); auto dt = Datasets(true, "Arff"); + nlohmann::json output; for (const auto& name : dt.getNames()) { // for (const auto& name : { "iris" }) { auto [X, y] = dt.getTensors(name); @@ -222,13 +226,23 @@ int main() auto yresized = torch::transpose(y.view({ y.size(0), 1 }), 0, 1); dataset = torch::cat({ dataset, yresized }, 0); auto cfs = bayesnet::CFS(dataset, features, className, maxFeatures, classNumStates, weights); - cout << "Dataset: " << name << " CFS features: " << flush; + auto fcbf = bayesnet::FCBF(dataset, features, className, maxFeatures, classNumStates, weights, 1e-7); + auto iwss = bayesnet::IWSS(dataset, features, className, maxFeatures, classNumStates, weights, 0.5); + cout << "Dataset: " << setw(20) << name << flush; cfs.fit(); - for (const auto& feature : cfs.getFeatures()) { - cout << feature << ", "; - } - cout << "end." << endl; + cout << " CFS: " << setw(4) << cfs.getFeatures().size() << flush; + fcbf.fit(); + cout << " FCBF: " << setw(4) << fcbf.getFeatures().size() << flush; + iwss.fit(); + cout << " IWSS: " << setw(4) << iwss.getFeatures().size() << flush; + cout << endl; + output[name]["CFS"] = cfs.getFeatures(); + output[name]["FCBF"] = fcbf.getFeatures(); + output[name]["IWSS"] = iwss.getFeatures(); } + ofstream file("features_cpp.json"); + file << output; + file.close(); }