From 77bf2ecd2f1a873071b4d774fdca7560a9020a40 Mon Sep 17 00:00:00 2001 From: Maksim Date: Wed, 3 Apr 2024 02:01:09 +0300 Subject: [PATCH 1/3] Add new example dataset for AR --- examples/datasets/rules_book_rows.csv | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 examples/datasets/rules_book_rows.csv diff --git a/examples/datasets/rules_book_rows.csv b/examples/datasets/rules_book_rows.csv new file mode 100644 index 0000000000..982dbcaff1 --- /dev/null +++ b/examples/datasets/rules_book_rows.csv @@ -0,0 +1,5 @@ +Bread,Butter,Milk, +Eggs,Milk,Yogurt, +Bread,Cheese,Eggs,Milk +Eggs,Milk,Yogurt, +Cheese,Milk,Yogurt, From 0fc2d4ce23428882907425178c17e6877af0311d Mon Sep 17 00:00:00 2001 From: Maksim Date: Wed, 3 Apr 2024 02:02:17 +0300 Subject: [PATCH 2/3] Add python bindings for AR --- src/python_bindings/ar/bind_ar.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/python_bindings/ar/bind_ar.cpp b/src/python_bindings/ar/bind_ar.cpp index 84aac5fa87..9a03bf1c1a 100644 --- a/src/python_bindings/ar/bind_ar.cpp +++ b/src/python_bindings/ar/bind_ar.cpp @@ -14,15 +14,33 @@ namespace py = pybind11; namespace python_bindings { void BindAr(py::module_& main_module) { using namespace algos; + using model::ArIDs; using model::ARStrings; auto ar_module = main_module.def_submodule("ar"); - py::class_(ar_module, "AssociativeRule") + py::class_(ar_module, "ARStrings") .def("__str__", &ARStrings::ToString) .def_readonly("left", &ARStrings::left) .def_readonly("right", &ARStrings::right) .def_readonly("confidence", &ARStrings::confidence); - BindPrimitive(ar_module, &ARAlgorithm::GetArStringsList, "ArAlgorithm", "get_ars", - {"Apriori"}, py::return_value_policy::move); + + py::class_(ar_module, "ArIDs") + .def_readonly("left", &ArIDs::left) + .def_readonly("right", &ArIDs::right) + .def_readonly("confidence", &ArIDs::confidence); + + py::class_(ar_module, "ArAlgorithm") + .def("get_ars", &ARAlgorithm::GetArStringsList, + py::return_value_policy::reference_internal) + .def("get_itemnames", &ARAlgorithm::GetItemNamesVector) + .def("get_ar_ids", &ARAlgorithm::GetArIDsList); + + auto algos_module = ar_module.def_submodule("algorithms"); + auto default_algorithm = + detail::RegisterAlgorithm(algos_module, "Apriori"); + algos_module.attr("Default") = default_algorithm; + + // Perhaps in the future there will be a need for: + // default_algorithm.def("get_frequent_list", &Apriori::GetFrequentList); } } // namespace python_bindings From 49c14502728088d705266b9494895470c475db74 Mon Sep 17 00:00:00 2001 From: Alexey Shlyonskikh Date: Mon, 22 Apr 2024 19:06:57 +0300 Subject: [PATCH 3/3] Fix GFD header name --- src/core/algorithms/algorithms.h | 2 +- .../gfd/{mining_algorithms.h => verification_algorithms.h} | 0 src/python_bindings/gfd/bind_gfd_verification.cpp | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/core/algorithms/gfd/{mining_algorithms.h => verification_algorithms.h} (100%) diff --git a/src/core/algorithms/algorithms.h b/src/core/algorithms/algorithms.h index 385e02335b..84e308a2dc 100644 --- a/src/core/algorithms/algorithms.h +++ b/src/core/algorithms/algorithms.h @@ -5,7 +5,7 @@ #include "algorithms/cfd/mining_algorithms.h" #include "algorithms/fd/mining_algorithms.h" #include "algorithms/fd/verification_algorithms.h" -#include "algorithms/gfd/mining_algorithms.h" +#include "algorithms/gfd/verification_algorithms.h" #include "algorithms/ind/mining_algorithms.h" #include "algorithms/metric/verification_algorithms.h" #include "algorithms/od/mining_algorithms.h" diff --git a/src/core/algorithms/gfd/mining_algorithms.h b/src/core/algorithms/gfd/verification_algorithms.h similarity index 100% rename from src/core/algorithms/gfd/mining_algorithms.h rename to src/core/algorithms/gfd/verification_algorithms.h diff --git a/src/python_bindings/gfd/bind_gfd_verification.cpp b/src/python_bindings/gfd/bind_gfd_verification.cpp index 58f1068681..4361523e5a 100644 --- a/src/python_bindings/gfd/bind_gfd_verification.cpp +++ b/src/python_bindings/gfd/bind_gfd_verification.cpp @@ -3,7 +3,7 @@ #include #include -#include "algorithms/gfd/mining_algorithms.h" +#include "algorithms/gfd/verification_algorithms.h" #include "py_util/bind_primitive.h" namespace {