Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
43ceefd2c9 | |||
e6501502d1 | |||
d84adf6172 | |||
268a86cbe0 | |||
fc4c93b299 | |||
86f2bc44fc | |||
f0f3d9ad6e | |||
9a323cd7a3 | |||
cb949ac7e5 | |||
2c297ea15d | |||
4e4b6e67f4 | |||
82847774ee | |||
d0955d9369 | |||
2d34eb8c89 | |||
0159c397fa | |||
0bbc8328a9 | |||
35ca862eca | |||
26eb58b104 | |||
6fcc15d39a | |||
9a14133be5 | |||
59c1cf5b3b | |||
8e9090d283 | |||
02bcab01be | |||
716748e18c | |||
0b31780d39 | |||
fa26aa80f7 | |||
3eb61905fb | |||
ca0ae4dacf | |||
b34869cc61 | |||
27a3e5a5e0 | |||
684443a788 | |||
6d9badc33b | |||
015b1b0c0f | |||
7bb8e4df01 | |||
53710378de | |||
c833e9ba32 | |||
f5cb46ee29 | |||
fa35681abe | |||
b0bd0e6eee | |||
d43be27821 | |||
a2853dd2e5 | |||
0341bd5648 | |||
22b742f068 | |||
2584e8294d | |||
291ba0fb0e | |||
80043d5181 | |||
677ec5613d | |||
cccaa6e0af | |||
2e3e0e0fc2 | |||
8784a24898 | |||
54496c68f1 | |||
1f236a70db | |||
ef3c74633c | |||
7efd95095c |
@ -1,4 +1,4 @@
|
|||||||
compilation_database_dir: build_debug
|
compilation_database_dir: build_Debug
|
||||||
output_directory: diagrams
|
output_directory: diagrams
|
||||||
diagrams:
|
diagrams:
|
||||||
BayesNet:
|
BayesNet:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM mcr.microsoft.com/devcontainers/cpp:ubuntu22.04
|
FROM mcr.microsoft.com/devcontainers/cpp:ubuntu22.04
|
||||||
|
|
||||||
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"
|
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.29.3"
|
||||||
|
|
||||||
# Optionally install the cmake for vcpkg
|
# Optionally install the cmake for vcpkg
|
||||||
COPY ./reinstall-cmake.sh /tmp/
|
COPY ./reinstall-cmake.sh /tmp/
|
||||||
@ -23,7 +23,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test
|
|||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
|
||||||
# Install GCC 13.1
|
# Install GCC 13.1
|
||||||
RUN apt-get install -y gcc-13 g++-13
|
RUN apt-get install -y gcc-13 g++-13 doxygen
|
||||||
|
|
||||||
# Install lcov 2.1
|
# Install lcov 2.1
|
||||||
RUN wget --quiet https://github.com/linux-test-project/lcov/releases/download/v2.1/lcov-2.1.tar.gz && \
|
RUN wget --quiet https://github.com/linux-test-project/lcov/releases/download/v2.1/lcov-2.1.tar.gz && \
|
||||||
|
4
.gitignore
vendored
@ -40,4 +40,8 @@ puml/**
|
|||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
sample/build
|
sample/build
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
docs/manual
|
||||||
|
docs/man3
|
||||||
|
docs/man
|
||||||
|
docs/Doxyfile
|
||||||
|
|
||||||
|
11
.gitmodules
vendored
@ -1,8 +1,3 @@
|
|||||||
[submodule "lib/mdlp"]
|
|
||||||
path = lib/mdlp
|
|
||||||
url = https://github.com/rmontanana/mdlp
|
|
||||||
main = main
|
|
||||||
update = merge
|
|
||||||
[submodule "lib/json"]
|
[submodule "lib/json"]
|
||||||
path = lib/json
|
path = lib/json
|
||||||
url = https://github.com/nlohmann/json.git
|
url = https://github.com/nlohmann/json.git
|
||||||
@ -18,3 +13,9 @@
|
|||||||
url = https://github.com/catchorg/Catch2.git
|
url = https://github.com/catchorg/Catch2.git
|
||||||
main = main
|
main = main
|
||||||
update = merge
|
update = merge
|
||||||
|
[submodule "tests/lib/Files"]
|
||||||
|
path = tests/lib/Files
|
||||||
|
url = https://github.com/rmontanana/ArffFiles
|
||||||
|
[submodule "lib/mdlp"]
|
||||||
|
path = lib/mdlp
|
||||||
|
url = https://github.com/rmontanana/mdlp
|
||||||
|
6
.vscode/launch.json
vendored
@ -14,11 +14,11 @@
|
|||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"program": "${workspaceFolder}/build_debug/tests/TestBayesNet",
|
"program": "${workspaceFolder}/build_Debug/tests/TestBayesNet",
|
||||||
"args": [
|
"args": [
|
||||||
"[Node]"
|
"No features selected"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceFolder}/build_debug/tests"
|
"cwd": "${workspaceFolder}/build_Debug/tests"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "(gdb) Launch",
|
"name": "(gdb) Launch",
|
||||||
|
27
CHANGELOG.md
@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.0.6] 2024-11-23
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Prevent existing edges to be added to the network in the `add_edge` method.
|
||||||
|
- Don't allow to add nodes or edges on already fiited networks.
|
||||||
|
- Number of threads spawned
|
||||||
|
- Network class tests
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Library logo generated with <https://openart.ai> to README.md
|
- Library logo generated with <https://openart.ai> to README.md
|
||||||
@ -14,12 +23,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- *convergence_best* hyperparameter to the BoostAODE class, to control the way the prior accuracy is computed if convergence is set. Default value is *false*.
|
- *convergence_best* hyperparameter to the BoostAODE class, to control the way the prior accuracy is computed if convergence is set. Default value is *false*.
|
||||||
- SPnDE model.
|
- SPnDE model.
|
||||||
- A2DE model.
|
- A2DE model.
|
||||||
|
- BoostA2DE model.
|
||||||
- A2DE & SPnDE tests.
|
- A2DE & SPnDE tests.
|
||||||
- Add tests to reach 99% of coverage.
|
- Add tests to reach 99% of coverage.
|
||||||
- Add tests to check the correct version of the mdlp, folding and json libraries.
|
- Add tests to check the correct version of the mdlp, folding and json libraries.
|
||||||
|
- Library documentation generated with Doxygen.
|
||||||
|
- Link to documentation in the README.md.
|
||||||
|
- Three types of smoothing the Bayesian Network ORIGINAL, LAPLACE and CESTNIK.
|
||||||
|
|
||||||
### Internal
|
### Internal
|
||||||
|
|
||||||
|
- Fixed doxygen optional dependency
|
||||||
|
- Add env parallel variable to Makefile
|
||||||
|
- Add CountingSemaphore class to manage the number of threads spawned.
|
||||||
|
- Ignore CUDA language in CMake CodeCoverage module.
|
||||||
|
- Update mdlp library as a git submodule.
|
||||||
- Create library ShuffleArffFile to limit the number of samples with a parameter and shuffle them.
|
- Create library ShuffleArffFile to limit the number of samples with a parameter and shuffle them.
|
||||||
- Refactor catch2 library location to test/lib
|
- Refactor catch2 library location to test/lib
|
||||||
- Refactor loadDataset function in tests.
|
- Refactor loadDataset function in tests.
|
||||||
@ -27,6 +45,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Refactor Coverage Report generation.
|
- Refactor Coverage Report generation.
|
||||||
- Add devcontainer to work on apple silicon.
|
- Add devcontainer to work on apple silicon.
|
||||||
- Change build cmake folder names to Debug & Release.
|
- Change build cmake folder names to Debug & Release.
|
||||||
|
- Add a Makefile target (doc) to generate the documentation.
|
||||||
|
- Add a Makefile target (doc-install) to install the documentation.
|
||||||
|
|
||||||
|
### Libraries versions
|
||||||
|
|
||||||
|
- mdlp: 2.0.1
|
||||||
|
- Folding: 1.1.0
|
||||||
|
- json: 3.11
|
||||||
|
- ArffFiles: 1.1.0
|
||||||
|
|
||||||
## [1.0.5] 2024-04-20
|
## [1.0.5] 2024-04-20
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(BayesNet
|
project(BayesNet
|
||||||
VERSION 1.0.5.1
|
VERSION 1.0.6
|
||||||
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
||||||
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
@ -25,8 +25,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors -fno-default-inline")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
|
||||||
|
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
# -------
|
# -------
|
||||||
@ -46,11 +49,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
set(CODE_COVERAGE ON)
|
set(CODE_COVERAGE ON)
|
||||||
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
|
||||||
|
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||||
|
message(STATUS "Languages=${LANGUAGES}")
|
||||||
if (CODE_COVERAGE)
|
if (CODE_COVERAGE)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
include(CodeCoverage)
|
include(CodeCoverage)
|
||||||
MESSAGE("Code coverage enabled")
|
MESSAGE(STATUS "Code coverage enabled")
|
||||||
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||||
endif (CODE_COVERAGE)
|
endif (CODE_COVERAGE)
|
||||||
|
|
||||||
@ -60,10 +64,10 @@ endif (ENABLE_CLANG_TIDY)
|
|||||||
|
|
||||||
# External libraries - dependencies of BayesNet
|
# External libraries - dependencies of BayesNet
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
|
|
||||||
# include(FetchContent)
|
# include(FetchContent)
|
||||||
add_git_submodule("lib/json")
|
add_git_submodule("lib/json")
|
||||||
add_git_submodule("lib/mdlp")
|
add_git_submodule("lib/mdlp")
|
||||||
add_subdirectory("lib/Files")
|
|
||||||
|
|
||||||
# Subdirectories
|
# Subdirectories
|
||||||
# --------------
|
# --------------
|
||||||
@ -73,7 +77,7 @@ add_subdirectory(bayesnet)
|
|||||||
# Testing
|
# Testing
|
||||||
# -------
|
# -------
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
MESSAGE("Testing enabled")
|
MESSAGE(STATUS "Testing enabled")
|
||||||
add_subdirectory(tests/lib/catch2)
|
add_subdirectory(tests/lib/catch2)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
@ -87,3 +91,18 @@ install(TARGETS BayesNet
|
|||||||
CONFIGURATIONS Release)
|
CONFIGURATIONS Release)
|
||||||
install(DIRECTORY bayesnet/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
|
install(DIRECTORY bayesnet/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)
|
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
# -------------
|
||||||
|
find_package(Doxygen)
|
||||||
|
if (Doxygen_FOUND)
|
||||||
|
set(DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
|
||||||
|
set(doxyfile_in ${DOC_DIR}/Doxyfile.in)
|
||||||
|
set(doxyfile ${DOC_DIR}/Doxyfile)
|
||||||
|
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
|
||||||
|
doxygen_add_docs(doxygen
|
||||||
|
WORKING_DIRECTORY ${DOC_DIR}
|
||||||
|
CONFIG_FILE ${doxyfile})
|
||||||
|
else (Doxygen_FOUND)
|
||||||
|
MESSAGE("* Doxygen not found")
|
||||||
|
endif (Doxygen_FOUND)
|
||||||
|
57
Makefile
@ -1,6 +1,6 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge
|
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge doc doc-install
|
||||||
|
|
||||||
f_release = build_Release
|
f_release = build_Release
|
||||||
f_debug = build_Debug
|
f_debug = build_Debug
|
||||||
@ -12,7 +12,11 @@ plantuml = plantuml
|
|||||||
lcov = lcov
|
lcov = lcov
|
||||||
genhtml = genhtml
|
genhtml = genhtml
|
||||||
dot = dot
|
dot = dot
|
||||||
n_procs = -j 16
|
docsrcdir = docs/manual
|
||||||
|
mansrcdir = docs/man3
|
||||||
|
mandestdir = /usr/local/share/man
|
||||||
|
sed_command_link = 's/e">LCOV -/e"><a href="https:\/\/rmontanana.github.io\/bayesnet">Back to manual<\/a> LCOV -/g'
|
||||||
|
sed_command_diagram = 's/Diagram"/Diagram" width="100%" height="100%" /g'
|
||||||
|
|
||||||
define ClearTests
|
define ClearTests
|
||||||
@for t in $(test_targets); do \
|
@for t in $(test_targets); do \
|
||||||
@ -39,7 +43,7 @@ setup: ## Install dependencies for tests and coverage
|
|||||||
fi
|
fi
|
||||||
@echo "* You should install plantuml & graphviz for the diagrams"
|
@echo "* You should install plantuml & graphviz for the diagrams"
|
||||||
|
|
||||||
diagrams: ## Create an UML class diagram & depnendency of the project (diagrams/BayesNet.png)
|
diagrams: ## Create an UML class diagram & dependency of the project (diagrams/BayesNet.png)
|
||||||
@which $(plantuml) || (echo ">>> Please install plantuml"; exit 1)
|
@which $(plantuml) || (echo ">>> Please install plantuml"; exit 1)
|
||||||
@which $(dot) || (echo ">>> Please install graphviz"; exit 1)
|
@which $(dot) || (echo ">>> Please install graphviz"; exit 1)
|
||||||
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
|
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
|
||||||
@ -54,10 +58,10 @@ diagrams: ## Create an UML class diagram & depnendency of the project (diagrams/
|
|||||||
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
|
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
|
||||||
|
|
||||||
buildd: ## Build the debug targets
|
buildd: ## Build the debug targets
|
||||||
cmake --build $(f_debug) -t $(app_targets) $(n_procs)
|
cmake --build $(f_debug) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
||||||
|
|
||||||
buildr: ## Build the release targets
|
buildr: ## Build the release targets
|
||||||
cmake --build $(f_release) -t $(app_targets) $(n_procs)
|
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
||||||
|
|
||||||
clean: ## Clean the tests info
|
clean: ## Clean the tests info
|
||||||
@echo ">>> Cleaning Debug BayesNet tests...";
|
@echo ">>> Cleaning Debug BayesNet tests...";
|
||||||
@ -101,7 +105,7 @@ opt = ""
|
|||||||
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
||||||
@echo ">>> Running BayesNet tests...";
|
@echo ">>> Running BayesNet tests...";
|
||||||
@$(MAKE) clean
|
@$(MAKE) clean
|
||||||
@cmake --build $(f_debug) -t $(test_targets) $(n_procs)
|
@cmake --build $(f_debug) -t $(test_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
||||||
@for t in $(test_targets); do \
|
@for t in $(test_targets); do \
|
||||||
echo ">>> Running $$t...";\
|
echo ">>> Running $$t...";\
|
||||||
if [ -f $(f_debug)/tests/$$t ]; then \
|
if [ -f $(f_debug)/tests/$$t ]; then \
|
||||||
@ -114,7 +118,7 @@ test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximu
|
|||||||
|
|
||||||
coverage: ## Run tests and generate coverage report (build/index.html)
|
coverage: ## Run tests and generate coverage report (build/index.html)
|
||||||
@echo ">>> Building tests with coverage..."
|
@echo ">>> Building tests with coverage..."
|
||||||
@which $(lcov) || (echo ">>> Please install lcov"; exit 1)
|
@which $(lcov) || (echo ">>ease install lcov"; exit 1)
|
||||||
@if [ ! -f $(f_debug)/tests/coverage.info ] ; then $(MAKE) test ; fi
|
@if [ ! -f $(f_debug)/tests/coverage.info ] ; then $(MAKE) test ; fi
|
||||||
@echo ">>> Building report..."
|
@echo ">>> Building report..."
|
||||||
@cd $(f_debug)/tests; \
|
@cd $(f_debug)/tests; \
|
||||||
@ -130,9 +134,14 @@ coverage: ## Run tests and generate coverage report (build/index.html)
|
|||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
viewcoverage: ## View the html coverage report
|
viewcoverage: ## View the html coverage report
|
||||||
@which $(genhtml) || (echo ">>> Please install lcov (genhtml not found)"; exit 1)
|
@which $(genhtml) >/dev/null || (echo ">>> Please install lcov (genhtml not found)"; exit 1)
|
||||||
@$(genhtml) $(f_debug)/tests/coverage.info --demangle-cpp --output-directory html --title "BayesNet Coverage Report" -s -k -f --legend >/dev/null 2>&1;
|
@if [ ! -d $(docsrcdir)/coverage ]; then mkdir -p $(docsrcdir)/coverage; fi
|
||||||
@xdg-open html/index.html || open html/index.html 2>/dev/null
|
@if [ ! -f $(f_debug)/tests/coverage.info ]; then \
|
||||||
|
echo ">>> No coverage.info file found. Run make coverage first!"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@$(genhtml) $(f_debug)/tests/coverage.info --demangle-cpp --output-directory $(docsrcdir)/coverage --title "BayesNet Coverage Report" -s -k -f --legend >/dev/null 2>&1;
|
||||||
|
@xdg-open $(docsrcdir)/coverage/index.html || open $(docsrcdir)/coverage/index.html 2>/dev/null
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
updatebadge: ## Update the coverage badge in README.md
|
updatebadge: ## Update the coverage badge in README.md
|
||||||
@ -145,6 +154,34 @@ updatebadge: ## Update the coverage badge in README.md
|
|||||||
@env python update_coverage.py $(f_debug)/tests
|
@env python update_coverage.py $(f_debug)/tests
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
doc: ## Generate documentation
|
||||||
|
@echo ">>> Generating documentation..."
|
||||||
|
@cmake --build $(f_release) -t doxygen
|
||||||
|
@cp -rp diagrams $(docsrcdir)
|
||||||
|
@
|
||||||
|
@if [ "$(shell uname)" = "Darwin" ]; then \
|
||||||
|
sed -i "" $(sed_command_link) $(docsrcdir)/coverage/index.html ; \
|
||||||
|
sed -i "" $(sed_command_diagram) $(docsrcdir)/index.html ; \
|
||||||
|
else \
|
||||||
|
sed -i $(sed_command_link) $(docsrcdir)/coverage/index.html ; \
|
||||||
|
sed -i $(sed_command_diagram) $(docsrcdir)/index.html ; \
|
||||||
|
fi
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
docdir = ""
|
||||||
|
doc-install: ## Install documentation
|
||||||
|
@echo ">>> Installing documentation..."
|
||||||
|
@if [ "$(docdir)" = "" ]; then \
|
||||||
|
echo "docdir parameter has to be set when calling doc-install, i.e. docdir=../bayesnet_help"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@if [ ! -d $(docdir) ]; then \
|
||||||
|
@$(MAKE) doc; \
|
||||||
|
fi
|
||||||
|
@cp -rp $(docsrcdir)/* $(docdir)
|
||||||
|
@sudo cp -rp $(mansrcdir) $(mandestdir)
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
help: ## Show help message
|
help: ## Show help message
|
||||||
@IFS=$$'\n' ; \
|
@IFS=$$'\n' ; \
|
||||||
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
||||||
|
21
README.md
@ -7,9 +7,10 @@
|
|||||||
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_BayesNet&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
|
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_BayesNet&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
|
||||||
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_BayesNet&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
|
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_BayesNet&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
|
||||||
![Gitea Last Commit](https://img.shields.io/gitea/last-commit/rmontanana/bayesnet?gitea_url=https://gitea.rmontanana.es:3000&logo=gitea)
|
![Gitea Last Commit](https://img.shields.io/gitea/last-commit/rmontanana/bayesnet?gitea_url=https://gitea.rmontanana.es:3000&logo=gitea)
|
||||||
[![Coverage Badge](https://img.shields.io/badge/Coverage-99,0%25-green)](html/index.html)
|
[![Coverage Badge](https://img.shields.io/badge/Coverage-99,1%25-green)](html/index.html)
|
||||||
|
[![DOI](https://zenodo.org/badge/667782806.svg)](https://doi.org/10.5281/zenodo.14210344)
|
||||||
|
|
||||||
Bayesian Network Classifiers using libtorch from scratch
|
Bayesian Network Classifiers library
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@ -67,10 +68,16 @@ make sample fname=tests/data/glass.arff
|
|||||||
|
|
||||||
#### - SPODE
|
#### - SPODE
|
||||||
|
|
||||||
|
#### - SPnDE
|
||||||
|
|
||||||
#### - AODE
|
#### - AODE
|
||||||
|
|
||||||
|
#### - A2DE
|
||||||
|
|
||||||
#### - [BoostAODE](docs/BoostAODE.md)
|
#### - [BoostAODE](docs/BoostAODE.md)
|
||||||
|
|
||||||
|
#### - BoostA2DE
|
||||||
|
|
||||||
### With Local Discretization
|
### With Local Discretization
|
||||||
|
|
||||||
#### - TANLd
|
#### - TANLd
|
||||||
@ -81,6 +88,12 @@ make sample fname=tests/data/glass.arff
|
|||||||
|
|
||||||
#### - AODELd
|
#### - AODELd
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
### [Manual](https://rmontanana.github.io/bayesnet/)
|
||||||
|
|
||||||
|
### [Coverage report](https://rmontanana.github.io/bayesnet/coverage/index.html)
|
||||||
|
|
||||||
## Diagrams
|
## Diagrams
|
||||||
|
|
||||||
### UML Class Diagram
|
### UML Class Diagram
|
||||||
@ -90,7 +103,3 @@ make sample fname=tests/data/glass.arff
|
|||||||
### Dependency Diagram
|
### Dependency Diagram
|
||||||
|
|
||||||
![BayesNet Dependency Diagram](diagrams/dependency.svg)
|
![BayesNet Dependency Diagram](diagrams/dependency.svg)
|
||||||
|
|
||||||
## Coverage report
|
|
||||||
|
|
||||||
### [Coverage report](docs/coverage.pdf)
|
|
||||||
|
@ -8,16 +8,18 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include "bayesnet/network/Network.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
enum status_t { NORMAL, WARNING, ERROR };
|
enum status_t { NORMAL, WARNING, ERROR };
|
||||||
class BaseClassifier {
|
class BaseClassifier {
|
||||||
public:
|
public:
|
||||||
// X is nxm std::vector, y is nx1 std::vector
|
// X is nxm std::vector, y is nx1 std::vector
|
||||||
virtual BaseClassifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;
|
virtual BaseClassifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) = 0;
|
||||||
// X is nxm tensor, y is nx1 tensor
|
// X is nxm tensor, y is nx1 tensor
|
||||||
virtual BaseClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;
|
virtual BaseClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) = 0;
|
||||||
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;
|
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) = 0;
|
||||||
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) = 0;
|
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing) = 0;
|
||||||
virtual ~BaseClassifier() = default;
|
virtual ~BaseClassifier() = default;
|
||||||
torch::Tensor virtual predict(torch::Tensor& X) = 0;
|
torch::Tensor virtual predict(torch::Tensor& X) = 0;
|
||||||
std::vector<int> virtual predict(std::vector<std::vector<int >>& X) = 0;
|
std::vector<int> virtual predict(std::vector<std::vector<int >>& X) = 0;
|
||||||
@ -39,7 +41,7 @@ namespace bayesnet {
|
|||||||
virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;
|
virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;
|
||||||
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
|
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
|
||||||
protected:
|
protected:
|
||||||
virtual void trainModel(const torch::Tensor& weights) = 0;
|
virtual void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) = 0;
|
||||||
std::vector<std::string> validHyperparameters;
|
std::vector<std::string> validHyperparameters;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
include_directories(
|
include_directories(
|
||||||
${BayesNet_SOURCE_DIR}/lib/mdlp
|
${BayesNet_SOURCE_DIR}/lib/mdlp/src
|
||||||
${BayesNet_SOURCE_DIR}/lib/Files
|
|
||||||
${BayesNet_SOURCE_DIR}/lib/folding
|
${BayesNet_SOURCE_DIR}/lib/folding
|
||||||
${BayesNet_SOURCE_DIR}/lib/json/include
|
${BayesNet_SOURCE_DIR}/lib/json/include
|
||||||
${BayesNet_SOURCE_DIR}
|
${BayesNet_SOURCE_DIR}
|
||||||
@ -10,4 +9,4 @@ include_directories(
|
|||||||
file(GLOB_RECURSE Sources "*.cc")
|
file(GLOB_RECURSE Sources "*.cc")
|
||||||
|
|
||||||
add_library(BayesNet ${Sources})
|
add_library(BayesNet ${Sources})
|
||||||
target_link_libraries(BayesNet mdlp "${TORCH_LIBRARIES}")
|
target_link_libraries(BayesNet fimdlp "${TORCH_LIBRARIES}")
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}
|
Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}
|
||||||
const std::string CLASSIFIER_NOT_FITTED = "Classifier has not been fitted";
|
const std::string CLASSIFIER_NOT_FITTED = "Classifier has not been fitted";
|
||||||
Classifier& Classifier::build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)
|
Classifier& Classifier::build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
this->features = features;
|
this->features = features;
|
||||||
this->className = className;
|
this->className = className;
|
||||||
@ -23,7 +23,7 @@ namespace bayesnet {
|
|||||||
metrics = Metrics(dataset, features, className, n_classes);
|
metrics = Metrics(dataset, features, className, n_classes);
|
||||||
model.initialize();
|
model.initialize();
|
||||||
buildModel(weights);
|
buildModel(weights);
|
||||||
trainModel(weights);
|
trainModel(weights, smoothing);
|
||||||
fitted = true;
|
fitted = true;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -41,20 +41,20 @@ namespace bayesnet {
|
|||||||
throw std::runtime_error(oss.str());
|
throw std::runtime_error(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Classifier::trainModel(const torch::Tensor& weights)
|
void Classifier::trainModel(const torch::Tensor& weights, Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
model.fit(dataset, weights, features, className, states);
|
model.fit(dataset, weights, features, className, states, smoothing);
|
||||||
}
|
}
|
||||||
// X is nxm where n is the number of features and m the number of samples
|
// X is nxm where n is the number of features and m the number of samples
|
||||||
Classifier& Classifier::fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)
|
Classifier& Classifier::fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
dataset = X;
|
dataset = X;
|
||||||
buildDataset(y);
|
buildDataset(y);
|
||||||
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
|
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
|
||||||
return build(features, className, states, weights);
|
return build(features, className, states, weights, smoothing);
|
||||||
}
|
}
|
||||||
// X is nxm where n is the number of features and m the number of samples
|
// X is nxm where n is the number of features and m the number of samples
|
||||||
Classifier& Classifier::fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)
|
Classifier& Classifier::fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
dataset = torch::zeros({ static_cast<int>(X.size()), static_cast<int>(X[0].size()) }, torch::kInt32);
|
dataset = torch::zeros({ static_cast<int>(X.size()), static_cast<int>(X[0].size()) }, torch::kInt32);
|
||||||
for (int i = 0; i < X.size(); ++i) {
|
for (int i = 0; i < X.size(); ++i) {
|
||||||
@ -63,18 +63,18 @@ namespace bayesnet {
|
|||||||
auto ytmp = torch::tensor(y, torch::kInt32);
|
auto ytmp = torch::tensor(y, torch::kInt32);
|
||||||
buildDataset(ytmp);
|
buildDataset(ytmp);
|
||||||
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
|
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
|
||||||
return build(features, className, states, weights);
|
return build(features, className, states, weights, smoothing);
|
||||||
}
|
}
|
||||||
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)
|
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
this->dataset = dataset;
|
this->dataset = dataset;
|
||||||
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
|
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
|
||||||
return build(features, className, states, weights);
|
return build(features, className, states, weights, smoothing);
|
||||||
}
|
}
|
||||||
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)
|
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
this->dataset = dataset;
|
this->dataset = dataset;
|
||||||
return build(features, className, states, weights);
|
return build(features, className, states, weights, smoothing);
|
||||||
}
|
}
|
||||||
void Classifier::checkFitParameters()
|
void Classifier::checkFitParameters()
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define CLASSIFIER_H
|
#define CLASSIFIER_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include "bayesnet/utils/BayesMetrics.h"
|
#include "bayesnet/utils/BayesMetrics.h"
|
||||||
#include "bayesnet/network/Network.h"
|
|
||||||
#include "bayesnet/BaseClassifier.h"
|
#include "bayesnet/BaseClassifier.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
@ -16,10 +15,10 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
Classifier(Network model);
|
Classifier(Network model);
|
||||||
virtual ~Classifier() = default;
|
virtual ~Classifier() = default;
|
||||||
Classifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
|
Classifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
Classifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
|
Classifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
|
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) override;
|
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||||
void addNodes();
|
void addNodes();
|
||||||
int getNumberOfNodes() const override;
|
int getNumberOfNodes() const override;
|
||||||
int getNumberOfEdges() const override;
|
int getNumberOfEdges() const override;
|
||||||
@ -51,10 +50,10 @@ namespace bayesnet {
|
|||||||
std::vector<std::string> notes; // Used to store messages occurred during the fit process
|
std::vector<std::string> notes; // Used to store messages occurred during the fit process
|
||||||
void checkFitParameters();
|
void checkFitParameters();
|
||||||
virtual void buildModel(const torch::Tensor& weights) = 0;
|
virtual void buildModel(const torch::Tensor& weights) = 0;
|
||||||
void trainModel(const torch::Tensor& weights) override;
|
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||||
void buildDataset(torch::Tensor& y);
|
void buildDataset(torch::Tensor& y);
|
||||||
private:
|
private:
|
||||||
Classifier& build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
|
Classifier& build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}
|
KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}
|
||||||
KDBLd& KDBLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
KDBLd& KDBLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
checkInput(X_, y_);
|
checkInput(X_, y_);
|
||||||
features = features_;
|
features = features_;
|
||||||
@ -19,7 +19,7 @@ namespace bayesnet {
|
|||||||
states = fit_local_discretization(y);
|
states = fit_local_discretization(y);
|
||||||
// We have discretized the input data
|
// We have discretized the input data
|
||||||
// 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network
|
// 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network
|
||||||
KDB::fit(dataset, features, className, states);
|
KDB::fit(dataset, features, className, states, smoothing);
|
||||||
states = localDiscretizationProposal(states, model);
|
states = localDiscretizationProposal(states, model);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
explicit KDBLd(int k);
|
explicit KDBLd(int k);
|
||||||
virtual ~KDBLd() = default;
|
virtual ~KDBLd() = default;
|
||||||
KDBLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
KDBLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
std::vector<std::string> graph(const std::string& name = "KDB") const override;
|
std::vector<std::string> graph(const std::string& name = "KDB") const override;
|
||||||
torch::Tensor predict(torch::Tensor& X) override;
|
torch::Tensor predict(torch::Tensor& X) override;
|
||||||
static inline std::string version() { return "0.0.1"; };
|
static inline std::string version() { return "0.0.1"; };
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
// ***************************************************************
|
// ***************************************************************
|
||||||
|
|
||||||
#include <ArffFiles.h>
|
|
||||||
#include "Proposal.h"
|
#include "Proposal.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
@ -54,8 +53,7 @@ namespace bayesnet {
|
|||||||
yJoinParents[i] += to_string(pDataset.index({ idx, i }).item<int>());
|
yJoinParents[i] += to_string(pDataset.index({ idx, i }).item<int>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto arff = ArffFiles();
|
auto yxv = factorize(yJoinParents);
|
||||||
auto yxv = arff.factorize(yJoinParents);
|
|
||||||
auto xvf_ptr = Xf.index({ index }).data_ptr<float>();
|
auto xvf_ptr = Xf.index({ index }).data_ptr<float>();
|
||||||
auto xvf = std::vector<mdlp::precision_t>(xvf_ptr, xvf_ptr + Xf.size(1));
|
auto xvf = std::vector<mdlp::precision_t>(xvf_ptr, xvf_ptr + Xf.size(1));
|
||||||
discretizers[feature]->fit(xvf, yxv);
|
discretizers[feature]->fit(xvf, yxv);
|
||||||
@ -72,7 +70,7 @@ namespace bayesnet {
|
|||||||
states[pFeatures[index]] = xStates;
|
states[pFeatures[index]] = xStates;
|
||||||
}
|
}
|
||||||
const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);
|
const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);
|
||||||
model.fit(pDataset, weights, pFeatures, pClassName, states);
|
model.fit(pDataset, weights, pFeatures, pClassName, states, Smoothing_t::ORIGINAL);
|
||||||
}
|
}
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
@ -113,4 +111,19 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
return Xtd;
|
return Xtd;
|
||||||
}
|
}
|
||||||
|
std::vector<int> Proposal::factorize(const std::vector<std::string>& labels_t)
|
||||||
|
{
|
||||||
|
std::vector<int> yy;
|
||||||
|
yy.reserve(labels_t.size());
|
||||||
|
std::map<std::string, int> labelMap;
|
||||||
|
int i = 0;
|
||||||
|
for (const std::string& label : labels_t) {
|
||||||
|
if (labelMap.find(label) == labelMap.end()) {
|
||||||
|
labelMap[label] = i++;
|
||||||
|
bool allDigits = std::all_of(label.begin(), label.end(), ::isdigit);
|
||||||
|
}
|
||||||
|
yy.push_back(labelMap[label]);
|
||||||
|
}
|
||||||
|
return yy;
|
||||||
|
}
|
||||||
}
|
}
|
@ -27,6 +27,7 @@ namespace bayesnet {
|
|||||||
torch::Tensor y; // y discrete nx1 tensor
|
torch::Tensor y; // y discrete nx1 tensor
|
||||||
map<std::string, mdlp::CPPFImdlp*> discretizers;
|
map<std::string, mdlp::CPPFImdlp*> discretizers;
|
||||||
private:
|
private:
|
||||||
|
std::vector<int> factorize(const std::vector<std::string>& labels_t);
|
||||||
torch::Tensor& pDataset; // (n+1)xm tensor
|
torch::Tensor& pDataset; // (n+1)xm tensor
|
||||||
std::vector<std::string>& pFeatures;
|
std::vector<std::string>& pFeatures;
|
||||||
std::string& pClassName;
|
std::string& pClassName;
|
||||||
|
@ -8,25 +8,25 @@
|
|||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
SPODELd::SPODELd(int root) : SPODE(root), Proposal(dataset, features, className) {}
|
SPODELd::SPODELd(int root) : SPODE(root), Proposal(dataset, features, className) {}
|
||||||
SPODELd& SPODELd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
SPODELd& SPODELd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
checkInput(X_, y_);
|
checkInput(X_, y_);
|
||||||
Xf = X_;
|
Xf = X_;
|
||||||
y = y_;
|
y = y_;
|
||||||
return commonFit(features_, className_, states_);
|
return commonFit(features_, className_, states_, smoothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPODELd& SPODELd::fit(torch::Tensor& dataset, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
SPODELd& SPODELd::fit(torch::Tensor& dataset, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
if (!torch::is_floating_point(dataset)) {
|
if (!torch::is_floating_point(dataset)) {
|
||||||
throw std::runtime_error("Dataset must be a floating point tensor");
|
throw std::runtime_error("Dataset must be a floating point tensor");
|
||||||
}
|
}
|
||||||
Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();
|
Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();
|
||||||
y = dataset.index({ -1, "..." }).clone().to(torch::kInt32);
|
y = dataset.index({ -1, "..." }).clone().to(torch::kInt32);
|
||||||
return commonFit(features_, className_, states_);
|
return commonFit(features_, className_, states_, smoothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPODELd& SPODELd::commonFit(const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
SPODELd& SPODELd::commonFit(const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
features = features_;
|
features = features_;
|
||||||
className = className_;
|
className = className_;
|
||||||
@ -34,7 +34,7 @@ namespace bayesnet {
|
|||||||
states = fit_local_discretization(y);
|
states = fit_local_discretization(y);
|
||||||
// We have discretized the input data
|
// We have discretized the input data
|
||||||
// 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network
|
// 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network
|
||||||
SPODE::fit(dataset, features, className, states);
|
SPODE::fit(dataset, features, className, states, smoothing);
|
||||||
states = localDiscretizationProposal(states, model);
|
states = localDiscretizationProposal(states, model);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
explicit SPODELd(int root);
|
explicit SPODELd(int root);
|
||||||
virtual ~SPODELd() = default;
|
virtual ~SPODELd() = default;
|
||||||
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
SPODELd& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
SPODELd& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
SPODELd& commonFit(const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states);
|
SPODELd& commonFit(const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
|
||||||
std::vector<std::string> graph(const std::string& name = "SPODE") const override;
|
std::vector<std::string> graph(const std::string& name = "SPODELd") const override;
|
||||||
torch::Tensor predict(torch::Tensor& X) override;
|
torch::Tensor predict(torch::Tensor& X) override;
|
||||||
static inline std::string version() { return "0.0.1"; };
|
static inline std::string version() { return "0.0.1"; };
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
TANLd::TANLd() : TAN(), Proposal(dataset, features, className) {}
|
TANLd::TANLd() : TAN(), Proposal(dataset, features, className) {}
|
||||||
TANLd& TANLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
TANLd& TANLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
checkInput(X_, y_);
|
checkInput(X_, y_);
|
||||||
features = features_;
|
features = features_;
|
||||||
@ -19,7 +19,7 @@ namespace bayesnet {
|
|||||||
states = fit_local_discretization(y);
|
states = fit_local_discretization(y);
|
||||||
// We have discretized the input data
|
// We have discretized the input data
|
||||||
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
|
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
|
||||||
TAN::fit(dataset, features, className, states);
|
TAN::fit(dataset, features, className, states, smoothing);
|
||||||
states = localDiscretizationProposal(states, model);
|
states = localDiscretizationProposal(states, model);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
@ -15,10 +15,9 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
TANLd();
|
TANLd();
|
||||||
virtual ~TANLd() = default;
|
virtual ~TANLd() = default;
|
||||||
TANLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
TANLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
|
||||||
std::vector<std::string> graph(const std::string& name = "TAN") const override;
|
std::vector<std::string> graph(const std::string& name = "TANLd") const override;
|
||||||
torch::Tensor predict(torch::Tensor& X) override;
|
torch::Tensor predict(torch::Tensor& X) override;
|
||||||
static inline std::string version() { return "0.0.1"; };
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // !TANLD_H
|
#endif // !TANLD_H
|
@ -10,7 +10,7 @@ namespace bayesnet {
|
|||||||
AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)
|
AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
AODELd& AODELd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
AODELd& AODELd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
checkInput(X_, y_);
|
checkInput(X_, y_);
|
||||||
features = features_;
|
features = features_;
|
||||||
@ -20,8 +20,9 @@ namespace bayesnet {
|
|||||||
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
|
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||||
states = fit_local_discretization(y);
|
states = fit_local_discretization(y);
|
||||||
// We have discretized the input data
|
// We have discretized the input data
|
||||||
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
|
// 1st we need to fit the model to build the normal AODE structure, Ensemble::fit
|
||||||
Ensemble::fit(dataset, features, className, states);
|
// calls buildModel to initialize the base models
|
||||||
|
Ensemble::fit(dataset, features, className, states, smoothing);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -34,10 +35,10 @@ namespace bayesnet {
|
|||||||
n_models = models.size();
|
n_models = models.size();
|
||||||
significanceModels = std::vector<double>(n_models, 1.0);
|
significanceModels = std::vector<double>(n_models, 1.0);
|
||||||
}
|
}
|
||||||
void AODELd::trainModel(const torch::Tensor& weights)
|
void AODELd::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
for (const auto& model : models) {
|
for (const auto& model : models) {
|
||||||
model->fit(Xf, y, features, className, states);
|
model->fit(Xf, y, features, className, states, smoothing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<std::string> AODELd::graph(const std::string& name) const
|
std::vector<std::string> AODELd::graph(const std::string& name) const
|
||||||
|
@ -15,10 +15,10 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
AODELd(bool predict_voting = true);
|
AODELd(bool predict_voting = true);
|
||||||
virtual ~AODELd() = default;
|
virtual ~AODELd() = default;
|
||||||
AODELd& fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_) override;
|
AODELd& fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing) override;
|
||||||
std::vector<std::string> graph(const std::string& name = "AODELd") const override;
|
std::vector<std::string> graph(const std::string& name = "AODELd") const override;
|
||||||
protected:
|
protected:
|
||||||
void trainModel(const torch::Tensor& weights) override;
|
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||||
void buildModel(const torch::Tensor& weights) override;
|
void buildModel(const torch::Tensor& weights) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
246
bayesnet/ensembles/Boost.cc
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
#include <folding.hpp>
|
||||||
|
#include "bayesnet/feature_selection/CFS.h"
|
||||||
|
#include "bayesnet/feature_selection/FCBF.h"
|
||||||
|
#include "bayesnet/feature_selection/IWSS.h"
|
||||||
|
#include "Boost.h"
|
||||||
|
|
||||||
|
namespace bayesnet {
|
||||||
|
Boost::Boost(bool predict_voting) : Ensemble(predict_voting)
|
||||||
|
{
|
||||||
|
validHyperparameters = { "order", "convergence", "convergence_best", "bisection", "threshold", "maxTolerance",
|
||||||
|
"predict_voting", "select_features", "block_update" };
|
||||||
|
}
|
||||||
|
void Boost::setHyperparameters(const nlohmann::json& hyperparameters_)
|
||||||
|
{
|
||||||
|
auto hyperparameters = hyperparameters_;
|
||||||
|
if (hyperparameters.contains("order")) {
|
||||||
|
std::vector<std::string> algos = { Orders.ASC, Orders.DESC, Orders.RAND };
|
||||||
|
order_algorithm = hyperparameters["order"];
|
||||||
|
if (std::find(algos.begin(), algos.end(), order_algorithm) == algos.end()) {
|
||||||
|
throw std::invalid_argument("Invalid order algorithm, valid values [" + Orders.ASC + ", " + Orders.DESC + ", " + Orders.RAND + "]");
|
||||||
|
}
|
||||||
|
hyperparameters.erase("order");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("convergence")) {
|
||||||
|
convergence = hyperparameters["convergence"];
|
||||||
|
hyperparameters.erase("convergence");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("convergence_best")) {
|
||||||
|
convergence_best = hyperparameters["convergence_best"];
|
||||||
|
hyperparameters.erase("convergence_best");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("bisection")) {
|
||||||
|
bisection = hyperparameters["bisection"];
|
||||||
|
hyperparameters.erase("bisection");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("threshold")) {
|
||||||
|
threshold = hyperparameters["threshold"];
|
||||||
|
hyperparameters.erase("threshold");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("maxTolerance")) {
|
||||||
|
maxTolerance = hyperparameters["maxTolerance"];
|
||||||
|
if (maxTolerance < 1 || maxTolerance > 4)
|
||||||
|
throw std::invalid_argument("Invalid maxTolerance value, must be greater in [1, 4]");
|
||||||
|
hyperparameters.erase("maxTolerance");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("predict_voting")) {
|
||||||
|
predict_voting = hyperparameters["predict_voting"];
|
||||||
|
hyperparameters.erase("predict_voting");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("select_features")) {
|
||||||
|
auto selectedAlgorithm = hyperparameters["select_features"];
|
||||||
|
std::vector<std::string> algos = { SelectFeatures.IWSS, SelectFeatures.CFS, SelectFeatures.FCBF };
|
||||||
|
selectFeatures = true;
|
||||||
|
select_features_algorithm = selectedAlgorithm;
|
||||||
|
if (std::find(algos.begin(), algos.end(), selectedAlgorithm) == algos.end()) {
|
||||||
|
throw std::invalid_argument("Invalid selectFeatures value, valid values [" + SelectFeatures.IWSS + ", " + SelectFeatures.CFS + ", " + SelectFeatures.FCBF + "]");
|
||||||
|
}
|
||||||
|
hyperparameters.erase("select_features");
|
||||||
|
}
|
||||||
|
if (hyperparameters.contains("block_update")) {
|
||||||
|
block_update = hyperparameters["block_update"];
|
||||||
|
hyperparameters.erase("block_update");
|
||||||
|
}
|
||||||
|
Classifier::setHyperparameters(hyperparameters);
|
||||||
|
}
|
||||||
|
void Boost::buildModel(const torch::Tensor& weights)
|
||||||
|
{
|
||||||
|
// Models shall be built in trainModel
|
||||||
|
models.clear();
|
||||||
|
significanceModels.clear();
|
||||||
|
n_models = 0;
|
||||||
|
// Prepare the validation dataset
|
||||||
|
auto y_ = dataset.index({ -1, "..." });
|
||||||
|
if (convergence) {
|
||||||
|
// Prepare train & validation sets from train data
|
||||||
|
auto fold = folding::StratifiedKFold(5, y_, 271);
|
||||||
|
auto [train, test] = fold.getFold(0);
|
||||||
|
auto train_t = torch::tensor(train);
|
||||||
|
auto test_t = torch::tensor(test);
|
||||||
|
// Get train and validation sets
|
||||||
|
X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), train_t });
|
||||||
|
y_train = dataset.index({ -1, train_t });
|
||||||
|
X_test = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), test_t });
|
||||||
|
y_test = dataset.index({ -1, test_t });
|
||||||
|
dataset = X_train;
|
||||||
|
m = X_train.size(1);
|
||||||
|
auto n_classes = states.at(className).size();
|
||||||
|
// Build dataset with train data
|
||||||
|
buildDataset(y_train);
|
||||||
|
metrics = Metrics(dataset, features, className, n_classes);
|
||||||
|
} else {
|
||||||
|
// Use all data to train
|
||||||
|
X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." });
|
||||||
|
y_train = y_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::vector<int> Boost::featureSelection(torch::Tensor& weights_)
|
||||||
|
{
|
||||||
|
int maxFeatures = 0;
|
||||||
|
if (select_features_algorithm == SelectFeatures.CFS) {
|
||||||
|
featureSelector = new CFS(dataset, features, className, maxFeatures, states.at(className).size(), weights_);
|
||||||
|
} else if (select_features_algorithm == SelectFeatures.IWSS) {
|
||||||
|
if (threshold < 0 || threshold >0.5) {
|
||||||
|
throw std::invalid_argument("Invalid threshold value for " + SelectFeatures.IWSS + " [0, 0.5]");
|
||||||
|
}
|
||||||
|
featureSelector = new IWSS(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);
|
||||||
|
} else if (select_features_algorithm == SelectFeatures.FCBF) {
|
||||||
|
if (threshold < 1e-7 || threshold > 1) {
|
||||||
|
throw std::invalid_argument("Invalid threshold value for " + SelectFeatures.FCBF + " [1e-7, 1]");
|
||||||
|
}
|
||||||
|
featureSelector = new FCBF(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);
|
||||||
|
}
|
||||||
|
featureSelector->fit();
|
||||||
|
auto featuresUsed = featureSelector->getFeatures();
|
||||||
|
delete featureSelector;
|
||||||
|
return featuresUsed;
|
||||||
|
}
|
||||||
|
std::tuple<torch::Tensor&, double, bool> Boost::update_weights(torch::Tensor& ytrain, torch::Tensor& ypred, torch::Tensor& weights)
|
||||||
|
{
|
||||||
|
bool terminate = false;
|
||||||
|
double alpha_t = 0;
|
||||||
|
auto mask_wrong = ypred != ytrain;
|
||||||
|
auto mask_right = ypred == ytrain;
|
||||||
|
auto masked_weights = weights * mask_wrong.to(weights.dtype());
|
||||||
|
double epsilon_t = masked_weights.sum().item<double>();
|
||||||
|
if (epsilon_t > 0.5) {
|
||||||
|
// Inverse the weights policy (plot ln(wt))
|
||||||
|
// "In each round of AdaBoost, there is a sanity check to ensure that the current base
|
||||||
|
// learner is better than random guess" (Zhi-Hua Zhou, 2012)
|
||||||
|
terminate = true;
|
||||||
|
} else {
|
||||||
|
double wt = (1 - epsilon_t) / epsilon_t;
|
||||||
|
alpha_t = epsilon_t == 0 ? 1 : 0.5 * log(wt);
|
||||||
|
// Step 3.2: Update weights for next classifier
|
||||||
|
// Step 3.2.1: Update weights of wrong samples
|
||||||
|
weights += mask_wrong.to(weights.dtype()) * exp(alpha_t) * weights;
|
||||||
|
// Step 3.2.2: Update weights of right samples
|
||||||
|
weights += mask_right.to(weights.dtype()) * exp(-alpha_t) * weights;
|
||||||
|
// Step 3.3: Normalise the weights
|
||||||
|
double totalWeights = torch::sum(weights).item<double>();
|
||||||
|
weights = weights / totalWeights;
|
||||||
|
}
|
||||||
|
return { weights, alpha_t, terminate };
|
||||||
|
}
|
||||||
|
std::tuple<torch::Tensor&, double, bool> Boost::update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights)
|
||||||
|
{
|
||||||
|
/* Update Block algorithm
|
||||||
|
k = # of models in block
|
||||||
|
n_models = # of models in ensemble to make predictions
|
||||||
|
n_models_bak = # models saved
|
||||||
|
models = vector of models to make predictions
|
||||||
|
models_bak = models not used to make predictions
|
||||||
|
significances_bak = backup of significances vector
|
||||||
|
|
||||||
|
Case list
|
||||||
|
A) k = 1, n_models = 1 => n = 0 , n_models = n + k
|
||||||
|
B) k = 1, n_models = n + 1 => n_models = n + k
|
||||||
|
C) k > 1, n_models = k + 1 => n= 1, n_models = n + k
|
||||||
|
D) k > 1, n_models = k => n = 0, n_models = n + k
|
||||||
|
E) k > 1, n_models = k + n => n_models = n + k
|
||||||
|
|
||||||
|
A, D) n=0, k > 0, n_models == k
|
||||||
|
1. n_models_bak <- n_models
|
||||||
|
2. significances_bak <- significances
|
||||||
|
3. significances = vector(k, 1)
|
||||||
|
4. Don’t move any classifiers out of models
|
||||||
|
5. n_models <- k
|
||||||
|
6. Make prediction, compute alpha, update weights
|
||||||
|
7. Don’t restore any classifiers to models
|
||||||
|
8. significances <- significances_bak
|
||||||
|
9. Update last k significances
|
||||||
|
10. n_models <- n_models_bak
|
||||||
|
|
||||||
|
B, C, E) n > 0, k > 0, n_models == n + k
|
||||||
|
1. n_models_bak <- n_models
|
||||||
|
2. significances_bak <- significances
|
||||||
|
3. significances = vector(k, 1)
|
||||||
|
4. Move first n classifiers to models_bak
|
||||||
|
5. n_models <- k
|
||||||
|
6. Make prediction, compute alpha, update weights
|
||||||
|
7. Insert classifiers in models_bak to be the first n models
|
||||||
|
8. significances <- significances_bak
|
||||||
|
9. Update last k significances
|
||||||
|
10. n_models <- n_models_bak
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Make predict with only the last k models
|
||||||
|
//
|
||||||
|
std::unique_ptr<Classifier> model;
|
||||||
|
std::vector<std::unique_ptr<Classifier>> models_bak;
|
||||||
|
// 1. n_models_bak <- n_models 2. significances_bak <- significances
|
||||||
|
auto significance_bak = significanceModels;
|
||||||
|
auto n_models_bak = n_models;
|
||||||
|
// 3. significances = vector(k, 1)
|
||||||
|
significanceModels = std::vector<double>(k, 1.0);
|
||||||
|
// 4. Move first n classifiers to models_bak
|
||||||
|
// backup the first n_models - k models (if n_models == k, don't backup any)
|
||||||
|
for (int i = 0; i < n_models - k; ++i) {
|
||||||
|
model = std::move(models[0]);
|
||||||
|
models.erase(models.begin());
|
||||||
|
models_bak.push_back(std::move(model));
|
||||||
|
}
|
||||||
|
assert(models.size() == k);
|
||||||
|
// 5. n_models <- k
|
||||||
|
n_models = k;
|
||||||
|
// 6. Make prediction, compute alpha, update weights
|
||||||
|
auto ypred = predict(X_train);
|
||||||
|
//
|
||||||
|
// Update weights
|
||||||
|
//
|
||||||
|
double alpha_t;
|
||||||
|
bool terminate;
|
||||||
|
std::tie(weights, alpha_t, terminate) = update_weights(y_train, ypred, weights);
|
||||||
|
//
|
||||||
|
// Restore the models if needed
|
||||||
|
//
|
||||||
|
// 7. Insert classifiers in models_bak to be the first n models
|
||||||
|
// if n_models_bak == k, don't restore any, because none of them were moved
|
||||||
|
if (k != n_models_bak) {
|
||||||
|
// Insert in the same order as they were extracted
|
||||||
|
int bak_size = models_bak.size();
|
||||||
|
for (int i = 0; i < bak_size; ++i) {
|
||||||
|
model = std::move(models_bak[bak_size - 1 - i]);
|
||||||
|
models_bak.erase(models_bak.end() - 1);
|
||||||
|
models.insert(models.begin(), std::move(model));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 8. significances <- significances_bak
|
||||||
|
significanceModels = significance_bak;
|
||||||
|
//
|
||||||
|
// Update the significance of the last k models
|
||||||
|
//
|
||||||
|
// 9. Update last k significances
|
||||||
|
for (int i = 0; i < k; ++i) {
|
||||||
|
significanceModels[n_models_bak - k + i] = alpha_t;
|
||||||
|
}
|
||||||
|
// 10. n_models <- n_models_bak
|
||||||
|
n_models = n_models_bak;
|
||||||
|
return { weights, alpha_t, terminate };
|
||||||
|
}
|
||||||
|
}
|
52
bayesnet/ensembles/Boost.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#ifndef BOOST_H
|
||||||
|
#define BOOST_H
|
||||||
|
#include <string>
|
||||||
|
#include <tuple>
|
||||||
|
#include <vector>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <torch/torch.h>
|
||||||
|
#include "Ensemble.h"
|
||||||
|
#include "bayesnet/feature_selection/FeatureSelect.h"
|
||||||
|
namespace bayesnet {
|
||||||
|
const struct {
|
||||||
|
std::string CFS = "CFS";
|
||||||
|
std::string FCBF = "FCBF";
|
||||||
|
std::string IWSS = "IWSS";
|
||||||
|
}SelectFeatures;
|
||||||
|
const struct {
|
||||||
|
std::string ASC = "asc";
|
||||||
|
std::string DESC = "desc";
|
||||||
|
std::string RAND = "rand";
|
||||||
|
}Orders;
|
||||||
|
class Boost : public Ensemble {
|
||||||
|
public:
|
||||||
|
explicit Boost(bool predict_voting = false);
|
||||||
|
virtual ~Boost() = default;
|
||||||
|
void setHyperparameters(const nlohmann::json& hyperparameters_) override;
|
||||||
|
protected:
|
||||||
|
std::vector<int> featureSelection(torch::Tensor& weights_);
|
||||||
|
void buildModel(const torch::Tensor& weights) override;
|
||||||
|
std::tuple<torch::Tensor&, double, bool> update_weights(torch::Tensor& ytrain, torch::Tensor& ypred, torch::Tensor& weights);
|
||||||
|
std::tuple<torch::Tensor&, double, bool> update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights);
|
||||||
|
torch::Tensor X_train, y_train, X_test, y_test;
|
||||||
|
// Hyperparameters
|
||||||
|
bool bisection = true; // if true, use bisection stratety to add k models at once to the ensemble
|
||||||
|
int maxTolerance = 3;
|
||||||
|
std::string order_algorithm; // order to process the KBest features asc, desc, rand
|
||||||
|
bool convergence = true; //if true, stop when the model does not improve
|
||||||
|
bool convergence_best = false; // wether to keep the best accuracy to the moment or the last accuracy as prior accuracy
|
||||||
|
bool selectFeatures = false; // if true, use feature selection
|
||||||
|
std::string select_features_algorithm = Orders.DESC; // Selected feature selection algorithm
|
||||||
|
FeatureSelect* featureSelector = nullptr;
|
||||||
|
double threshold = -1;
|
||||||
|
bool block_update = false;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
170
bayesnet/ensembles/BoostA2DE.cc
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <functional>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <tuple>
|
||||||
|
#include <folding.hpp>
|
||||||
|
#include "bayesnet/feature_selection/CFS.h"
|
||||||
|
#include "bayesnet/feature_selection/FCBF.h"
|
||||||
|
#include "bayesnet/feature_selection/IWSS.h"
|
||||||
|
#include "BoostA2DE.h"
|
||||||
|
|
||||||
|
namespace bayesnet {
|
||||||
|
|
||||||
|
BoostA2DE::BoostA2DE(bool predict_voting) : Boost(predict_voting)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
std::vector<int> BoostA2DE::initializeModels(const Smoothing_t smoothing)
|
||||||
|
{
|
||||||
|
torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
|
||||||
|
std::vector<int> featuresSelected = featureSelection(weights_);
|
||||||
|
if (featuresSelected.size() < 2) {
|
||||||
|
notes.push_back("No features selected in initialization");
|
||||||
|
status = ERROR;
|
||||||
|
return std::vector<int>();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < featuresSelected.size() - 1; i++) {
|
||||||
|
for (int j = i + 1; j < featuresSelected.size(); j++) {
|
||||||
|
auto parents = { featuresSelected[i], featuresSelected[j] };
|
||||||
|
std::unique_ptr<Classifier> model = std::make_unique<SPnDE>(parents);
|
||||||
|
model->fit(dataset, features, className, states, weights_, smoothing);
|
||||||
|
models.push_back(std::move(model));
|
||||||
|
significanceModels.push_back(1.0); // They will be updated later in trainModel
|
||||||
|
n_models++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notes.push_back("Used features in initialization: " + std::to_string(featuresSelected.size()) + " of " + std::to_string(features.size()) + " with " + select_features_algorithm);
|
||||||
|
return featuresSelected;
|
||||||
|
}
|
||||||
|
void BoostA2DE::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Logging setup
|
||||||
|
//
|
||||||
|
// loguru::set_thread_name("BoostA2DE");
|
||||||
|
// loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
|
||||||
|
// loguru::add_file("boostA2DE.log", loguru::Truncate, loguru::Verbosity_MAX);
|
||||||
|
|
||||||
|
// Algorithm based on the adaboost algorithm for classification
|
||||||
|
// as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
|
||||||
|
fitted = true;
|
||||||
|
double alpha_t = 0;
|
||||||
|
torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
|
||||||
|
bool finished = false;
|
||||||
|
std::vector<int> featuresUsed;
|
||||||
|
if (selectFeatures) {
|
||||||
|
featuresUsed = initializeModels(smoothing);
|
||||||
|
if (featuresUsed.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto ypred = predict(X_train);
|
||||||
|
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
|
||||||
|
// Update significance of the models
|
||||||
|
for (int i = 0; i < n_models; ++i) {
|
||||||
|
significanceModels[i] = alpha_t;
|
||||||
|
}
|
||||||
|
if (finished) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int numItemsPack = 0; // The counter of the models inserted in the current pack
|
||||||
|
// Variables to control the accuracy finish condition
|
||||||
|
double priorAccuracy = 0.0;
|
||||||
|
double improvement = 1.0;
|
||||||
|
double convergence_threshold = 1e-4;
|
||||||
|
int tolerance = 0; // number of times the accuracy is lower than the convergence_threshold
|
||||||
|
// Step 0: Set the finish condition
|
||||||
|
// epsilon sub t > 0.5 => inverse the weights policy
|
||||||
|
// validation error is not decreasing
|
||||||
|
// run out of features
|
||||||
|
bool ascending = order_algorithm == Orders.ASC;
|
||||||
|
std::mt19937 g{ 173 };
|
||||||
|
std::vector<std::pair<int, int>> pairSelection;
|
||||||
|
while (!finished) {
|
||||||
|
// Step 1: Build ranking with mutual information
|
||||||
|
pairSelection = metrics.SelectKPairs(weights_, featuresUsed, ascending, 0); // Get all the pairs sorted
|
||||||
|
if (order_algorithm == Orders.RAND) {
|
||||||
|
std::shuffle(pairSelection.begin(), pairSelection.end(), g);
|
||||||
|
}
|
||||||
|
int k = bisection ? pow(2, tolerance) : 1;
|
||||||
|
int counter = 0; // The model counter of the current pack
|
||||||
|
// VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
|
||||||
|
while (counter++ < k && pairSelection.size() > 0) {
|
||||||
|
auto feature_pair = pairSelection[0];
|
||||||
|
pairSelection.erase(pairSelection.begin());
|
||||||
|
std::unique_ptr<Classifier> model;
|
||||||
|
model = std::make_unique<SPnDE>(std::vector<int>({ feature_pair.first, feature_pair.second }));
|
||||||
|
model->fit(dataset, features, className, states, weights_, smoothing);
|
||||||
|
alpha_t = 0.0;
|
||||||
|
if (!block_update) {
|
||||||
|
auto ypred = model->predict(X_train);
|
||||||
|
// Step 3.1: Compute the classifier amout of say
|
||||||
|
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
|
||||||
|
}
|
||||||
|
// Step 3.4: Store classifier and its accuracy to weigh its future vote
|
||||||
|
numItemsPack++;
|
||||||
|
models.push_back(std::move(model));
|
||||||
|
significanceModels.push_back(alpha_t);
|
||||||
|
n_models++;
|
||||||
|
// VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
|
||||||
|
}
|
||||||
|
if (block_update) {
|
||||||
|
std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);
|
||||||
|
}
|
||||||
|
if (convergence && !finished) {
|
||||||
|
auto y_val_predict = predict(X_test);
|
||||||
|
double accuracy = (y_val_predict == y_test).sum().item<double>() / (double)y_test.size(0);
|
||||||
|
if (priorAccuracy == 0) {
|
||||||
|
priorAccuracy = accuracy;
|
||||||
|
} else {
|
||||||
|
improvement = accuracy - priorAccuracy;
|
||||||
|
}
|
||||||
|
if (improvement < convergence_threshold) {
|
||||||
|
// VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
|
||||||
|
tolerance++;
|
||||||
|
} else {
|
||||||
|
// VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
|
||||||
|
tolerance = 0; // Reset the counter if the model performs better
|
||||||
|
numItemsPack = 0;
|
||||||
|
}
|
||||||
|
if (convergence_best) {
|
||||||
|
// Keep the best accuracy until now as the prior accuracy
|
||||||
|
priorAccuracy = std::max(accuracy, priorAccuracy);
|
||||||
|
} else {
|
||||||
|
// Keep the last accuray obtained as the prior accuracy
|
||||||
|
priorAccuracy = accuracy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
|
||||||
|
finished = finished || tolerance > maxTolerance || pairSelection.size() == 0;
|
||||||
|
}
|
||||||
|
if (tolerance > maxTolerance) {
|
||||||
|
if (numItemsPack < n_models) {
|
||||||
|
notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated");
|
||||||
|
// VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
|
||||||
|
for (int i = 0; i < numItemsPack; ++i) {
|
||||||
|
significanceModels.pop_back();
|
||||||
|
models.pop_back();
|
||||||
|
n_models--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
notes.push_back("Convergence threshold reached & 0 models eliminated");
|
||||||
|
// VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pairSelection.size() > 0) {
|
||||||
|
notes.push_back("Pairs not used in train: " + std::to_string(pairSelection.size()));
|
||||||
|
status = WARNING;
|
||||||
|
}
|
||||||
|
notes.push_back("Number of models: " + std::to_string(n_models));
|
||||||
|
}
|
||||||
|
std::vector<std::string> BoostA2DE::graph(const std::string& title) const
|
||||||
|
{
|
||||||
|
return Ensemble::graph(title);
|
||||||
|
}
|
||||||
|
}
|
25
bayesnet/ensembles/BoostA2DE.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#ifndef BOOSTA2DE_H
|
||||||
|
#define BOOSTA2DE_H
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "bayesnet/classifiers/SPnDE.h"
|
||||||
|
#include "Boost.h"
|
||||||
|
namespace bayesnet {
|
||||||
|
class BoostA2DE : public Boost {
|
||||||
|
public:
|
||||||
|
explicit BoostA2DE(bool predict_voting = false);
|
||||||
|
virtual ~BoostA2DE() = default;
|
||||||
|
std::vector<std::string> graph(const std::string& title = "BoostA2DE") const override;
|
||||||
|
protected:
|
||||||
|
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||||
|
private:
|
||||||
|
std::vector<int> initializeModels(const Smoothing_t smoothing);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
@ -4,275 +4,40 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
// ***************************************************************
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include <random>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <folding.hpp>
|
|
||||||
#include "bayesnet/feature_selection/CFS.h"
|
|
||||||
#include "bayesnet/feature_selection/FCBF.h"
|
|
||||||
#include "bayesnet/feature_selection/IWSS.h"
|
|
||||||
#include "BoostAODE.h"
|
#include "BoostAODE.h"
|
||||||
#include "lib/log/loguru.cpp"
|
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
|
|
||||||
BoostAODE::BoostAODE(bool predict_voting) : Ensemble(predict_voting)
|
BoostAODE::BoostAODE(bool predict_voting) : Boost(predict_voting)
|
||||||
{
|
{
|
||||||
validHyperparameters = {
|
|
||||||
"maxModels", "bisection", "order", "convergence", "convergence_best", "threshold",
|
|
||||||
"select_features", "maxTolerance", "predict_voting", "block_update"
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void BoostAODE::buildModel(const torch::Tensor& weights)
|
std::vector<int> BoostAODE::initializeModels(const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
// Models shall be built in trainModel
|
|
||||||
models.clear();
|
|
||||||
significanceModels.clear();
|
|
||||||
n_models = 0;
|
|
||||||
// Prepare the validation dataset
|
|
||||||
auto y_ = dataset.index({ -1, "..." });
|
|
||||||
if (convergence) {
|
|
||||||
// Prepare train & validation sets from train data
|
|
||||||
auto fold = folding::StratifiedKFold(5, y_, 271);
|
|
||||||
auto [train, test] = fold.getFold(0);
|
|
||||||
auto train_t = torch::tensor(train);
|
|
||||||
auto test_t = torch::tensor(test);
|
|
||||||
// Get train and validation sets
|
|
||||||
X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), train_t });
|
|
||||||
y_train = dataset.index({ -1, train_t });
|
|
||||||
X_test = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), test_t });
|
|
||||||
y_test = dataset.index({ -1, test_t });
|
|
||||||
dataset = X_train;
|
|
||||||
m = X_train.size(1);
|
|
||||||
auto n_classes = states.at(className).size();
|
|
||||||
// Build dataset with train data
|
|
||||||
buildDataset(y_train);
|
|
||||||
metrics = Metrics(dataset, features, className, n_classes);
|
|
||||||
} else {
|
|
||||||
// Use all data to train
|
|
||||||
X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." });
|
|
||||||
y_train = y_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void BoostAODE::setHyperparameters(const nlohmann::json& hyperparameters_)
|
|
||||||
{
|
|
||||||
auto hyperparameters = hyperparameters_;
|
|
||||||
if (hyperparameters.contains("order")) {
|
|
||||||
std::vector<std::string> algos = { Orders.ASC, Orders.DESC, Orders.RAND };
|
|
||||||
order_algorithm = hyperparameters["order"];
|
|
||||||
if (std::find(algos.begin(), algos.end(), order_algorithm) == algos.end()) {
|
|
||||||
throw std::invalid_argument("Invalid order algorithm, valid values [" + Orders.ASC + ", " + Orders.DESC + ", " + Orders.RAND + "]");
|
|
||||||
}
|
|
||||||
hyperparameters.erase("order");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("convergence")) {
|
|
||||||
convergence = hyperparameters["convergence"];
|
|
||||||
hyperparameters.erase("convergence");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("convergence_best")) {
|
|
||||||
convergence_best = hyperparameters["convergence_best"];
|
|
||||||
hyperparameters.erase("convergence_best");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("bisection")) {
|
|
||||||
bisection = hyperparameters["bisection"];
|
|
||||||
hyperparameters.erase("bisection");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("threshold")) {
|
|
||||||
threshold = hyperparameters["threshold"];
|
|
||||||
hyperparameters.erase("threshold");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("maxTolerance")) {
|
|
||||||
maxTolerance = hyperparameters["maxTolerance"];
|
|
||||||
if (maxTolerance < 1 || maxTolerance > 4)
|
|
||||||
throw std::invalid_argument("Invalid maxTolerance value, must be greater in [1, 4]");
|
|
||||||
hyperparameters.erase("maxTolerance");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("predict_voting")) {
|
|
||||||
predict_voting = hyperparameters["predict_voting"];
|
|
||||||
hyperparameters.erase("predict_voting");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("select_features")) {
|
|
||||||
auto selectedAlgorithm = hyperparameters["select_features"];
|
|
||||||
std::vector<std::string> algos = { SelectFeatures.IWSS, SelectFeatures.CFS, SelectFeatures.FCBF };
|
|
||||||
selectFeatures = true;
|
|
||||||
select_features_algorithm = selectedAlgorithm;
|
|
||||||
if (std::find(algos.begin(), algos.end(), selectedAlgorithm) == algos.end()) {
|
|
||||||
throw std::invalid_argument("Invalid selectFeatures value, valid values [" + SelectFeatures.IWSS + ", " + SelectFeatures.CFS + ", " + SelectFeatures.FCBF + "]");
|
|
||||||
}
|
|
||||||
hyperparameters.erase("select_features");
|
|
||||||
}
|
|
||||||
if (hyperparameters.contains("block_update")) {
|
|
||||||
block_update = hyperparameters["block_update"];
|
|
||||||
hyperparameters.erase("block_update");
|
|
||||||
}
|
|
||||||
Classifier::setHyperparameters(hyperparameters);
|
|
||||||
}
|
|
||||||
std::tuple<torch::Tensor&, double, bool> update_weights(torch::Tensor& ytrain, torch::Tensor& ypred, torch::Tensor& weights)
|
|
||||||
{
|
|
||||||
bool terminate = false;
|
|
||||||
double alpha_t = 0;
|
|
||||||
auto mask_wrong = ypred != ytrain;
|
|
||||||
auto mask_right = ypred == ytrain;
|
|
||||||
auto masked_weights = weights * mask_wrong.to(weights.dtype());
|
|
||||||
double epsilon_t = masked_weights.sum().item<double>();
|
|
||||||
if (epsilon_t > 0.5) {
|
|
||||||
// Inverse the weights policy (plot ln(wt))
|
|
||||||
// "In each round of AdaBoost, there is a sanity check to ensure that the current base
|
|
||||||
// learner is better than random guess" (Zhi-Hua Zhou, 2012)
|
|
||||||
terminate = true;
|
|
||||||
} else {
|
|
||||||
double wt = (1 - epsilon_t) / epsilon_t;
|
|
||||||
alpha_t = epsilon_t == 0 ? 1 : 0.5 * log(wt);
|
|
||||||
// Step 3.2: Update weights for next classifier
|
|
||||||
// Step 3.2.1: Update weights of wrong samples
|
|
||||||
weights += mask_wrong.to(weights.dtype()) * exp(alpha_t) * weights;
|
|
||||||
// Step 3.2.2: Update weights of right samples
|
|
||||||
weights += mask_right.to(weights.dtype()) * exp(-alpha_t) * weights;
|
|
||||||
// Step 3.3: Normalise the weights
|
|
||||||
double totalWeights = torch::sum(weights).item<double>();
|
|
||||||
weights = weights / totalWeights;
|
|
||||||
}
|
|
||||||
return { weights, alpha_t, terminate };
|
|
||||||
}
|
|
||||||
std::tuple<torch::Tensor&, double, bool> BoostAODE::update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights)
|
|
||||||
{
|
|
||||||
/* Update Block algorithm
|
|
||||||
k = # of models in block
|
|
||||||
n_models = # of models in ensemble to make predictions
|
|
||||||
n_models_bak = # models saved
|
|
||||||
models = vector of models to make predictions
|
|
||||||
models_bak = models not used to make predictions
|
|
||||||
significances_bak = backup of significances vector
|
|
||||||
|
|
||||||
Case list
|
|
||||||
A) k = 1, n_models = 1 => n = 0 , n_models = n + k
|
|
||||||
B) k = 1, n_models = n + 1 => n_models = n + k
|
|
||||||
C) k > 1, n_models = k + 1 => n= 1, n_models = n + k
|
|
||||||
D) k > 1, n_models = k => n = 0, n_models = n + k
|
|
||||||
E) k > 1, n_models = k + n => n_models = n + k
|
|
||||||
|
|
||||||
A, D) n=0, k > 0, n_models == k
|
|
||||||
1. n_models_bak <- n_models
|
|
||||||
2. significances_bak <- significances
|
|
||||||
3. significances = vector(k, 1)
|
|
||||||
4. Don’t move any classifiers out of models
|
|
||||||
5. n_models <- k
|
|
||||||
6. Make prediction, compute alpha, update weights
|
|
||||||
7. Don’t restore any classifiers to models
|
|
||||||
8. significances <- significances_bak
|
|
||||||
9. Update last k significances
|
|
||||||
10. n_models <- n_models_bak
|
|
||||||
|
|
||||||
B, C, E) n > 0, k > 0, n_models == n + k
|
|
||||||
1. n_models_bak <- n_models
|
|
||||||
2. significances_bak <- significances
|
|
||||||
3. significances = vector(k, 1)
|
|
||||||
4. Move first n classifiers to models_bak
|
|
||||||
5. n_models <- k
|
|
||||||
6. Make prediction, compute alpha, update weights
|
|
||||||
7. Insert classifiers in models_bak to be the first n models
|
|
||||||
8. significances <- significances_bak
|
|
||||||
9. Update last k significances
|
|
||||||
10. n_models <- n_models_bak
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Make predict with only the last k models
|
|
||||||
//
|
|
||||||
std::unique_ptr<Classifier> model;
|
|
||||||
std::vector<std::unique_ptr<Classifier>> models_bak;
|
|
||||||
// 1. n_models_bak <- n_models 2. significances_bak <- significances
|
|
||||||
auto significance_bak = significanceModels;
|
|
||||||
auto n_models_bak = n_models;
|
|
||||||
// 3. significances = vector(k, 1)
|
|
||||||
significanceModels = std::vector<double>(k, 1.0);
|
|
||||||
// 4. Move first n classifiers to models_bak
|
|
||||||
// backup the first n_models - k models (if n_models == k, don't backup any)
|
|
||||||
for (int i = 0; i < n_models - k; ++i) {
|
|
||||||
model = std::move(models[0]);
|
|
||||||
models.erase(models.begin());
|
|
||||||
models_bak.push_back(std::move(model));
|
|
||||||
}
|
|
||||||
assert(models.size() == k);
|
|
||||||
// 5. n_models <- k
|
|
||||||
n_models = k;
|
|
||||||
// 6. Make prediction, compute alpha, update weights
|
|
||||||
auto ypred = predict(X_train);
|
|
||||||
//
|
|
||||||
// Update weights
|
|
||||||
//
|
|
||||||
double alpha_t;
|
|
||||||
bool terminate;
|
|
||||||
std::tie(weights, alpha_t, terminate) = update_weights(y_train, ypred, weights);
|
|
||||||
//
|
|
||||||
// Restore the models if needed
|
|
||||||
//
|
|
||||||
// 7. Insert classifiers in models_bak to be the first n models
|
|
||||||
// if n_models_bak == k, don't restore any, because none of them were moved
|
|
||||||
if (k != n_models_bak) {
|
|
||||||
// Insert in the same order as they were extracted
|
|
||||||
int bak_size = models_bak.size();
|
|
||||||
for (int i = 0; i < bak_size; ++i) {
|
|
||||||
model = std::move(models_bak[bak_size - 1 - i]);
|
|
||||||
models_bak.erase(models_bak.end() - 1);
|
|
||||||
models.insert(models.begin(), std::move(model));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 8. significances <- significances_bak
|
|
||||||
significanceModels = significance_bak;
|
|
||||||
//
|
|
||||||
// Update the significance of the last k models
|
|
||||||
//
|
|
||||||
// 9. Update last k significances
|
|
||||||
for (int i = 0; i < k; ++i) {
|
|
||||||
significanceModels[n_models_bak - k + i] = alpha_t;
|
|
||||||
}
|
|
||||||
// 10. n_models <- n_models_bak
|
|
||||||
n_models = n_models_bak;
|
|
||||||
return { weights, alpha_t, terminate };
|
|
||||||
}
|
|
||||||
std::vector<int> BoostAODE::initializeModels()
|
|
||||||
{
|
|
||||||
std::vector<int> featuresUsed;
|
|
||||||
torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
|
torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
|
||||||
int maxFeatures = 0;
|
std::vector<int> featuresSelected = featureSelection(weights_);
|
||||||
if (select_features_algorithm == SelectFeatures.CFS) {
|
for (const int& feature : featuresSelected) {
|
||||||
featureSelector = new CFS(dataset, features, className, maxFeatures, states.at(className).size(), weights_);
|
|
||||||
} else if (select_features_algorithm == SelectFeatures.IWSS) {
|
|
||||||
if (threshold < 0 || threshold >0.5) {
|
|
||||||
throw std::invalid_argument("Invalid threshold value for " + SelectFeatures.IWSS + " [0, 0.5]");
|
|
||||||
}
|
|
||||||
featureSelector = new IWSS(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);
|
|
||||||
} else if (select_features_algorithm == SelectFeatures.FCBF) {
|
|
||||||
if (threshold < 1e-7 || threshold > 1) {
|
|
||||||
throw std::invalid_argument("Invalid threshold value for " + SelectFeatures.FCBF + " [1e-7, 1]");
|
|
||||||
}
|
|
||||||
featureSelector = new FCBF(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);
|
|
||||||
}
|
|
||||||
featureSelector->fit();
|
|
||||||
auto cfsFeatures = featureSelector->getFeatures();
|
|
||||||
auto scores = featureSelector->getScores();
|
|
||||||
for (const int& feature : cfsFeatures) {
|
|
||||||
featuresUsed.push_back(feature);
|
|
||||||
std::unique_ptr<Classifier> model = std::make_unique<SPODE>(feature);
|
std::unique_ptr<Classifier> model = std::make_unique<SPODE>(feature);
|
||||||
model->fit(dataset, features, className, states, weights_);
|
model->fit(dataset, features, className, states, weights_, smoothing);
|
||||||
models.push_back(std::move(model));
|
models.push_back(std::move(model));
|
||||||
significanceModels.push_back(1.0); // They will be updated later in trainModel
|
significanceModels.push_back(1.0); // They will be updated later in trainModel
|
||||||
n_models++;
|
n_models++;
|
||||||
}
|
}
|
||||||
notes.push_back("Used features in initialization: " + std::to_string(featuresUsed.size()) + " of " + std::to_string(features.size()) + " with " + select_features_algorithm);
|
notes.push_back("Used features in initialization: " + std::to_string(featuresSelected.size()) + " of " + std::to_string(features.size()) + " with " + select_features_algorithm);
|
||||||
delete featureSelector;
|
return featuresSelected;
|
||||||
return featuresUsed;
|
|
||||||
}
|
}
|
||||||
void BoostAODE::trainModel(const torch::Tensor& weights)
|
void BoostAODE::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Logging setup
|
// Logging setup
|
||||||
//
|
//
|
||||||
loguru::set_thread_name("BoostAODE");
|
// loguru::set_thread_name("BoostAODE");
|
||||||
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
|
// loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
|
||||||
loguru::add_file("boostAODE.log", loguru::Truncate, loguru::Verbosity_MAX);
|
// loguru::add_file("boostAODE.log", loguru::Truncate, loguru::Verbosity_MAX);
|
||||||
|
|
||||||
// Algorithm based on the adaboost algorithm for classification
|
// Algorithm based on the adaboost algorithm for classification
|
||||||
// as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
|
// as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
|
||||||
@ -282,7 +47,7 @@ namespace bayesnet {
|
|||||||
bool finished = false;
|
bool finished = false;
|
||||||
std::vector<int> featuresUsed;
|
std::vector<int> featuresUsed;
|
||||||
if (selectFeatures) {
|
if (selectFeatures) {
|
||||||
featuresUsed = initializeModels();
|
featuresUsed = initializeModels(smoothing);
|
||||||
auto ypred = predict(X_train);
|
auto ypred = predict(X_train);
|
||||||
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
|
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
|
||||||
// Update significance of the models
|
// Update significance of the models
|
||||||
@ -318,13 +83,13 @@ namespace bayesnet {
|
|||||||
);
|
);
|
||||||
int k = bisection ? pow(2, tolerance) : 1;
|
int k = bisection ? pow(2, tolerance) : 1;
|
||||||
int counter = 0; // The model counter of the current pack
|
int counter = 0; // The model counter of the current pack
|
||||||
VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
|
// VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
|
||||||
while (counter++ < k && featureSelection.size() > 0) {
|
while (counter++ < k && featureSelection.size() > 0) {
|
||||||
auto feature = featureSelection[0];
|
auto feature = featureSelection[0];
|
||||||
featureSelection.erase(featureSelection.begin());
|
featureSelection.erase(featureSelection.begin());
|
||||||
std::unique_ptr<Classifier> model;
|
std::unique_ptr<Classifier> model;
|
||||||
model = std::make_unique<SPODE>(feature);
|
model = std::make_unique<SPODE>(feature);
|
||||||
model->fit(dataset, features, className, states, weights_);
|
model->fit(dataset, features, className, states, weights_, smoothing);
|
||||||
alpha_t = 0.0;
|
alpha_t = 0.0;
|
||||||
if (!block_update) {
|
if (!block_update) {
|
||||||
auto ypred = model->predict(X_train);
|
auto ypred = model->predict(X_train);
|
||||||
@ -337,7 +102,7 @@ namespace bayesnet {
|
|||||||
models.push_back(std::move(model));
|
models.push_back(std::move(model));
|
||||||
significanceModels.push_back(alpha_t);
|
significanceModels.push_back(alpha_t);
|
||||||
n_models++;
|
n_models++;
|
||||||
VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
|
// VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
|
||||||
}
|
}
|
||||||
if (block_update) {
|
if (block_update) {
|
||||||
std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);
|
std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);
|
||||||
@ -351,10 +116,10 @@ namespace bayesnet {
|
|||||||
improvement = accuracy - priorAccuracy;
|
improvement = accuracy - priorAccuracy;
|
||||||
}
|
}
|
||||||
if (improvement < convergence_threshold) {
|
if (improvement < convergence_threshold) {
|
||||||
VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
|
// VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
|
||||||
tolerance++;
|
tolerance++;
|
||||||
} else {
|
} else {
|
||||||
VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
|
// VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
|
||||||
tolerance = 0; // Reset the counter if the model performs better
|
tolerance = 0; // Reset the counter if the model performs better
|
||||||
numItemsPack = 0;
|
numItemsPack = 0;
|
||||||
}
|
}
|
||||||
@ -366,13 +131,13 @@ namespace bayesnet {
|
|||||||
priorAccuracy = accuracy;
|
priorAccuracy = accuracy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
|
// VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
|
||||||
finished = finished || tolerance > maxTolerance || featuresUsed.size() == features.size();
|
finished = finished || tolerance > maxTolerance || featuresUsed.size() == features.size();
|
||||||
}
|
}
|
||||||
if (tolerance > maxTolerance) {
|
if (tolerance > maxTolerance) {
|
||||||
if (numItemsPack < n_models) {
|
if (numItemsPack < n_models) {
|
||||||
notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated");
|
notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated");
|
||||||
VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
|
// VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
|
||||||
for (int i = 0; i < numItemsPack; ++i) {
|
for (int i = 0; i < numItemsPack; ++i) {
|
||||||
significanceModels.pop_back();
|
significanceModels.pop_back();
|
||||||
models.pop_back();
|
models.pop_back();
|
||||||
@ -380,7 +145,7 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notes.push_back("Convergence threshold reached & 0 models eliminated");
|
notes.push_back("Convergence threshold reached & 0 models eliminated");
|
||||||
VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
|
// VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (featuresUsed.size() != features.size()) {
|
if (featuresUsed.size() != features.size()) {
|
||||||
|
@ -6,45 +6,21 @@
|
|||||||
|
|
||||||
#ifndef BOOSTAODE_H
|
#ifndef BOOSTAODE_H
|
||||||
#define BOOSTAODE_H
|
#define BOOSTAODE_H
|
||||||
#include <map>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include "bayesnet/classifiers/SPODE.h"
|
#include "bayesnet/classifiers/SPODE.h"
|
||||||
#include "bayesnet/feature_selection/FeatureSelect.h"
|
#include "Boost.h"
|
||||||
#include "Ensemble.h"
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
const struct {
|
class BoostAODE : public Boost {
|
||||||
std::string CFS = "CFS";
|
|
||||||
std::string FCBF = "FCBF";
|
|
||||||
std::string IWSS = "IWSS";
|
|
||||||
}SelectFeatures;
|
|
||||||
const struct {
|
|
||||||
std::string ASC = "asc";
|
|
||||||
std::string DESC = "desc";
|
|
||||||
std::string RAND = "rand";
|
|
||||||
}Orders;
|
|
||||||
class BoostAODE : public Ensemble {
|
|
||||||
public:
|
public:
|
||||||
explicit BoostAODE(bool predict_voting = false);
|
explicit BoostAODE(bool predict_voting = false);
|
||||||
virtual ~BoostAODE() = default;
|
virtual ~BoostAODE() = default;
|
||||||
std::vector<std::string> graph(const std::string& title = "BoostAODE") const override;
|
std::vector<std::string> graph(const std::string& title = "BoostAODE") const override;
|
||||||
void setHyperparameters(const nlohmann::json& hyperparameters_) override;
|
|
||||||
protected:
|
protected:
|
||||||
void buildModel(const torch::Tensor& weights) override;
|
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||||
void trainModel(const torch::Tensor& weights) override;
|
|
||||||
private:
|
private:
|
||||||
std::tuple<torch::Tensor&, double, bool> update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights);
|
std::vector<int> initializeModels(const Smoothing_t smoothing);
|
||||||
std::vector<int> initializeModels();
|
|
||||||
torch::Tensor X_train, y_train, X_test, y_test;
|
|
||||||
// Hyperparameters
|
|
||||||
bool bisection = true; // if true, use bisection stratety to add k models at once to the ensemble
|
|
||||||
int maxTolerance = 3;
|
|
||||||
std::string order_algorithm; // order to process the KBest features asc, desc, rand
|
|
||||||
bool convergence = true; //if true, stop when the model does not improve
|
|
||||||
bool convergence_best = false; // wether to keep the best accuracy to the moment or the last accuracy as prior accuracy
|
|
||||||
bool selectFeatures = false; // if true, use feature selection
|
|
||||||
std::string select_features_algorithm = Orders.DESC; // Selected feature selection algorithm
|
|
||||||
FeatureSelect* featureSelector = nullptr;
|
|
||||||
double threshold = -1;
|
|
||||||
bool block_update = false;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -3,22 +3,21 @@
|
|||||||
// SPDX-FileType: SOURCE
|
// SPDX-FileType: SOURCE
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
// ***************************************************************
|
// ***************************************************************
|
||||||
|
|
||||||
#include "Ensemble.h"
|
#include "Ensemble.h"
|
||||||
|
#include "bayesnet/utils/CountingSemaphore.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
|
|
||||||
Ensemble::Ensemble(bool predict_voting) : Classifier(Network()), n_models(0), predict_voting(predict_voting)
|
Ensemble::Ensemble(bool predict_voting) : Classifier(Network()), n_models(0), predict_voting(predict_voting)
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
const std::string ENSEMBLE_NOT_FITTED = "Ensemble has not been fitted";
|
const std::string ENSEMBLE_NOT_FITTED = "Ensemble has not been fitted";
|
||||||
void Ensemble::trainModel(const torch::Tensor& weights)
|
void Ensemble::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
n_models = models.size();
|
n_models = models.size();
|
||||||
for (auto i = 0; i < n_models; ++i) {
|
for (auto i = 0; i < n_models; ++i) {
|
||||||
// fit with std::vectors
|
// fit with std::vectors
|
||||||
models[i]->fit(dataset, features, className, states);
|
models[i]->fit(dataset, features, className, states, smoothing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<int> Ensemble::compute_arg_max(std::vector<std::vector<double>>& X)
|
std::vector<int> Ensemble::compute_arg_max(std::vector<std::vector<double>>& X)
|
||||||
@ -85,17 +84,9 @@ namespace bayesnet {
|
|||||||
{
|
{
|
||||||
auto n_states = models[0]->getClassNumStates();
|
auto n_states = models[0]->getClassNumStates();
|
||||||
torch::Tensor y_pred = torch::zeros({ X.size(1), n_states }, torch::kFloat32);
|
torch::Tensor y_pred = torch::zeros({ X.size(1), n_states }, torch::kFloat32);
|
||||||
auto threads{ std::vector<std::thread>() };
|
|
||||||
std::mutex mtx;
|
|
||||||
for (auto i = 0; i < n_models; ++i) {
|
for (auto i = 0; i < n_models; ++i) {
|
||||||
threads.push_back(std::thread([&, i]() {
|
auto ypredict = models[i]->predict_proba(X);
|
||||||
auto ypredict = models[i]->predict_proba(X);
|
y_pred += ypredict * significanceModels[i];
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
|
||||||
y_pred += ypredict * significanceModels[i];
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
for (auto& thread : threads) {
|
|
||||||
thread.join();
|
|
||||||
}
|
}
|
||||||
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
|
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
|
||||||
y_pred /= sum;
|
y_pred /= sum;
|
||||||
@ -105,23 +96,15 @@ namespace bayesnet {
|
|||||||
{
|
{
|
||||||
auto n_states = models[0]->getClassNumStates();
|
auto n_states = models[0]->getClassNumStates();
|
||||||
std::vector<std::vector<double>> y_pred(X[0].size(), std::vector<double>(n_states, 0.0));
|
std::vector<std::vector<double>> y_pred(X[0].size(), std::vector<double>(n_states, 0.0));
|
||||||
auto threads{ std::vector<std::thread>() };
|
|
||||||
std::mutex mtx;
|
|
||||||
for (auto i = 0; i < n_models; ++i) {
|
for (auto i = 0; i < n_models; ++i) {
|
||||||
threads.push_back(std::thread([&, i]() {
|
auto ypredict = models[i]->predict_proba(X);
|
||||||
auto ypredict = models[i]->predict_proba(X);
|
assert(ypredict.size() == y_pred.size());
|
||||||
assert(ypredict.size() == y_pred.size());
|
assert(ypredict[0].size() == y_pred[0].size());
|
||||||
assert(ypredict[0].size() == y_pred[0].size());
|
// Multiply each prediction by the significance of the model and then add it to the final prediction
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
for (auto j = 0; j < ypredict.size(); ++j) {
|
||||||
// Multiply each prediction by the significance of the model and then add it to the final prediction
|
std::transform(y_pred[j].begin(), y_pred[j].end(), ypredict[j].begin(), y_pred[j].begin(),
|
||||||
for (auto j = 0; j < ypredict.size(); ++j) {
|
[significanceModels = significanceModels[i]](double x, double y) { return x + y * significanceModels; });
|
||||||
std::transform(y_pred[j].begin(), y_pred[j].end(), ypredict[j].begin(), y_pred[j].begin(),
|
}
|
||||||
[significanceModels = significanceModels[i]](double x, double y) { return x + y * significanceModels; });
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
for (auto& thread : threads) {
|
|
||||||
thread.join();
|
|
||||||
}
|
}
|
||||||
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
|
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
|
||||||
//Divide each element of the prediction by the sum of the significances
|
//Divide each element of the prediction by the sum of the significances
|
||||||
@ -141,17 +124,9 @@ namespace bayesnet {
|
|||||||
{
|
{
|
||||||
// Build a m x n_models tensor with the predictions of each model
|
// Build a m x n_models tensor with the predictions of each model
|
||||||
torch::Tensor y_pred = torch::zeros({ X.size(1), n_models }, torch::kInt32);
|
torch::Tensor y_pred = torch::zeros({ X.size(1), n_models }, torch::kInt32);
|
||||||
auto threads{ std::vector<std::thread>() };
|
|
||||||
std::mutex mtx;
|
|
||||||
for (auto i = 0; i < n_models; ++i) {
|
for (auto i = 0; i < n_models; ++i) {
|
||||||
threads.push_back(std::thread([&, i]() {
|
auto ypredict = models[i]->predict(X);
|
||||||
auto ypredict = models[i]->predict(X);
|
y_pred.index_put_({ "...", i }, ypredict);
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
|
||||||
y_pred.index_put_({ "...", i }, ypredict);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
for (auto& thread : threads) {
|
|
||||||
thread.join();
|
|
||||||
}
|
}
|
||||||
return voting(y_pred);
|
return voting(y_pred);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace bayesnet {
|
|||||||
unsigned n_models;
|
unsigned n_models;
|
||||||
std::vector<std::unique_ptr<Classifier>> models;
|
std::vector<std::unique_ptr<Classifier>> models;
|
||||||
std::vector<double> significanceModels;
|
std::vector<double> significanceModels;
|
||||||
void trainModel(const torch::Tensor& weights) override;
|
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||||
bool predict_voting;
|
bool predict_voting;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,20 @@
|
|||||||
// ***************************************************************
|
// ***************************************************************
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <numeric>
|
||||||
|
#include <algorithm>
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "bayesnet/utils/bayesnetUtils.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
|
#include "bayesnet/utils/CountingSemaphore.h"
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <fstream>
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
Network::Network() : fitted{ false }, maxThreads{ 0.95 }, classNumStates{ 0 }, laplaceSmoothing{ 0 }
|
Network::Network() : fitted{ false }, classNumStates{ 0 }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Network::Network(float maxT) : fitted{ false }, maxThreads{ maxT }, classNumStates{ 0 }, laplaceSmoothing{ 0 }
|
Network::Network(const Network& other) : features(other.features), className(other.className), classNumStates(other.getClassNumStates()),
|
||||||
{
|
fitted(other.fitted), samples(other.samples)
|
||||||
|
|
||||||
}
|
|
||||||
Network::Network(const Network& other) : laplaceSmoothing(other.laplaceSmoothing), features(other.features), className(other.className), classNumStates(other.getClassNumStates()),
|
|
||||||
maxThreads(other.getMaxThreads()), fitted(other.fitted), samples(other.samples)
|
|
||||||
{
|
{
|
||||||
if (samples.defined())
|
if (samples.defined())
|
||||||
samples = samples.clone();
|
samples = samples.clone();
|
||||||
@ -35,16 +35,15 @@ namespace bayesnet {
|
|||||||
nodes.clear();
|
nodes.clear();
|
||||||
samples = torch::Tensor();
|
samples = torch::Tensor();
|
||||||
}
|
}
|
||||||
float Network::getMaxThreads() const
|
|
||||||
{
|
|
||||||
return maxThreads;
|
|
||||||
}
|
|
||||||
torch::Tensor& Network::getSamples()
|
torch::Tensor& Network::getSamples()
|
||||||
{
|
{
|
||||||
return samples;
|
return samples;
|
||||||
}
|
}
|
||||||
void Network::addNode(const std::string& name)
|
void Network::addNode(const std::string& name)
|
||||||
{
|
{
|
||||||
|
if (fitted) {
|
||||||
|
throw std::invalid_argument("Cannot add node to a fitted network. Initialize first.");
|
||||||
|
}
|
||||||
if (name == "") {
|
if (name == "") {
|
||||||
throw std::invalid_argument("Node name cannot be empty");
|
throw std::invalid_argument("Node name cannot be empty");
|
||||||
}
|
}
|
||||||
@ -94,12 +93,21 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
void Network::addEdge(const std::string& parent, const std::string& child)
|
void Network::addEdge(const std::string& parent, const std::string& child)
|
||||||
{
|
{
|
||||||
|
if (fitted) {
|
||||||
|
throw std::invalid_argument("Cannot add edge to a fitted network. Initialize first.");
|
||||||
|
}
|
||||||
if (nodes.find(parent) == nodes.end()) {
|
if (nodes.find(parent) == nodes.end()) {
|
||||||
throw std::invalid_argument("Parent node " + parent + " does not exist");
|
throw std::invalid_argument("Parent node " + parent + " does not exist");
|
||||||
}
|
}
|
||||||
if (nodes.find(child) == nodes.end()) {
|
if (nodes.find(child) == nodes.end()) {
|
||||||
throw std::invalid_argument("Child node " + child + " does not exist");
|
throw std::invalid_argument("Child node " + child + " does not exist");
|
||||||
}
|
}
|
||||||
|
// Check if the edge is already in the graph
|
||||||
|
for (auto& node : nodes[parent]->getChildren()) {
|
||||||
|
if (node->getName() == child) {
|
||||||
|
throw std::invalid_argument("Edge " + parent + " -> " + child + " already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
// Temporarily add edge to check for cycles
|
// Temporarily add edge to check for cycles
|
||||||
nodes[parent]->addChild(nodes[child].get());
|
nodes[parent]->addChild(nodes[child].get());
|
||||||
nodes[child]->addParent(nodes[parent].get());
|
nodes[child]->addParent(nodes[parent].get());
|
||||||
@ -155,7 +163,7 @@ namespace bayesnet {
|
|||||||
classNumStates = nodes.at(className)->getNumStates();
|
classNumStates = nodes.at(className)->getNumStates();
|
||||||
}
|
}
|
||||||
// X comes in nxm, where n is the number of features and m the number of samples
|
// X comes in nxm, where n is the number of features and m the number of samples
|
||||||
void Network::fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states)
|
void Network::fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
checkFitData(X.size(1), X.size(0), y.size(0), featureNames, className, states, weights);
|
checkFitData(X.size(1), X.size(0), y.size(0), featureNames, className, states, weights);
|
||||||
this->className = className;
|
this->className = className;
|
||||||
@ -164,17 +172,17 @@ namespace bayesnet {
|
|||||||
for (int i = 0; i < featureNames.size(); ++i) {
|
for (int i = 0; i < featureNames.size(); ++i) {
|
||||||
auto row_feature = X.index({ i, "..." });
|
auto row_feature = X.index({ i, "..." });
|
||||||
}
|
}
|
||||||
completeFit(states, weights);
|
completeFit(states, weights, smoothing);
|
||||||
}
|
}
|
||||||
void Network::fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states)
|
void Network::fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
checkFitData(samples.size(1), samples.size(0) - 1, samples.size(1), featureNames, className, states, weights);
|
checkFitData(samples.size(1), samples.size(0) - 1, samples.size(1), featureNames, className, states, weights);
|
||||||
this->className = className;
|
this->className = className;
|
||||||
this->samples = samples;
|
this->samples = samples;
|
||||||
completeFit(states, weights);
|
completeFit(states, weights, smoothing);
|
||||||
}
|
}
|
||||||
// input_data comes in nxm, where n is the number of features and m the number of samples
|
// input_data comes in nxm, where n is the number of features and m the number of samples
|
||||||
void Network::fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights_, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states)
|
void Network::fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights_, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
const torch::Tensor weights = torch::tensor(weights_, torch::kFloat64);
|
const torch::Tensor weights = torch::tensor(weights_, torch::kFloat64);
|
||||||
checkFitData(input_data[0].size(), input_data.size(), labels.size(), featureNames, className, states, weights);
|
checkFitData(input_data[0].size(), input_data.size(), labels.size(), featureNames, className, states, weights);
|
||||||
@ -185,17 +193,43 @@ namespace bayesnet {
|
|||||||
samples.index_put_({ i, "..." }, torch::tensor(input_data[i], torch::kInt32));
|
samples.index_put_({ i, "..." }, torch::tensor(input_data[i], torch::kInt32));
|
||||||
}
|
}
|
||||||
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
|
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
|
||||||
completeFit(states, weights);
|
completeFit(states, weights, smoothing);
|
||||||
}
|
}
|
||||||
void Network::completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)
|
void Network::completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||||
{
|
{
|
||||||
setStates(states);
|
setStates(states);
|
||||||
laplaceSmoothing = 1.0 / samples.size(1); // To use in CPT computation
|
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
|
auto& semaphore = CountingSemaphore::getInstance();
|
||||||
|
const double n_samples = static_cast<double>(samples.size(1));
|
||||||
|
auto worker = [&](std::pair<const std::string, std::unique_ptr<Node>>& node, int i) {
|
||||||
|
std::string threadName = "FitWorker-" + std::to_string(i);
|
||||||
|
#if defined(__linux__)
|
||||||
|
pthread_setname_np(pthread_self(), threadName.c_str());
|
||||||
|
#else
|
||||||
|
pthread_setname_np(threadName.c_str());
|
||||||
|
#endif
|
||||||
|
double numStates = static_cast<double>(node.second->getNumStates());
|
||||||
|
double smoothing_factor;
|
||||||
|
switch (smoothing) {
|
||||||
|
case Smoothing_t::ORIGINAL:
|
||||||
|
smoothing_factor = 1.0 / n_samples;
|
||||||
|
break;
|
||||||
|
case Smoothing_t::LAPLACE:
|
||||||
|
smoothing_factor = 1.0;
|
||||||
|
break;
|
||||||
|
case Smoothing_t::CESTNIK:
|
||||||
|
smoothing_factor = 1 / numStates;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
smoothing_factor = 0.0; // No smoothing
|
||||||
|
}
|
||||||
|
node.second->computeCPT(samples, features, smoothing_factor, weights);
|
||||||
|
semaphore.release();
|
||||||
|
};
|
||||||
|
int i = 0;
|
||||||
for (auto& node : nodes) {
|
for (auto& node : nodes) {
|
||||||
threads.emplace_back([this, &node, &weights]() {
|
semaphore.acquire();
|
||||||
node.second->computeCPT(samples, features, laplaceSmoothing, weights);
|
threads.emplace_back(worker, std::ref(node), i++);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
for (auto& thread : threads) {
|
for (auto& thread : threads) {
|
||||||
thread.join();
|
thread.join();
|
||||||
@ -207,14 +241,38 @@ namespace bayesnet {
|
|||||||
if (!fitted) {
|
if (!fitted) {
|
||||||
throw std::logic_error("You must call fit() before calling predict()");
|
throw std::logic_error("You must call fit() before calling predict()");
|
||||||
}
|
}
|
||||||
|
// Ensure the sample size is equal to the number of features
|
||||||
|
if (samples.size(0) != features.size() - 1) {
|
||||||
|
throw std::invalid_argument("(T) Sample size (" + std::to_string(samples.size(0)) +
|
||||||
|
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
|
||||||
|
}
|
||||||
torch::Tensor result;
|
torch::Tensor result;
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
std::mutex mtx;
|
||||||
|
auto& semaphore = CountingSemaphore::getInstance();
|
||||||
result = torch::zeros({ samples.size(1), classNumStates }, torch::kFloat64);
|
result = torch::zeros({ samples.size(1), classNumStates }, torch::kFloat64);
|
||||||
for (int i = 0; i < samples.size(1); ++i) {
|
auto worker = [&](const torch::Tensor& sample, int i) {
|
||||||
const torch::Tensor sample = samples.index({ "...", i });
|
std::string threadName = "PredictWorker-" + std::to_string(i);
|
||||||
|
#if defined(__linux__)
|
||||||
|
pthread_setname_np(pthread_self(), threadName.c_str());
|
||||||
|
#else
|
||||||
|
pthread_setname_np(threadName.c_str());
|
||||||
|
#endif
|
||||||
auto psample = predict_sample(sample);
|
auto psample = predict_sample(sample);
|
||||||
auto temp = torch::tensor(psample, torch::kFloat64);
|
auto temp = torch::tensor(psample, torch::kFloat64);
|
||||||
// result.index_put_({ i, "..." }, torch::tensor(predict_sample(sample), torch::kFloat64));
|
{
|
||||||
result.index_put_({ i, "..." }, temp);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
result.index_put_({ i, "..." }, temp);
|
||||||
|
}
|
||||||
|
semaphore.release();
|
||||||
|
};
|
||||||
|
for (int i = 0; i < samples.size(1); ++i) {
|
||||||
|
semaphore.acquire();
|
||||||
|
const torch::Tensor sample = samples.index({ "...", i });
|
||||||
|
threads.emplace_back(worker, sample, i);
|
||||||
|
}
|
||||||
|
for (auto& thread : threads) {
|
||||||
|
thread.join();
|
||||||
}
|
}
|
||||||
if (proba)
|
if (proba)
|
||||||
return result;
|
return result;
|
||||||
@ -239,18 +297,38 @@ namespace bayesnet {
|
|||||||
if (!fitted) {
|
if (!fitted) {
|
||||||
throw std::logic_error("You must call fit() before calling predict()");
|
throw std::logic_error("You must call fit() before calling predict()");
|
||||||
}
|
}
|
||||||
std::vector<int> predictions;
|
// Ensure the sample size is equal to the number of features
|
||||||
|
if (tsamples.size() != features.size() - 1) {
|
||||||
|
throw std::invalid_argument("(V) Sample size (" + std::to_string(tsamples.size()) +
|
||||||
|
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
|
||||||
|
}
|
||||||
|
std::vector<int> predictions(tsamples[0].size(), 0);
|
||||||
std::vector<int> sample;
|
std::vector<int> sample;
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
auto& semaphore = CountingSemaphore::getInstance();
|
||||||
|
auto worker = [&](const std::vector<int>& sample, const int row, int& prediction) {
|
||||||
|
std::string threadName = "(V)PWorker-" + std::to_string(row);
|
||||||
|
#if defined(__linux__)
|
||||||
|
pthread_setname_np(pthread_self(), threadName.c_str());
|
||||||
|
#else
|
||||||
|
pthread_setname_np(threadName.c_str());
|
||||||
|
#endif
|
||||||
|
auto classProbabilities = predict_sample(sample);
|
||||||
|
auto maxElem = max_element(classProbabilities.begin(), classProbabilities.end());
|
||||||
|
int predictedClass = distance(classProbabilities.begin(), maxElem);
|
||||||
|
prediction = predictedClass;
|
||||||
|
semaphore.release();
|
||||||
|
};
|
||||||
for (int row = 0; row < tsamples[0].size(); ++row) {
|
for (int row = 0; row < tsamples[0].size(); ++row) {
|
||||||
sample.clear();
|
sample.clear();
|
||||||
for (int col = 0; col < tsamples.size(); ++col) {
|
for (int col = 0; col < tsamples.size(); ++col) {
|
||||||
sample.push_back(tsamples[col][row]);
|
sample.push_back(tsamples[col][row]);
|
||||||
}
|
}
|
||||||
std::vector<double> classProbabilities = predict_sample(sample);
|
semaphore.acquire();
|
||||||
// Find the class with the maximum posterior probability
|
threads.emplace_back(worker, sample, row, std::ref(predictions[row]));
|
||||||
auto maxElem = max_element(classProbabilities.begin(), classProbabilities.end());
|
}
|
||||||
int predictedClass = distance(classProbabilities.begin(), maxElem);
|
for (auto& thread : threads) {
|
||||||
predictions.push_back(predictedClass);
|
thread.join();
|
||||||
}
|
}
|
||||||
return predictions;
|
return predictions;
|
||||||
}
|
}
|
||||||
@ -261,14 +339,36 @@ namespace bayesnet {
|
|||||||
if (!fitted) {
|
if (!fitted) {
|
||||||
throw std::logic_error("You must call fit() before calling predict_proba()");
|
throw std::logic_error("You must call fit() before calling predict_proba()");
|
||||||
}
|
}
|
||||||
std::vector<std::vector<double>> predictions;
|
// Ensure the sample size is equal to the number of features
|
||||||
|
if (tsamples.size() != features.size() - 1) {
|
||||||
|
throw std::invalid_argument("(V) Sample size (" + std::to_string(tsamples.size()) +
|
||||||
|
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
|
||||||
|
}
|
||||||
|
std::vector<std::vector<double>> predictions(tsamples[0].size(), std::vector<double>(classNumStates, 0.0));
|
||||||
std::vector<int> sample;
|
std::vector<int> sample;
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
auto& semaphore = CountingSemaphore::getInstance();
|
||||||
|
auto worker = [&](const std::vector<int>& sample, int row, std::vector<double>& predictions) {
|
||||||
|
std::string threadName = "(V)PWorker-" + std::to_string(row);
|
||||||
|
#if defined(__linux__)
|
||||||
|
pthread_setname_np(pthread_self(), threadName.c_str());
|
||||||
|
#else
|
||||||
|
pthread_setname_np(threadName.c_str());
|
||||||
|
#endif
|
||||||
|
std::vector<double> classProbabilities = predict_sample(sample);
|
||||||
|
predictions = classProbabilities;
|
||||||
|
semaphore.release();
|
||||||
|
};
|
||||||
for (int row = 0; row < tsamples[0].size(); ++row) {
|
for (int row = 0; row < tsamples[0].size(); ++row) {
|
||||||
sample.clear();
|
sample.clear();
|
||||||
for (int col = 0; col < tsamples.size(); ++col) {
|
for (int col = 0; col < tsamples.size(); ++col) {
|
||||||
sample.push_back(tsamples[col][row]);
|
sample.push_back(tsamples[col][row]);
|
||||||
}
|
}
|
||||||
predictions.push_back(predict_sample(sample));
|
semaphore.acquire();
|
||||||
|
threads.emplace_back(worker, sample, row, std::ref(predictions[row]));
|
||||||
|
}
|
||||||
|
for (auto& thread : threads) {
|
||||||
|
thread.join();
|
||||||
}
|
}
|
||||||
return predictions;
|
return predictions;
|
||||||
}
|
}
|
||||||
@ -286,11 +386,6 @@ namespace bayesnet {
|
|||||||
// Return 1xn std::vector of probabilities
|
// Return 1xn std::vector of probabilities
|
||||||
std::vector<double> Network::predict_sample(const std::vector<int>& sample)
|
std::vector<double> Network::predict_sample(const std::vector<int>& sample)
|
||||||
{
|
{
|
||||||
// Ensure the sample size is equal to the number of features
|
|
||||||
if (sample.size() != features.size() - 1) {
|
|
||||||
throw std::invalid_argument("Sample size (" + std::to_string(sample.size()) +
|
|
||||||
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
|
|
||||||
}
|
|
||||||
std::map<std::string, int> evidence;
|
std::map<std::string, int> evidence;
|
||||||
for (int i = 0; i < sample.size(); ++i) {
|
for (int i = 0; i < sample.size(); ++i) {
|
||||||
evidence[features[i]] = sample[i];
|
evidence[features[i]] = sample[i];
|
||||||
@ -300,44 +395,26 @@ namespace bayesnet {
|
|||||||
// Return 1xn std::vector of probabilities
|
// Return 1xn std::vector of probabilities
|
||||||
std::vector<double> Network::predict_sample(const torch::Tensor& sample)
|
std::vector<double> Network::predict_sample(const torch::Tensor& sample)
|
||||||
{
|
{
|
||||||
// Ensure the sample size is equal to the number of features
|
|
||||||
if (sample.size(0) != features.size() - 1) {
|
|
||||||
throw std::invalid_argument("Sample size (" + std::to_string(sample.size(0)) +
|
|
||||||
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
|
|
||||||
}
|
|
||||||
std::map<std::string, int> evidence;
|
std::map<std::string, int> evidence;
|
||||||
for (int i = 0; i < sample.size(0); ++i) {
|
for (int i = 0; i < sample.size(0); ++i) {
|
||||||
evidence[features[i]] = sample[i].item<int>();
|
evidence[features[i]] = sample[i].item<int>();
|
||||||
}
|
}
|
||||||
return exactInference(evidence);
|
return exactInference(evidence);
|
||||||
}
|
}
|
||||||
double Network::computeFactor(std::map<std::string, int>& completeEvidence)
|
|
||||||
{
|
|
||||||
double result = 1.0;
|
|
||||||
for (auto& node : getNodes()) {
|
|
||||||
result *= node.second->getFactorValue(completeEvidence);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
std::vector<double> Network::exactInference(std::map<std::string, int>& evidence)
|
std::vector<double> Network::exactInference(std::map<std::string, int>& evidence)
|
||||||
{
|
{
|
||||||
std::vector<double> result(classNumStates, 0.0);
|
std::vector<double> result(classNumStates, 0.0);
|
||||||
std::vector<std::thread> threads;
|
auto completeEvidence = std::map<std::string, int>(evidence);
|
||||||
std::mutex mtx;
|
|
||||||
for (int i = 0; i < classNumStates; ++i) {
|
for (int i = 0; i < classNumStates; ++i) {
|
||||||
threads.emplace_back([this, &result, &evidence, i, &mtx]() {
|
completeEvidence[getClassName()] = i;
|
||||||
auto completeEvidence = std::map<std::string, int>(evidence);
|
double partial = 1.0;
|
||||||
completeEvidence[getClassName()] = i;
|
for (auto& node : getNodes()) {
|
||||||
double factor = computeFactor(completeEvidence);
|
partial *= node.second->getFactorValue(completeEvidence);
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
}
|
||||||
result[i] = factor;
|
result[i] = partial;
|
||||||
});
|
|
||||||
}
|
|
||||||
for (auto& thread : threads) {
|
|
||||||
thread.join();
|
|
||||||
}
|
}
|
||||||
// Normalize result
|
// Normalize result
|
||||||
double sum = accumulate(result.begin(), result.end(), 0.0);
|
double sum = std::accumulate(result.begin(), result.end(), 0.0);
|
||||||
transform(result.begin(), result.end(), result.begin(), [sum](const double& value) { return value / sum; });
|
transform(result.begin(), result.end(), result.begin(), [sum](const double& value) { return value / sum; });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,18 @@
|
|||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
|
enum class Smoothing_t {
|
||||||
|
NONE = -1,
|
||||||
|
ORIGINAL = 0,
|
||||||
|
LAPLACE,
|
||||||
|
CESTNIK
|
||||||
|
};
|
||||||
class Network {
|
class Network {
|
||||||
public:
|
public:
|
||||||
Network();
|
Network();
|
||||||
explicit Network(float);
|
|
||||||
explicit Network(const Network&);
|
explicit Network(const Network&);
|
||||||
~Network() = default;
|
~Network() = default;
|
||||||
torch::Tensor& getSamples();
|
torch::Tensor& getSamples();
|
||||||
float getMaxThreads() const;
|
|
||||||
void addNode(const std::string&);
|
void addNode(const std::string&);
|
||||||
void addEdge(const std::string&, const std::string&);
|
void addEdge(const std::string&, const std::string&);
|
||||||
std::map<std::string, std::unique_ptr<Node>>& getNodes();
|
std::map<std::string, std::unique_ptr<Node>>& getNodes();
|
||||||
@ -32,9 +36,9 @@ namespace bayesnet {
|
|||||||
/*
|
/*
|
||||||
Notice: Nodes have to be inserted in the same order as they are in the dataset, i.e., first node is first column and so on.
|
Notice: Nodes have to be inserted in the same order as they are in the dataset, i.e., first node is first column and so on.
|
||||||
*/
|
*/
|
||||||
void fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states);
|
void fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
|
||||||
void fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states);
|
void fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
|
||||||
void fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states);
|
void fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
|
||||||
std::vector<int> predict(const std::vector<std::vector<int>>&); // Return mx1 std::vector of predictions
|
std::vector<int> predict(const std::vector<std::vector<int>>&); // Return mx1 std::vector of predictions
|
||||||
torch::Tensor predict(const torch::Tensor&); // Return mx1 tensor of predictions
|
torch::Tensor predict(const torch::Tensor&); // Return mx1 tensor of predictions
|
||||||
torch::Tensor predict_tensor(const torch::Tensor& samples, const bool proba);
|
torch::Tensor predict_tensor(const torch::Tensor& samples, const bool proba);
|
||||||
@ -50,19 +54,16 @@ namespace bayesnet {
|
|||||||
private:
|
private:
|
||||||
std::map<std::string, std::unique_ptr<Node>> nodes;
|
std::map<std::string, std::unique_ptr<Node>> nodes;
|
||||||
bool fitted;
|
bool fitted;
|
||||||
float maxThreads = 0.95;
|
|
||||||
int classNumStates;
|
int classNumStates;
|
||||||
std::vector<std::string> features; // Including classname
|
std::vector<std::string> features; // Including classname
|
||||||
std::string className;
|
std::string className;
|
||||||
double laplaceSmoothing;
|
|
||||||
torch::Tensor samples; // n+1xm tensor used to fit the model
|
torch::Tensor samples; // n+1xm tensor used to fit the model
|
||||||
bool isCyclic(const std::string&, std::unordered_set<std::string>&, std::unordered_set<std::string>&);
|
bool isCyclic(const std::string&, std::unordered_set<std::string>&, std::unordered_set<std::string>&);
|
||||||
std::vector<double> predict_sample(const std::vector<int>&);
|
std::vector<double> predict_sample(const std::vector<int>&);
|
||||||
std::vector<double> predict_sample(const torch::Tensor&);
|
std::vector<double> predict_sample(const torch::Tensor&);
|
||||||
std::vector<double> exactInference(std::map<std::string, int>&);
|
std::vector<double> exactInference(std::map<std::string, int>&);
|
||||||
double computeFactor(std::map<std::string, int>&);
|
void completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing);
|
||||||
void completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
|
void checkFitData(int n_samples, int n_features, int n_samples_y, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
|
||||||
void checkFitData(int n_features, int n_samples, int n_samples_y, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
|
|
||||||
void setStates(const std::map<std::string, std::vector<int>>&);
|
void setStates(const std::map<std::string, std::vector<int>>&);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -90,51 +90,54 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void Node::computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double laplaceSmoothing, const torch::Tensor& weights)
|
void Node::computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double smoothing, const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
dimensions.clear();
|
dimensions.clear();
|
||||||
// Get dimensions of the CPT
|
// Get dimensions of the CPT
|
||||||
dimensions.push_back(numStates);
|
dimensions.push_back(numStates);
|
||||||
transform(parents.begin(), parents.end(), back_inserter(dimensions), [](const auto& parent) { return parent->getNumStates(); });
|
transform(parents.begin(), parents.end(), back_inserter(dimensions), [](const auto& parent) { return parent->getNumStates(); });
|
||||||
// Create a tensor of zeros with the dimensions of the CPT
|
// Create a tensor of zeros with the dimensions of the CPT
|
||||||
cpTable = torch::zeros(dimensions, torch::kFloat) + laplaceSmoothing;
|
cpTable = torch::zeros(dimensions, torch::kDouble) + smoothing;
|
||||||
// Fill table with counts
|
// Fill table with counts
|
||||||
auto pos = find(features.begin(), features.end(), name);
|
auto pos = find(features.begin(), features.end(), name);
|
||||||
if (pos == features.end()) {
|
if (pos == features.end()) {
|
||||||
throw std::logic_error("Feature " + name + " not found in dataset");
|
throw std::logic_error("Feature " + name + " not found in dataset");
|
||||||
}
|
}
|
||||||
int name_index = pos - features.begin();
|
int name_index = pos - features.begin();
|
||||||
|
c10::List<c10::optional<at::Tensor>> coordinates;
|
||||||
for (int n_sample = 0; n_sample < dataset.size(1); ++n_sample) {
|
for (int n_sample = 0; n_sample < dataset.size(1); ++n_sample) {
|
||||||
c10::List<c10::optional<at::Tensor>> coordinates;
|
coordinates.clear();
|
||||||
coordinates.push_back(dataset.index({ name_index, n_sample }));
|
auto sample = dataset.index({ "...", n_sample });
|
||||||
|
coordinates.push_back(sample[name_index]);
|
||||||
for (auto parent : parents) {
|
for (auto parent : parents) {
|
||||||
pos = find(features.begin(), features.end(), parent->getName());
|
pos = find(features.begin(), features.end(), parent->getName());
|
||||||
if (pos == features.end()) {
|
if (pos == features.end()) {
|
||||||
throw std::logic_error("Feature parent " + parent->getName() + " not found in dataset");
|
throw std::logic_error("Feature parent " + parent->getName() + " not found in dataset");
|
||||||
}
|
}
|
||||||
int parent_index = pos - features.begin();
|
int parent_index = pos - features.begin();
|
||||||
coordinates.push_back(dataset.index({ parent_index, n_sample }));
|
coordinates.push_back(sample[parent_index]);
|
||||||
}
|
}
|
||||||
// Increment the count of the corresponding coordinate
|
// Increment the count of the corresponding coordinate
|
||||||
cpTable.index_put_({ coordinates }, cpTable.index({ coordinates }) + weights.index({ n_sample }).item<double>());
|
cpTable.index_put_({ coordinates }, weights.index({ n_sample }), true);
|
||||||
}
|
}
|
||||||
// Normalize the counts
|
// Normalize the counts
|
||||||
|
// Divide each row by the sum of the row
|
||||||
cpTable = cpTable / cpTable.sum(0);
|
cpTable = cpTable / cpTable.sum(0);
|
||||||
}
|
}
|
||||||
float Node::getFactorValue(std::map<std::string, int>& evidence)
|
double Node::getFactorValue(std::map<std::string, int>& evidence)
|
||||||
{
|
{
|
||||||
c10::List<c10::optional<at::Tensor>> coordinates;
|
c10::List<c10::optional<at::Tensor>> coordinates;
|
||||||
// following predetermined order of indices in the cpTable (see Node.h)
|
// following predetermined order of indices in the cpTable (see Node.h)
|
||||||
coordinates.push_back(at::tensor(evidence[name]));
|
coordinates.push_back(at::tensor(evidence[name]));
|
||||||
transform(parents.begin(), parents.end(), std::back_inserter(coordinates), [&evidence](const auto& parent) { return at::tensor(evidence[parent->getName()]); });
|
transform(parents.begin(), parents.end(), std::back_inserter(coordinates), [&evidence](const auto& parent) { return at::tensor(evidence[parent->getName()]); });
|
||||||
return cpTable.index({ coordinates }).item<float>();
|
return cpTable.index({ coordinates }).item<double>();
|
||||||
}
|
}
|
||||||
std::vector<std::string> Node::graph(const std::string& className)
|
std::vector<std::string> Node::graph(const std::string& className)
|
||||||
{
|
{
|
||||||
auto output = std::vector<std::string>();
|
auto output = std::vector<std::string>();
|
||||||
auto suffix = name == className ? ", fontcolor=red, fillcolor=lightblue, style=filled " : "";
|
auto suffix = name == className ? ", fontcolor=red, fillcolor=lightblue, style=filled " : "";
|
||||||
output.push_back(name + " [shape=circle" + suffix + "] \n");
|
output.push_back("\"" + name + "\" [shape=circle" + suffix + "] \n");
|
||||||
transform(children.begin(), children.end(), back_inserter(output), [this](const auto& child) { return name + " -> " + child->getName(); });
|
transform(children.begin(), children.end(), back_inserter(output), [this](const auto& child) { return "\"" + name + "\" -> \"" + child->getName() + "\""; });
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,12 +23,12 @@ namespace bayesnet {
|
|||||||
std::vector<Node*>& getParents();
|
std::vector<Node*>& getParents();
|
||||||
std::vector<Node*>& getChildren();
|
std::vector<Node*>& getChildren();
|
||||||
torch::Tensor& getCPT();
|
torch::Tensor& getCPT();
|
||||||
void computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double laplaceSmoothing, const torch::Tensor& weights);
|
void computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double smoothing, const torch::Tensor& weights);
|
||||||
int getNumStates() const;
|
int getNumStates() const;
|
||||||
void setNumStates(int);
|
void setNumStates(int);
|
||||||
unsigned minFill();
|
unsigned minFill();
|
||||||
std::vector<std::string> graph(const std::string& clasName); // Returns a std::vector of std::strings representing the graph in graphviz format
|
std::vector<std::string> graph(const std::string& clasName); // Returns a std::vector of std::strings representing the graph in graphviz format
|
||||||
float getFactorValue(std::map<std::string, int>&);
|
double getFactorValue(std::map<std::string, int>&);
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<Node*> parents;
|
std::vector<Node*> parents;
|
||||||
|
@ -30,6 +30,53 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
|
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
|
||||||
}
|
}
|
||||||
|
std::vector<std::pair<int, int>> Metrics::SelectKPairs(const torch::Tensor& weights, std::vector<int>& featuresExcluded, bool ascending, unsigned k)
|
||||||
|
{
|
||||||
|
// Return the K Best features
|
||||||
|
auto n = features.size();
|
||||||
|
// compute scores
|
||||||
|
scoresKPairs.clear();
|
||||||
|
pairsKBest.clear();
|
||||||
|
auto labels = samples.index({ -1, "..." });
|
||||||
|
for (int i = 0; i < n - 1; ++i) {
|
||||||
|
if (std::find(featuresExcluded.begin(), featuresExcluded.end(), i) != featuresExcluded.end()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int j = i + 1; j < n; ++j) {
|
||||||
|
if (std::find(featuresExcluded.begin(), featuresExcluded.end(), j) != featuresExcluded.end()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto key = std::make_pair(i, j);
|
||||||
|
auto value = conditionalMutualInformation(samples.index({ i, "..." }), samples.index({ j, "..." }), labels, weights);
|
||||||
|
scoresKPairs.push_back({ key, value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sort scores
|
||||||
|
if (ascending) {
|
||||||
|
sort(scoresKPairs.begin(), scoresKPairs.end(), [](auto& a, auto& b)
|
||||||
|
{ return a.second < b.second; });
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sort(scoresKPairs.begin(), scoresKPairs.end(), [](auto& a, auto& b)
|
||||||
|
{ return a.second > b.second; });
|
||||||
|
}
|
||||||
|
for (auto& [pairs, score] : scoresKPairs) {
|
||||||
|
pairsKBest.push_back(pairs);
|
||||||
|
}
|
||||||
|
if (k != 0 && k < pairsKBest.size()) {
|
||||||
|
if (ascending) {
|
||||||
|
int limit = pairsKBest.size() - k;
|
||||||
|
for (int i = 0; i < limit; i++) {
|
||||||
|
pairsKBest.erase(pairsKBest.begin());
|
||||||
|
scoresKPairs.erase(scoresKPairs.begin());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pairsKBest.resize(k);
|
||||||
|
scoresKPairs.resize(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pairsKBest;
|
||||||
|
}
|
||||||
std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k)
|
std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k)
|
||||||
{
|
{
|
||||||
// Return the K Best features
|
// Return the K Best features
|
||||||
@ -69,7 +116,10 @@ namespace bayesnet {
|
|||||||
{
|
{
|
||||||
return scoresKBest;
|
return scoresKBest;
|
||||||
}
|
}
|
||||||
|
std::vector<std::pair<std::pair<int, int>, double>> Metrics::getScoresKPairs() const
|
||||||
|
{
|
||||||
|
return scoresKPairs;
|
||||||
|
}
|
||||||
torch::Tensor Metrics::conditionalEdge(const torch::Tensor& weights)
|
torch::Tensor Metrics::conditionalEdge(const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
auto result = std::vector<double>();
|
auto result = std::vector<double>();
|
||||||
@ -148,24 +198,20 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
return entropyValue;
|
return entropyValue;
|
||||||
}
|
}
|
||||||
// H(Y|X,C) = sum_{x in X, c in C} p(x,c) H(Y|X=x,C=c)
|
// H(X|Y,C) = sum_{y in Y, c in C} p(x,c) H(X|Y=y,C=c)
|
||||||
double Metrics::conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights)
|
double Metrics::conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
// Ensure the tensors are of the same length
|
// Ensure the tensors are of the same length
|
||||||
assert(firstFeature.size(0) == secondFeature.size(0) && firstFeature.size(0) == labels.size(0) && firstFeature.size(0) == weights.size(0));
|
assert(firstFeature.size(0) == secondFeature.size(0) && firstFeature.size(0) == labels.size(0) && firstFeature.size(0) == weights.size(0));
|
||||||
|
|
||||||
// Convert tensors to vectors for easier processing
|
// Convert tensors to vectors for easier processing
|
||||||
auto firstFeatureData = firstFeature.accessor<int, 1>();
|
auto firstFeatureData = firstFeature.accessor<int, 1>();
|
||||||
auto secondFeatureData = secondFeature.accessor<int, 1>();
|
auto secondFeatureData = secondFeature.accessor<int, 1>();
|
||||||
auto labelsData = labels.accessor<int, 1>();
|
auto labelsData = labels.accessor<int, 1>();
|
||||||
auto weightsData = weights.accessor<double, 1>();
|
auto weightsData = weights.accessor<double, 1>();
|
||||||
|
|
||||||
int numSamples = firstFeature.size(0);
|
int numSamples = firstFeature.size(0);
|
||||||
|
|
||||||
// Maps for joint and marginal probabilities
|
// Maps for joint and marginal probabilities
|
||||||
std::map<std::tuple<int, int, int>, double> jointCount;
|
std::map<std::tuple<int, int, int>, double> jointCount;
|
||||||
std::map<std::tuple<int, int>, double> marginalCount;
|
std::map<std::tuple<int, int>, double> marginalCount;
|
||||||
|
|
||||||
// Compute joint and marginal counts
|
// Compute joint and marginal counts
|
||||||
for (int i = 0; i < numSamples; ++i) {
|
for (int i = 0; i < numSamples; ++i) {
|
||||||
auto keyJoint = std::make_tuple(firstFeatureData[i], labelsData[i], secondFeatureData[i]);
|
auto keyJoint = std::make_tuple(firstFeatureData[i], labelsData[i], secondFeatureData[i]);
|
||||||
@ -174,34 +220,29 @@ namespace bayesnet {
|
|||||||
jointCount[keyJoint] += weightsData[i];
|
jointCount[keyJoint] += weightsData[i];
|
||||||
marginalCount[keyMarginal] += weightsData[i];
|
marginalCount[keyMarginal] += weightsData[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Total weight sum
|
// Total weight sum
|
||||||
double totalWeight = torch::sum(weights).item<double>();
|
double totalWeight = torch::sum(weights).item<double>();
|
||||||
if (totalWeight == 0)
|
if (totalWeight == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Compute the conditional entropy
|
// Compute the conditional entropy
|
||||||
double conditionalEntropy = 0.0;
|
double conditionalEntropy = 0.0;
|
||||||
|
|
||||||
for (const auto& [keyJoint, jointFreq] : jointCount) {
|
for (const auto& [keyJoint, jointFreq] : jointCount) {
|
||||||
auto [x, c, y] = keyJoint;
|
auto [x, c, y] = keyJoint;
|
||||||
auto keyMarginal = std::make_tuple(x, c);
|
auto keyMarginal = std::make_tuple(x, c);
|
||||||
|
//double p_xc = marginalCount[keyMarginal] / totalWeight;
|
||||||
double p_xc = marginalCount[keyMarginal] / totalWeight;
|
|
||||||
double p_y_given_xc = jointFreq / marginalCount[keyMarginal];
|
double p_y_given_xc = jointFreq / marginalCount[keyMarginal];
|
||||||
|
|
||||||
if (p_y_given_xc > 0) {
|
if (p_y_given_xc > 0) {
|
||||||
conditionalEntropy -= (jointFreq / totalWeight) * std::log(p_y_given_xc);
|
conditionalEntropy -= (jointFreq / totalWeight) * std::log(p_y_given_xc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return conditionalEntropy;
|
return conditionalEntropy;
|
||||||
}
|
}
|
||||||
// I(X;Y) = H(Y) - H(Y|X)
|
// I(X;Y) = H(Y) - H(Y|X) ; I(X;Y) >= 0
|
||||||
double Metrics::mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights)
|
double Metrics::mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
return entropy(firstFeature, weights) - conditionalEntropy(firstFeature, secondFeature, weights);
|
return std::max(entropy(firstFeature, weights) - conditionalEntropy(firstFeature, secondFeature, weights), 0.0);
|
||||||
}
|
}
|
||||||
// I(X;Y|C) = H(Y|C) - H(Y|X,C)
|
// I(X;Y|C) = H(X|C) - H(X|Y,C) >= 0
|
||||||
double Metrics::conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights)
|
double Metrics::conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
return std::max(conditionalEntropy(firstFeature, labels, weights) - conditionalEntropy(firstFeature, secondFeature, labels, weights), 0.0);
|
return std::max(conditionalEntropy(firstFeature, labels, weights) - conditionalEntropy(firstFeature, secondFeature, labels, weights), 0.0);
|
||||||
|
@ -16,7 +16,9 @@ namespace bayesnet {
|
|||||||
Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
|
Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
|
||||||
Metrics(const std::vector<std::vector<int>>& vsamples, const std::vector<int>& labels, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
|
Metrics(const std::vector<std::vector<int>>& vsamples, const std::vector<int>& labels, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
|
||||||
std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0);
|
std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0);
|
||||||
|
std::vector<std::pair<int, int>> SelectKPairs(const torch::Tensor& weights, std::vector<int>& featuresExcluded, bool ascending = false, unsigned k = 0);
|
||||||
std::vector<double> getScoresKBest() const;
|
std::vector<double> getScoresKBest() const;
|
||||||
|
std::vector<std::pair<std::pair<int, int>, double>> getScoresKPairs() const;
|
||||||
double mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
double mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
||||||
double conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights);
|
double conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights);
|
||||||
torch::Tensor conditionalEdge(const torch::Tensor& weights);
|
torch::Tensor conditionalEdge(const torch::Tensor& weights);
|
||||||
@ -33,7 +35,7 @@ namespace bayesnet {
|
|||||||
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
|
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
|
||||||
{
|
{
|
||||||
std::vector<std::pair<T, T>> result;
|
std::vector<std::pair<T, T>> result;
|
||||||
for (int i = 0; i < source.size(); ++i) {
|
for (int i = 0; i < source.size() - 1; ++i) {
|
||||||
T temp = source[i];
|
T temp = source[i];
|
||||||
for (int j = i + 1; j < source.size(); ++j) {
|
for (int j = i + 1; j < source.size(); ++j) {
|
||||||
result.push_back({ temp, source[j] });
|
result.push_back({ temp, source[j] });
|
||||||
@ -52,6 +54,8 @@ namespace bayesnet {
|
|||||||
int classNumStates = 0;
|
int classNumStates = 0;
|
||||||
std::vector<double> scoresKBest;
|
std::vector<double> scoresKBest;
|
||||||
std::vector<int> featuresKBest; // sorted indices of the features
|
std::vector<int> featuresKBest; // sorted indices of the features
|
||||||
|
std::vector<std::pair<int, int>> pairsKBest; // sorted indices of the pairs
|
||||||
|
std::vector<std::pair<std::pair<int, int>, double>> scoresKPairs;
|
||||||
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
46
bayesnet/utils/CountingSemaphore.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef COUNTING_SEMAPHORE_H
|
||||||
|
#define COUNTING_SEMAPHORE_H
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <thread>
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
class CountingSemaphore {
|
||||||
|
public:
|
||||||
|
static CountingSemaphore& getInstance()
|
||||||
|
{
|
||||||
|
static CountingSemaphore instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
// Delete copy constructor and assignment operator
|
||||||
|
CountingSemaphore(const CountingSemaphore&) = delete;
|
||||||
|
CountingSemaphore& operator=(const CountingSemaphore&) = delete;
|
||||||
|
void acquire()
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(mtx_);
|
||||||
|
cv_.wait(lock, [this]() { return count_ > 0; });
|
||||||
|
--count_;
|
||||||
|
}
|
||||||
|
void release()
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mtx_);
|
||||||
|
++count_;
|
||||||
|
if (count_ <= max_count_) {
|
||||||
|
cv_.notify_one();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
CountingSemaphore()
|
||||||
|
: max_count_(std::max(1u, static_cast<uint>(0.95 * std::thread::hardware_concurrency()))),
|
||||||
|
count_(max_count_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
std::mutex mtx_;
|
||||||
|
std::condition_variable cv_;
|
||||||
|
const uint max_count_;
|
||||||
|
uint count_;
|
||||||
|
};
|
||||||
|
#endif
|
@ -53,14 +53,14 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertElement(std::list<int>& variables, int variable)
|
void MST::insertElement(std::list<int>& variables, int variable)
|
||||||
{
|
{
|
||||||
if (std::find(variables.begin(), variables.end(), variable) == variables.end()) {
|
if (std::find(variables.begin(), variables.end(), variable) == variables.end()) {
|
||||||
variables.push_front(variable);
|
variables.push_front(variable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<int, int>> reorder(std::vector<std::pair<float, std::pair<int, int>>> T, int root_original)
|
std::vector<std::pair<int, int>> MST::reorder(std::vector<std::pair<float, std::pair<int, int>>> T, int root_original)
|
||||||
{
|
{
|
||||||
// Create the edges of a DAG from the MST
|
// Create the edges of a DAG from the MST
|
||||||
// replacing unordered_set with list because unordered_set cannot guarantee the order of the elements inserted
|
// replacing unordered_set with list because unordered_set cannot guarantee the order of the elements inserted
|
||||||
|
@ -14,6 +14,8 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
MST() = default;
|
MST() = default;
|
||||||
MST(const std::vector<std::string>& features, const torch::Tensor& weights, const int root);
|
MST(const std::vector<std::string>& features, const torch::Tensor& weights, const int root);
|
||||||
|
void insertElement(std::list<int>& variables, int variable);
|
||||||
|
std::vector<std::pair<int, int>> reorder(std::vector<std::pair<float, std::pair<int, int>>> T, int root_original);
|
||||||
std::vector<std::pair<int, int>> maximumSpanningTree();
|
std::vector<std::pair<int, int>> maximumSpanningTree();
|
||||||
private:
|
private:
|
||||||
torch::Tensor weights;
|
torch::Tensor weights;
|
||||||
|
@ -137,7 +137,7 @@
|
|||||||
|
|
||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
option(CODE_COVERAGE_VERBOSE "Verbose information" FALSE)
|
option(CODE_COVERAGE_VERBOSE "Verbose information" TRUE)
|
||||||
|
|
||||||
# Check prereqs
|
# Check prereqs
|
||||||
find_program( GCOV_PATH gcov )
|
find_program( GCOV_PATH gcov )
|
||||||
@ -160,7 +160,11 @@ foreach(LANG ${LANGUAGES})
|
|||||||
endif()
|
endif()
|
||||||
elseif(NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU"
|
elseif(NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU"
|
||||||
AND NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "(LLVM)?[Ff]lang")
|
AND NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "(LLVM)?[Ff]lang")
|
||||||
message(FATAL_ERROR "Compiler is not GNU or Flang! Aborting...")
|
if ("${LANG}" MATCHES "CUDA")
|
||||||
|
message(STATUS "Ignoring CUDA")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Compiler is not GNU or Flang! Aborting...")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
@ -1,36 +1,16 @@
|
|||||||
@startuml
|
@startuml
|
||||||
title clang-uml class diagram model
|
title clang-uml class diagram model
|
||||||
class "bayesnet::Metrics" as C_0000736965376885623323
|
class "bayesnet::Node" as C_0010428199432536647474
|
||||||
class C_0000736965376885623323 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0010428199432536647474 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+Metrics() = default : void
|
|
||||||
+Metrics(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int classNumStates) : void
|
|
||||||
+Metrics(const std::vector<std::vector<int>> & vsamples, const std::vector<int> & labels, const std::vector<std::string> & features, const std::string & className, const int classNumStates) : void
|
|
||||||
..
|
|
||||||
+SelectKBestWeighted(const torch::Tensor & weights, bool ascending = false, unsigned int k = 0) : std::vector<int>
|
|
||||||
+conditionalEdge(const torch::Tensor & weights) : torch::Tensor
|
|
||||||
+conditionalEdgeWeights(std::vector<float> & weights) : std::vector<float>
|
|
||||||
#doCombinations<T>(const std::vector<T> & source) : std::vector<std::pair<T, T> >
|
|
||||||
#entropy(const torch::Tensor & feature, const torch::Tensor & weights) : double
|
|
||||||
+getScoresKBest() const : std::vector<double>
|
|
||||||
+maximumSpanningTree(const std::vector<std::string> & features, const torch::Tensor & weights, const int root) : std::vector<std::pair<int,int>>
|
|
||||||
+mutualInformation(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & weights) : double
|
|
||||||
#pop_first<T>(std::vector<T> & v) : T
|
|
||||||
__
|
|
||||||
#className : std::string
|
|
||||||
#features : std::vector<std::string>
|
|
||||||
#samples : torch::Tensor
|
|
||||||
}
|
|
||||||
class "bayesnet::Node" as C_0001303524929067080934
|
|
||||||
class C_0001303524929067080934 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+Node(const std::string &) : void
|
+Node(const std::string &) : void
|
||||||
..
|
..
|
||||||
+addChild(Node *) : void
|
+addChild(Node *) : void
|
||||||
+addParent(Node *) : void
|
+addParent(Node *) : void
|
||||||
+clear() : void
|
+clear() : void
|
||||||
+computeCPT(const torch::Tensor & dataset, const std::vector<std::string> & features, const double laplaceSmoothing, const torch::Tensor & weights) : void
|
+computeCPT(const torch::Tensor & dataset, const std::vector<std::string> & features, const double smoothing, const torch::Tensor & weights) : void
|
||||||
+getCPT() : torch::Tensor &
|
+getCPT() : torch::Tensor &
|
||||||
+getChildren() : std::vector<Node *> &
|
+getChildren() : std::vector<Node *> &
|
||||||
+getFactorValue(std::map<std::string,int> &) : float
|
+getFactorValue(std::map<std::string,int> &) : double
|
||||||
+getName() const : std::string
|
+getName() const : std::string
|
||||||
+getNumStates() const : int
|
+getNumStates() const : int
|
||||||
+getParents() : std::vector<Node *> &
|
+getParents() : std::vector<Node *> &
|
||||||
@ -41,24 +21,29 @@ class C_0001303524929067080934 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+setNumStates(int) : void
|
+setNumStates(int) : void
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::Network" as C_0001186707649890429575
|
enum "bayesnet::Smoothing_t" as C_0013393078277439680282
|
||||||
class C_0001186707649890429575 #aliceblue;line:blue;line.dotted;text:blue {
|
enum C_0013393078277439680282 {
|
||||||
|
NONE
|
||||||
|
ORIGINAL
|
||||||
|
LAPLACE
|
||||||
|
CESTNIK
|
||||||
|
}
|
||||||
|
class "bayesnet::Network" as C_0009493661199123436603
|
||||||
|
class C_0009493661199123436603 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+Network() : void
|
+Network() : void
|
||||||
+Network(float) : void
|
|
||||||
+Network(const Network &) : void
|
+Network(const Network &) : void
|
||||||
+~Network() = default : void
|
+~Network() = default : void
|
||||||
..
|
..
|
||||||
+addEdge(const std::string &, const std::string &) : void
|
+addEdge(const std::string &, const std::string &) : void
|
||||||
+addNode(const std::string &) : void
|
+addNode(const std::string &) : void
|
||||||
+dump_cpt() const : std::string
|
+dump_cpt() const : std::string
|
||||||
+fit(const torch::Tensor & samples, const torch::Tensor & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states) : void
|
+fit(const torch::Tensor & samples, const torch::Tensor & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : void
|
||||||
+fit(const torch::Tensor & X, const torch::Tensor & y, const torch::Tensor & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states) : void
|
+fit(const torch::Tensor & X, const torch::Tensor & y, const torch::Tensor & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : void
|
||||||
+fit(const std::vector<std::vector<int>> & input_data, const std::vector<int> & labels, const std::vector<double> & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states) : void
|
+fit(const std::vector<std::vector<int>> & input_data, const std::vector<int> & labels, const std::vector<double> & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : void
|
||||||
+getClassName() const : std::string
|
+getClassName() const : std::string
|
||||||
+getClassNumStates() const : int
|
+getClassNumStates() const : int
|
||||||
+getEdges() const : std::vector<std::pair<std::string,std::string>>
|
+getEdges() const : std::vector<std::pair<std::string,std::string>>
|
||||||
+getFeatures() const : std::vector<std::string>
|
+getFeatures() const : std::vector<std::string>
|
||||||
+getMaxThreads() const : float
|
|
||||||
+getNodes() : std::map<std::string,std::unique_ptr<Node>> &
|
+getNodes() : std::map<std::string,std::unique_ptr<Node>> &
|
||||||
+getNumEdges() const : int
|
+getNumEdges() const : int
|
||||||
+getSamples() : torch::Tensor &
|
+getSamples() : torch::Tensor &
|
||||||
@ -76,21 +61,21 @@ class C_0001186707649890429575 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+version() : std::string
|
+version() : std::string
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
enum "bayesnet::status_t" as C_0000738420730783851375
|
enum "bayesnet::status_t" as C_0005907365846270811004
|
||||||
enum C_0000738420730783851375 {
|
enum C_0005907365846270811004 {
|
||||||
NORMAL
|
NORMAL
|
||||||
WARNING
|
WARNING
|
||||||
ERROR
|
ERROR
|
||||||
}
|
}
|
||||||
abstract "bayesnet::BaseClassifier" as C_0000327135989451974539
|
abstract "bayesnet::BaseClassifier" as C_0002617087915615796317
|
||||||
abstract C_0000327135989451974539 #aliceblue;line:blue;line.dotted;text:blue {
|
abstract C_0002617087915615796317 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+~BaseClassifier() = default : void
|
+~BaseClassifier() = default : void
|
||||||
..
|
..
|
||||||
{abstract} +dump_cpt() const = 0 : std::string
|
{abstract} +dump_cpt() const = 0 : std::string
|
||||||
{abstract} +fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) = 0 : BaseClassifier &
|
{abstract} +fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) = 0 : BaseClassifier &
|
||||||
{abstract} +fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) = 0 : BaseClassifier &
|
{abstract} +fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) = 0 : BaseClassifier &
|
||||||
{abstract} +fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const torch::Tensor & weights) = 0 : BaseClassifier &
|
{abstract} +fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const torch::Tensor & weights, const Smoothing_t smoothing) = 0 : BaseClassifier &
|
||||||
{abstract} +fit(std::vector<std::vector<int>> & X, std::vector<int> & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) = 0 : BaseClassifier &
|
{abstract} +fit(std::vector<std::vector<int>> & X, std::vector<int> & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) = 0 : BaseClassifier &
|
||||||
{abstract} +getClassNumStates() const = 0 : int
|
{abstract} +getClassNumStates() const = 0 : int
|
||||||
{abstract} +getNotes() const = 0 : std::vector<std::string>
|
{abstract} +getNotes() const = 0 : std::vector<std::string>
|
||||||
{abstract} +getNumberOfEdges() const = 0 : int
|
{abstract} +getNumberOfEdges() const = 0 : int
|
||||||
@ -109,12 +94,35 @@ abstract C_0000327135989451974539 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
{abstract} +setHyperparameters(const nlohmann::json & hyperparameters) = 0 : void
|
{abstract} +setHyperparameters(const nlohmann::json & hyperparameters) = 0 : void
|
||||||
{abstract} +show() const = 0 : std::vector<std::string>
|
{abstract} +show() const = 0 : std::vector<std::string>
|
||||||
{abstract} +topological_order() = 0 : std::vector<std::string>
|
{abstract} +topological_order() = 0 : std::vector<std::string>
|
||||||
{abstract} #trainModel(const torch::Tensor & weights) = 0 : void
|
{abstract} #trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) = 0 : void
|
||||||
__
|
__
|
||||||
#validHyperparameters : std::vector<std::string>
|
#validHyperparameters : std::vector<std::string>
|
||||||
}
|
}
|
||||||
abstract "bayesnet::Classifier" as C_0002043996622900301644
|
class "bayesnet::Metrics" as C_0005895723015084986588
|
||||||
abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0005895723015084986588 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+Metrics() = default : void
|
||||||
|
+Metrics(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int classNumStates) : void
|
||||||
|
+Metrics(const std::vector<std::vector<int>> & vsamples, const std::vector<int> & labels, const std::vector<std::string> & features, const std::string & className, const int classNumStates) : void
|
||||||
|
..
|
||||||
|
+SelectKBestWeighted(const torch::Tensor & weights, bool ascending = false, unsigned int k = 0) : std::vector<int>
|
||||||
|
+SelectKPairs(const torch::Tensor & weights, std::vector<int> & featuresExcluded, bool ascending = false, unsigned int k = 0) : std::vector<std::pair<int,int>>
|
||||||
|
+conditionalEdge(const torch::Tensor & weights) : torch::Tensor
|
||||||
|
+conditionalEntropy(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & labels, const torch::Tensor & weights) : double
|
||||||
|
+conditionalMutualInformation(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & labels, const torch::Tensor & weights) : double
|
||||||
|
#doCombinations<T>(const std::vector<T> & source) : std::vector<std::pair<T, T> >
|
||||||
|
+entropy(const torch::Tensor & feature, const torch::Tensor & weights) : double
|
||||||
|
+getScoresKBest() const : std::vector<double>
|
||||||
|
+getScoresKPairs() const : std::vector<std::pair<std::pair<int,int>,double>>
|
||||||
|
+maximumSpanningTree(const std::vector<std::string> & features, const torch::Tensor & weights, const int root) : std::vector<std::pair<int,int>>
|
||||||
|
+mutualInformation(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & weights) : double
|
||||||
|
#pop_first<T>(std::vector<T> & v) : T
|
||||||
|
__
|
||||||
|
#className : std::string
|
||||||
|
#features : std::vector<std::string>
|
||||||
|
#samples : torch::Tensor
|
||||||
|
}
|
||||||
|
abstract "bayesnet::Classifier" as C_0016351972983202413152
|
||||||
|
abstract C_0016351972983202413152 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+Classifier(Network model) : void
|
+Classifier(Network model) : void
|
||||||
+~Classifier() = default : void
|
+~Classifier() = default : void
|
||||||
..
|
..
|
||||||
@ -123,10 +131,10 @@ abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
{abstract} #buildModel(const torch::Tensor & weights) = 0 : void
|
{abstract} #buildModel(const torch::Tensor & weights) = 0 : void
|
||||||
#checkFitParameters() : void
|
#checkFitParameters() : void
|
||||||
+dump_cpt() const : std::string
|
+dump_cpt() const : std::string
|
||||||
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : Classifier &
|
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : Classifier &
|
||||||
+fit(std::vector<std::vector<int>> & X, std::vector<int> & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : Classifier &
|
+fit(std::vector<std::vector<int>> & X, std::vector<int> & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : Classifier &
|
||||||
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : Classifier &
|
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : Classifier &
|
||||||
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const torch::Tensor & weights) : Classifier &
|
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const torch::Tensor & weights, const Smoothing_t smoothing) : Classifier &
|
||||||
+getClassNumStates() const : int
|
+getClassNumStates() const : int
|
||||||
+getNotes() const : std::vector<std::string>
|
+getNotes() const : std::vector<std::string>
|
||||||
+getNumberOfEdges() const : int
|
+getNumberOfEdges() const : int
|
||||||
@ -143,7 +151,7 @@ abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
||||||
+show() const : std::vector<std::string>
|
+show() const : std::vector<std::string>
|
||||||
+topological_order() : std::vector<std::string>
|
+topological_order() : std::vector<std::string>
|
||||||
#trainModel(const torch::Tensor & weights) : void
|
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
|
||||||
__
|
__
|
||||||
#className : std::string
|
#className : std::string
|
||||||
#dataset : torch::Tensor
|
#dataset : torch::Tensor
|
||||||
@ -157,8 +165,8 @@ __
|
|||||||
#states : std::map<std::string,std::vector<int>>
|
#states : std::map<std::string,std::vector<int>>
|
||||||
#status : status_t
|
#status : status_t
|
||||||
}
|
}
|
||||||
class "bayesnet::KDB" as C_0001112865019015250005
|
class "bayesnet::KDB" as C_0008902920152122000044
|
||||||
class C_0001112865019015250005 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0008902920152122000044 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+KDB(int k, float theta = 0.03) : void
|
+KDB(int k, float theta = 0.03) : void
|
||||||
+~KDB() = default : void
|
+~KDB() = default : void
|
||||||
..
|
..
|
||||||
@ -167,8 +175,26 @@ class C_0001112865019015250005 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::TAN" as C_0001760994424884323017
|
class "bayesnet::SPODE" as C_0004096182510460307610
|
||||||
class C_0001760994424884323017 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0004096182510460307610 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+SPODE(int root) : void
|
||||||
|
+~SPODE() = default : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+graph(const std::string & name = "SPODE") const : std::vector<std::string>
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::SPnDE" as C_0016268916386101512883
|
||||||
|
class C_0016268916386101512883 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+SPnDE(std::vector<int> parents) : void
|
||||||
|
+~SPnDE() = default : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+graph(const std::string & name = "SPnDE") const : std::vector<std::string>
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::TAN" as C_0014087955399074584137
|
||||||
|
class C_0014087955399074584137 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+TAN() : void
|
+TAN() : void
|
||||||
+~TAN() = default : void
|
+~TAN() = default : void
|
||||||
..
|
..
|
||||||
@ -176,8 +202,8 @@ class C_0001760994424884323017 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+graph(const std::string & name = "TAN") const : std::vector<std::string>
|
+graph(const std::string & name = "TAN") const : std::vector<std::string>
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::Proposal" as C_0002219995589162262979
|
class "bayesnet::Proposal" as C_0017759964713298103839
|
||||||
class C_0002219995589162262979 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0017759964713298103839 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+Proposal(torch::Tensor & pDataset, std::vector<std::string> & features_, std::string & className_) : void
|
+Proposal(torch::Tensor & pDataset, std::vector<std::string> & features_, std::string & className_) : void
|
||||||
+~Proposal() : void
|
+~Proposal() : void
|
||||||
..
|
..
|
||||||
@ -190,74 +216,42 @@ __
|
|||||||
#discretizers : map<std::string,mdlp::CPPFImdlp *>
|
#discretizers : map<std::string,mdlp::CPPFImdlp *>
|
||||||
#y : torch::Tensor
|
#y : torch::Tensor
|
||||||
}
|
}
|
||||||
class "bayesnet::TANLd" as C_0001668829096702037834
|
class "bayesnet::KDBLd" as C_0002756018222998454702
|
||||||
class C_0001668829096702037834 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0002756018222998454702 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+TANLd() : void
|
+KDBLd(int k) : void
|
||||||
+~TANLd() = default : void
|
+~KDBLd() = default : void
|
||||||
..
|
..
|
||||||
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : TANLd &
|
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : KDBLd &
|
||||||
+graph(const std::string & name = "TAN") const : std::vector<std::string>
|
+graph(const std::string & name = "KDB") const : std::vector<std::string>
|
||||||
+predict(torch::Tensor & X) : torch::Tensor
|
+predict(torch::Tensor & X) : torch::Tensor
|
||||||
{static} +version() : std::string
|
{static} +version() : std::string
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
abstract "bayesnet::FeatureSelect" as C_0001695326193250580823
|
class "bayesnet::SPODELd" as C_0010957245114062042836
|
||||||
abstract C_0001695326193250580823 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0010957245114062042836 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+FeatureSelect(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights) : void
|
+SPODELd(int root) : void
|
||||||
+~FeatureSelect() : void
|
+~SPODELd() = default : void
|
||||||
..
|
..
|
||||||
#computeMeritCFS() : double
|
+commonFit(const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : SPODELd &
|
||||||
#computeSuFeatures(const int a, const int b) : double
|
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : SPODELd &
|
||||||
#computeSuLabels() : void
|
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : SPODELd &
|
||||||
{abstract} +fit() = 0 : void
|
+graph(const std::string & name = "SPODELd") const : std::vector<std::string>
|
||||||
+getFeatures() const : std::vector<int>
|
+predict(torch::Tensor & X) : torch::Tensor
|
||||||
+getScores() const : std::vector<double>
|
{static} +version() : std::string
|
||||||
#initialize() : void
|
|
||||||
#symmetricalUncertainty(int a, int b) : double
|
|
||||||
__
|
|
||||||
#fitted : bool
|
|
||||||
#maxFeatures : int
|
|
||||||
#selectedFeatures : std::vector<int>
|
|
||||||
#selectedScores : std::vector<double>
|
|
||||||
#suFeatures : std::map<std::pair<int,int>,double>
|
|
||||||
#suLabels : std::vector<double>
|
|
||||||
#weights : const torch::Tensor &
|
|
||||||
}
|
|
||||||
class "bayesnet::CFS" as C_0000011627355691342494
|
|
||||||
class C_0000011627355691342494 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+CFS(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights) : void
|
|
||||||
+~CFS() : void
|
|
||||||
..
|
|
||||||
+fit() : void
|
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::FCBF" as C_0000144682015341746929
|
class "bayesnet::TANLd" as C_0013350632773616302678
|
||||||
class C_0000144682015341746929 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0013350632773616302678 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+FCBF(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights, const double threshold) : void
|
+TANLd() : void
|
||||||
+~FCBF() : void
|
+~TANLd() = default : void
|
||||||
..
|
..
|
||||||
+fit() : void
|
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : TANLd &
|
||||||
|
+graph(const std::string & name = "TANLd") const : std::vector<std::string>
|
||||||
|
+predict(torch::Tensor & X) : torch::Tensor
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::IWSS" as C_0000008268514674428553
|
class "bayesnet::Ensemble" as C_0015881931090842884611
|
||||||
class C_0000008268514674428553 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0015881931090842884611 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+IWSS(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights, const double threshold) : void
|
|
||||||
+~IWSS() : void
|
|
||||||
..
|
|
||||||
+fit() : void
|
|
||||||
__
|
|
||||||
}
|
|
||||||
class "bayesnet::SPODE" as C_0000512022813807538451
|
|
||||||
class C_0000512022813807538451 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+SPODE(int root) : void
|
|
||||||
+~SPODE() = default : void
|
|
||||||
..
|
|
||||||
#buildModel(const torch::Tensor & weights) : void
|
|
||||||
+graph(const std::string & name = "SPODE") const : std::vector<std::string>
|
|
||||||
__
|
|
||||||
}
|
|
||||||
class "bayesnet::Ensemble" as C_0001985241386355360576
|
|
||||||
class C_0001985241386355360576 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+Ensemble(bool predict_voting = true) : void
|
+Ensemble(bool predict_voting = true) : void
|
||||||
+~Ensemble() = default : void
|
+~Ensemble() = default : void
|
||||||
..
|
..
|
||||||
@ -280,7 +274,7 @@ class C_0001985241386355360576 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+score(torch::Tensor & X, torch::Tensor & y) : float
|
+score(torch::Tensor & X, torch::Tensor & y) : float
|
||||||
+show() const : std::vector<std::string>
|
+show() const : std::vector<std::string>
|
||||||
+topological_order() : std::vector<std::string>
|
+topological_order() : std::vector<std::string>
|
||||||
#trainModel(const torch::Tensor & weights) : void
|
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
|
||||||
#voting(torch::Tensor & votes) : torch::Tensor
|
#voting(torch::Tensor & votes) : torch::Tensor
|
||||||
__
|
__
|
||||||
#models : std::vector<std::unique_ptr<Classifier>>
|
#models : std::vector<std::unique_ptr<Classifier>>
|
||||||
@ -288,41 +282,223 @@ __
|
|||||||
#predict_voting : bool
|
#predict_voting : bool
|
||||||
#significanceModels : std::vector<double>
|
#significanceModels : std::vector<double>
|
||||||
}
|
}
|
||||||
class "bayesnet::(anonymous_45089536)" as C_0001186398587753535158
|
class "bayesnet::A2DE" as C_0001410789567057647859
|
||||||
class C_0001186398587753535158 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0001410789567057647859 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+A2DE(bool predict_voting = false) : void
|
||||||
|
+~A2DE() : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+graph(const std::string & title = "A2DE") const : std::vector<std::string>
|
||||||
|
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::AODE" as C_0006288892608974306258
|
||||||
|
class C_0006288892608974306258 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+AODE(bool predict_voting = false) : void
|
||||||
|
+~AODE() : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+graph(const std::string & title = "AODE") const : std::vector<std::string>
|
||||||
|
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
abstract "bayesnet::FeatureSelect" as C_0013562609546004646591
|
||||||
|
abstract C_0013562609546004646591 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+FeatureSelect(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights) : void
|
||||||
|
+~FeatureSelect() : void
|
||||||
|
..
|
||||||
|
#computeMeritCFS() : double
|
||||||
|
#computeSuFeatures(const int a, const int b) : double
|
||||||
|
#computeSuLabels() : void
|
||||||
|
{abstract} +fit() = 0 : void
|
||||||
|
+getFeatures() const : std::vector<int>
|
||||||
|
+getScores() const : std::vector<double>
|
||||||
|
#initialize() : void
|
||||||
|
#symmetricalUncertainty(int a, int b) : double
|
||||||
|
__
|
||||||
|
#fitted : bool
|
||||||
|
#maxFeatures : int
|
||||||
|
#selectedFeatures : std::vector<int>
|
||||||
|
#selectedScores : std::vector<double>
|
||||||
|
#suFeatures : std::map<std::pair<int,int>,double>
|
||||||
|
#suLabels : std::vector<double>
|
||||||
|
#weights : const torch::Tensor &
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60342586)" as C_0005584545181746538542
|
||||||
|
class C_0005584545181746538542 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
__
|
__
|
||||||
+CFS : std::string
|
+CFS : std::string
|
||||||
+FCBF : std::string
|
+FCBF : std::string
|
||||||
+IWSS : std::string
|
+IWSS : std::string
|
||||||
}
|
}
|
||||||
class "bayesnet::(anonymous_45090163)" as C_0000602764946063116717
|
class "bayesnet::(anonymous_60343240)" as C_0016227156982041949444
|
||||||
class C_0000602764946063116717 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0016227156982041949444 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
__
|
__
|
||||||
+ASC : std::string
|
+ASC : std::string
|
||||||
+DESC : std::string
|
+DESC : std::string
|
||||||
+RAND : std::string
|
+RAND : std::string
|
||||||
}
|
}
|
||||||
class "bayesnet::BoostAODE" as C_0000358471592399852382
|
class "bayesnet::Boost" as C_0009819322948617116148
|
||||||
class C_0000358471592399852382 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0009819322948617116148 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+Boost(bool predict_voting = false) : void
|
||||||
|
+~Boost() = default : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
#featureSelection(torch::Tensor & weights_) : std::vector<int>
|
||||||
|
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
||||||
|
#update_weights(torch::Tensor & ytrain, torch::Tensor & ypred, torch::Tensor & weights) : std::tuple<torch::Tensor &,double,bool>
|
||||||
|
#update_weights_block(int k, torch::Tensor & ytrain, torch::Tensor & weights) : std::tuple<torch::Tensor &,double,bool>
|
||||||
|
__
|
||||||
|
#X_test : torch::Tensor
|
||||||
|
#X_train : torch::Tensor
|
||||||
|
#bisection : bool
|
||||||
|
#block_update : bool
|
||||||
|
#convergence : bool
|
||||||
|
#convergence_best : bool
|
||||||
|
#featureSelector : FeatureSelect *
|
||||||
|
#maxTolerance : int
|
||||||
|
#order_algorithm : std::string
|
||||||
|
#selectFeatures : bool
|
||||||
|
#select_features_algorithm : std::string
|
||||||
|
#threshold : double
|
||||||
|
#y_test : torch::Tensor
|
||||||
|
#y_train : torch::Tensor
|
||||||
|
}
|
||||||
|
class "bayesnet::AODELd" as C_0003898187834670349177
|
||||||
|
class C_0003898187834670349177 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+AODELd(bool predict_voting = true) : void
|
||||||
|
+~AODELd() = default : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+fit(torch::Tensor & X_, torch::Tensor & y_, const std::vector<std::string> & features_, const std::string & className_, std::map<std::string,std::vector<int>> & states_, const Smoothing_t smoothing) : AODELd &
|
||||||
|
+graph(const std::string & name = "AODELd") const : std::vector<std::string>
|
||||||
|
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60275628)" as C_0009086919615463763584
|
||||||
|
class C_0009086919615463763584 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+CFS : std::string
|
||||||
|
+FCBF : std::string
|
||||||
|
+IWSS : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60276282)" as C_0015251985607563196159
|
||||||
|
class C_0015251985607563196159 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+ASC : std::string
|
||||||
|
+DESC : std::string
|
||||||
|
+RAND : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::BoostA2DE" as C_0000272055465257861326
|
||||||
|
class C_0000272055465257861326 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+BoostA2DE(bool predict_voting = false) : void
|
||||||
|
+~BoostA2DE() = default : void
|
||||||
|
..
|
||||||
|
+graph(const std::string & title = "BoostA2DE") const : std::vector<std::string>
|
||||||
|
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60275502)" as C_0016033655851510053155
|
||||||
|
class C_0016033655851510053155 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+CFS : std::string
|
||||||
|
+FCBF : std::string
|
||||||
|
+IWSS : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60276156)" as C_0000379522761622473555
|
||||||
|
class C_0000379522761622473555 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+ASC : std::string
|
||||||
|
+DESC : std::string
|
||||||
|
+RAND : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::BoostAODE" as C_0002867772739198819061
|
||||||
|
class C_0002867772739198819061 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+BoostAODE(bool predict_voting = false) : void
|
+BoostAODE(bool predict_voting = false) : void
|
||||||
+~BoostAODE() = default : void
|
+~BoostAODE() = default : void
|
||||||
..
|
..
|
||||||
#buildModel(const torch::Tensor & weights) : void
|
|
||||||
+graph(const std::string & title = "BoostAODE") const : std::vector<std::string>
|
+graph(const std::string & title = "BoostAODE") const : std::vector<std::string>
|
||||||
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
|
||||||
#trainModel(const torch::Tensor & weights) : void
|
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::MST" as C_0000131858426172291700
|
class "bayesnet::CFS" as C_0000093018845530739957
|
||||||
class C_0000131858426172291700 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0000093018845530739957 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+CFS(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights) : void
|
||||||
|
+~CFS() : void
|
||||||
|
..
|
||||||
|
+fit() : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::FCBF" as C_0001157456122733975432
|
||||||
|
class C_0001157456122733975432 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+FCBF(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights, const double threshold) : void
|
||||||
|
+~FCBF() : void
|
||||||
|
..
|
||||||
|
+fit() : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::IWSS" as C_0000066148117395428429
|
||||||
|
class C_0000066148117395428429 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+IWSS(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights, const double threshold) : void
|
||||||
|
+~IWSS() : void
|
||||||
|
..
|
||||||
|
+fit() : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60730495)" as C_0004857727320042830573
|
||||||
|
class C_0004857727320042830573 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+CFS : std::string
|
||||||
|
+FCBF : std::string
|
||||||
|
+IWSS : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60731150)" as C_0000076541533312623385
|
||||||
|
class C_0000076541533312623385 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+ASC : std::string
|
||||||
|
+DESC : std::string
|
||||||
|
+RAND : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60653004)" as C_0001444063444142949758
|
||||||
|
class C_0001444063444142949758 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+CFS : std::string
|
||||||
|
+FCBF : std::string
|
||||||
|
+IWSS : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60653658)" as C_0007139277546931322856
|
||||||
|
class C_0007139277546931322856 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+ASC : std::string
|
||||||
|
+DESC : std::string
|
||||||
|
+RAND : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60731375)" as C_0010493853592456211189
|
||||||
|
class C_0010493853592456211189 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+CFS : std::string
|
||||||
|
+FCBF : std::string
|
||||||
|
+IWSS : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_60732030)" as C_0007011438637915849564
|
||||||
|
class C_0007011438637915849564 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
__
|
||||||
|
+ASC : std::string
|
||||||
|
+DESC : std::string
|
||||||
|
+RAND : std::string
|
||||||
|
}
|
||||||
|
class "bayesnet::MST" as C_0001054867409378333602
|
||||||
|
class C_0001054867409378333602 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+MST() = default : void
|
+MST() = default : void
|
||||||
+MST(const std::vector<std::string> & features, const torch::Tensor & weights, const int root) : void
|
+MST(const std::vector<std::string> & features, const torch::Tensor & weights, const int root) : void
|
||||||
..
|
..
|
||||||
|
+insertElement(std::list<int> & variables, int variable) : void
|
||||||
+maximumSpanningTree() : std::vector<std::pair<int,int>>
|
+maximumSpanningTree() : std::vector<std::pair<int,int>>
|
||||||
|
+reorder(std::vector<std::pair<float,std::pair<int,int>>> T, int root_original) : std::vector<std::pair<int,int>>
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::Graph" as C_0001197041682001898467
|
class "bayesnet::Graph" as C_0009576333456015187741
|
||||||
class C_0001197041682001898467 #aliceblue;line:blue;line.dotted;text:blue {
|
class C_0009576333456015187741 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
+Graph(int V) : void
|
+Graph(int V) : void
|
||||||
..
|
..
|
||||||
+addEdge(int u, int v, float wt) : void
|
+addEdge(int u, int v, float wt) : void
|
||||||
@ -332,81 +508,73 @@ class C_0001197041682001898467 #aliceblue;line:blue;line.dotted;text:blue {
|
|||||||
+union_set(int u, int v) : void
|
+union_set(int u, int v) : void
|
||||||
__
|
__
|
||||||
}
|
}
|
||||||
class "bayesnet::KDBLd" as C_0000344502277874806837
|
C_0010428199432536647474 --> C_0010428199432536647474 : -parents
|
||||||
class C_0000344502277874806837 #aliceblue;line:blue;line.dotted;text:blue {
|
C_0010428199432536647474 --> C_0010428199432536647474 : -children
|
||||||
+KDBLd(int k) : void
|
C_0009493661199123436603 ..> C_0013393078277439680282
|
||||||
+~KDBLd() = default : void
|
C_0009493661199123436603 o-- C_0010428199432536647474 : -nodes
|
||||||
..
|
C_0002617087915615796317 ..> C_0013393078277439680282
|
||||||
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : KDBLd &
|
C_0002617087915615796317 ..> C_0005907365846270811004
|
||||||
+graph(const std::string & name = "KDB") const : std::vector<std::string>
|
C_0016351972983202413152 ..> C_0013393078277439680282
|
||||||
+predict(torch::Tensor & X) : torch::Tensor
|
C_0016351972983202413152 o-- C_0009493661199123436603 : #model
|
||||||
{static} +version() : std::string
|
C_0016351972983202413152 o-- C_0005895723015084986588 : #metrics
|
||||||
__
|
C_0016351972983202413152 o-- C_0005907365846270811004 : #status
|
||||||
}
|
C_0002617087915615796317 <|-- C_0016351972983202413152
|
||||||
class "bayesnet::AODE" as C_0000786111576121788282
|
|
||||||
class C_0000786111576121788282 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+AODE(bool predict_voting = false) : void
|
|
||||||
+~AODE() : void
|
|
||||||
..
|
|
||||||
#buildModel(const torch::Tensor & weights) : void
|
|
||||||
+graph(const std::string & title = "AODE") const : std::vector<std::string>
|
|
||||||
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
|
||||||
__
|
|
||||||
}
|
|
||||||
class "bayesnet::SPODELd" as C_0001369655639257755354
|
|
||||||
class C_0001369655639257755354 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+SPODELd(int root) : void
|
|
||||||
+~SPODELd() = default : void
|
|
||||||
..
|
|
||||||
+commonFit(const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : SPODELd &
|
|
||||||
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : SPODELd &
|
|
||||||
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : SPODELd &
|
|
||||||
+graph(const std::string & name = "SPODE") const : std::vector<std::string>
|
|
||||||
+predict(torch::Tensor & X) : torch::Tensor
|
|
||||||
{static} +version() : std::string
|
|
||||||
__
|
|
||||||
}
|
|
||||||
class "bayesnet::AODELd" as C_0000487273479333793647
|
|
||||||
class C_0000487273479333793647 #aliceblue;line:blue;line.dotted;text:blue {
|
|
||||||
+AODELd(bool predict_voting = true) : void
|
|
||||||
+~AODELd() = default : void
|
|
||||||
..
|
|
||||||
#buildModel(const torch::Tensor & weights) : void
|
|
||||||
+fit(torch::Tensor & X_, torch::Tensor & y_, const std::vector<std::string> & features_, const std::string & className_, std::map<std::string,std::vector<int>> & states_) : AODELd &
|
|
||||||
+graph(const std::string & name = "AODELd") const : std::vector<std::string>
|
|
||||||
#trainModel(const torch::Tensor & weights) : void
|
|
||||||
__
|
|
||||||
}
|
|
||||||
C_0001303524929067080934 --> C_0001303524929067080934 : -parents
|
|
||||||
C_0001303524929067080934 --> C_0001303524929067080934 : -children
|
|
||||||
C_0001186707649890429575 o-- C_0001303524929067080934 : -nodes
|
|
||||||
C_0000327135989451974539 ..> C_0000738420730783851375
|
|
||||||
C_0002043996622900301644 o-- C_0001186707649890429575 : #model
|
|
||||||
C_0002043996622900301644 o-- C_0000736965376885623323 : #metrics
|
|
||||||
C_0002043996622900301644 o-- C_0000738420730783851375 : #status
|
|
||||||
C_0000327135989451974539 <|-- C_0002043996622900301644
|
|
||||||
C_0002043996622900301644 <|-- C_0001112865019015250005
|
|
||||||
C_0002043996622900301644 <|-- C_0001760994424884323017
|
|
||||||
C_0002219995589162262979 ..> C_0001186707649890429575
|
|
||||||
C_0001760994424884323017 <|-- C_0001668829096702037834
|
|
||||||
C_0002219995589162262979 <|-- C_0001668829096702037834
|
|
||||||
C_0000736965376885623323 <|-- C_0001695326193250580823
|
|
||||||
C_0001695326193250580823 <|-- C_0000011627355691342494
|
|
||||||
C_0001695326193250580823 <|-- C_0000144682015341746929
|
|
||||||
C_0001695326193250580823 <|-- C_0000008268514674428553
|
|
||||||
C_0002043996622900301644 <|-- C_0000512022813807538451
|
|
||||||
C_0001985241386355360576 o-- C_0002043996622900301644 : #models
|
|
||||||
C_0002043996622900301644 <|-- C_0001985241386355360576
|
|
||||||
C_0000358471592399852382 --> C_0001695326193250580823 : -featureSelector
|
|
||||||
C_0001985241386355360576 <|-- C_0000358471592399852382
|
|
||||||
C_0001112865019015250005 <|-- C_0000344502277874806837
|
|
||||||
C_0002219995589162262979 <|-- C_0000344502277874806837
|
|
||||||
C_0001985241386355360576 <|-- C_0000786111576121788282
|
|
||||||
C_0000512022813807538451 <|-- C_0001369655639257755354
|
|
||||||
C_0002219995589162262979 <|-- C_0001369655639257755354
|
|
||||||
C_0001985241386355360576 <|-- C_0000487273479333793647
|
|
||||||
C_0002219995589162262979 <|-- C_0000487273479333793647
|
|
||||||
|
|
||||||
'Generated with clang-uml, version 0.5.1
|
C_0016351972983202413152 <|-- C_0008902920152122000044
|
||||||
'LLVM version clang version 17.0.6 (Fedora 17.0.6-2.fc39)
|
|
||||||
|
C_0016351972983202413152 <|-- C_0004096182510460307610
|
||||||
|
|
||||||
|
C_0016351972983202413152 <|-- C_0016268916386101512883
|
||||||
|
|
||||||
|
C_0016351972983202413152 <|-- C_0014087955399074584137
|
||||||
|
|
||||||
|
C_0017759964713298103839 ..> C_0009493661199123436603
|
||||||
|
C_0002756018222998454702 ..> C_0013393078277439680282
|
||||||
|
C_0008902920152122000044 <|-- C_0002756018222998454702
|
||||||
|
|
||||||
|
C_0017759964713298103839 <|-- C_0002756018222998454702
|
||||||
|
|
||||||
|
C_0010957245114062042836 ..> C_0013393078277439680282
|
||||||
|
C_0004096182510460307610 <|-- C_0010957245114062042836
|
||||||
|
|
||||||
|
C_0017759964713298103839 <|-- C_0010957245114062042836
|
||||||
|
|
||||||
|
C_0013350632773616302678 ..> C_0013393078277439680282
|
||||||
|
C_0014087955399074584137 <|-- C_0013350632773616302678
|
||||||
|
|
||||||
|
C_0017759964713298103839 <|-- C_0013350632773616302678
|
||||||
|
|
||||||
|
C_0015881931090842884611 ..> C_0013393078277439680282
|
||||||
|
C_0015881931090842884611 o-- C_0016351972983202413152 : #models
|
||||||
|
C_0016351972983202413152 <|-- C_0015881931090842884611
|
||||||
|
|
||||||
|
C_0015881931090842884611 <|-- C_0001410789567057647859
|
||||||
|
|
||||||
|
C_0015881931090842884611 <|-- C_0006288892608974306258
|
||||||
|
|
||||||
|
C_0005895723015084986588 <|-- C_0013562609546004646591
|
||||||
|
|
||||||
|
C_0009819322948617116148 --> C_0013562609546004646591 : #featureSelector
|
||||||
|
C_0015881931090842884611 <|-- C_0009819322948617116148
|
||||||
|
|
||||||
|
C_0003898187834670349177 ..> C_0013393078277439680282
|
||||||
|
C_0015881931090842884611 <|-- C_0003898187834670349177
|
||||||
|
|
||||||
|
C_0017759964713298103839 <|-- C_0003898187834670349177
|
||||||
|
|
||||||
|
C_0000272055465257861326 ..> C_0013393078277439680282
|
||||||
|
C_0009819322948617116148 <|-- C_0000272055465257861326
|
||||||
|
|
||||||
|
C_0002867772739198819061 ..> C_0013393078277439680282
|
||||||
|
C_0009819322948617116148 <|-- C_0002867772739198819061
|
||||||
|
|
||||||
|
C_0013562609546004646591 <|-- C_0000093018845530739957
|
||||||
|
|
||||||
|
C_0013562609546004646591 <|-- C_0001157456122733975432
|
||||||
|
|
||||||
|
C_0013562609546004646591 <|-- C_0000066148117395428429
|
||||||
|
|
||||||
|
|
||||||
|
'Generated with clang-uml, version 0.5.5
|
||||||
|
'LLVM version clang version 18.1.8 (Fedora 18.1.8-5.fc41)
|
||||||
@enduml
|
@enduml
|
||||||
|
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 196 KiB |
@ -1,128 +1,314 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
<!-- Generated by graphviz version 8.1.0 (20230707.0739)
|
<!-- Generated by graphviz version 12.1.0 (20240811.2233)
|
||||||
-->
|
-->
|
||||||
<!-- Title: BayesNet Pages: 1 -->
|
<!-- Title: BayesNet Pages: 1 -->
|
||||||
<svg width="1632pt" height="288pt"
|
<svg width="3725pt" height="432pt"
|
||||||
viewBox="0.00 0.00 1631.95 287.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
viewBox="0.00 0.00 3724.84 431.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 283.8)">
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 427.8)">
|
||||||
<title>BayesNet</title>
|
<title>BayesNet</title>
|
||||||
<polygon fill="white" stroke="none" points="-4,4 -4,-283.8 1627.95,-283.8 1627.95,4 -4,4"/>
|
<polygon fill="white" stroke="none" points="-4,4 -4,-427.8 3720.84,-427.8 3720.84,4 -4,4"/>
|
||||||
<!-- node1 -->
|
<!-- node0 -->
|
||||||
<g id="node1" class="node">
|
<g id="node1" class="node">
|
||||||
|
<title>node0</title>
|
||||||
|
<polygon fill="none" stroke="black" points="1655.43,-398.35 1655.43,-413.26 1625.69,-423.8 1583.63,-423.8 1553.89,-413.26 1553.89,-398.35 1583.63,-387.8 1625.69,-387.8 1655.43,-398.35"/>
|
||||||
|
<text text-anchor="middle" x="1604.66" y="-401.53" font-family="Times,serif" font-size="12.00">BayesNet</text>
|
||||||
|
</g>
|
||||||
|
<!-- node1 -->
|
||||||
|
<g id="node2" class="node">
|
||||||
<title>node1</title>
|
<title>node1</title>
|
||||||
<polygon fill="none" stroke="black" points="826.43,-254.35 826.43,-269.26 796.69,-279.8 754.63,-279.8 724.89,-269.26 724.89,-254.35 754.63,-243.8 796.69,-243.8 826.43,-254.35"/>
|
<polygon fill="none" stroke="black" points="413.32,-257.8 372.39,-273.03 206.66,-279.8 40.93,-273.03 0,-257.8 114.69,-245.59 298.64,-245.59 413.32,-257.8"/>
|
||||||
<text text-anchor="middle" x="775.66" y="-257.53" font-family="Times,serif" font-size="12.00">BayesNet</text>
|
<text text-anchor="middle" x="206.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libc10.so</text>
|
||||||
|
</g>
|
||||||
|
<!-- node0->node1 -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>node0->node1</title>
|
||||||
|
<path fill="none" stroke="black" d="M1553.59,-400.53C1451.65,-391.91 1215.69,-371.61 1017.66,-351.8 773.36,-327.37 488.07,-295.22 329.31,-277.01"/>
|
||||||
|
<polygon fill="black" stroke="black" points="329.93,-273.56 319.6,-275.89 329.14,-280.51 329.93,-273.56"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- node2 -->
|
<!-- node2 -->
|
||||||
<g id="node2" class="node">
|
<g id="node3" class="node">
|
||||||
<title>node2</title>
|
<title>node2</title>
|
||||||
<polygon fill="none" stroke="black" points="413.32,-185.8 372.39,-201.03 206.66,-207.8 40.93,-201.03 0,-185.8 114.69,-173.59 298.64,-173.59 413.32,-185.8"/>
|
<polygon fill="none" stroke="black" points="894.21,-257.8 848.35,-273.03 662.66,-279.8 476.98,-273.03 431.12,-257.8 559.61,-245.59 765.71,-245.59 894.21,-257.8"/>
|
||||||
<text text-anchor="middle" x="206.66" y="-185.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libc10.so</text>
|
<text text-anchor="middle" x="662.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libc10_cuda.so</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- node1->node2 -->
|
<!-- node0->node2 -->
|
||||||
<g id="edge1" class="edge">
|
<g id="edge2" class="edge">
|
||||||
<title>node1->node2</title>
|
<title>node0->node2</title>
|
||||||
<path fill="none" stroke="black" d="M724.41,-254.5C634.7,-243.46 447.04,-220.38 324.01,-205.24"/>
|
<path fill="none" stroke="black" d="M1555.34,-397.37C1408.12,-375.18 969.52,-309.06 767.13,-278.55"/>
|
||||||
<polygon fill="black" stroke="black" points="324.77,-201.69 314.42,-203.94 323.92,-208.63 324.77,-201.69"/>
|
<polygon fill="black" stroke="black" points="767.81,-275.12 757.4,-277.09 766.77,-282.04 767.81,-275.12"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- node3 -->
|
<!-- node3 -->
|
||||||
<g id="node3" class="node">
|
<g id="node4" class="node">
|
||||||
<title>node3</title>
|
<title>node3</title>
|
||||||
<polygon fill="none" stroke="black" points="857.68,-185.8 815.49,-201.03 644.66,-207.8 473.84,-201.03 431.65,-185.8 549.86,-173.59 739.46,-173.59 857.68,-185.8"/>
|
<polygon fill="none" stroke="black" points="1338.68,-257.8 1296.49,-273.03 1125.66,-279.8 954.84,-273.03 912.65,-257.8 1030.86,-245.59 1220.46,-245.59 1338.68,-257.8"/>
|
||||||
<text text-anchor="middle" x="644.66" y="-185.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libkineto.a</text>
|
<text text-anchor="middle" x="1125.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libkineto.a</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- node1->node3 -->
|
<!-- node0->node3 -->
|
||||||
<g id="edge2" class="edge">
|
<g id="edge3" class="edge">
|
||||||
<title>node1->node3</title>
|
<title>node0->node3</title>
|
||||||
<path fill="none" stroke="black" d="M747.56,-245.79C729.21,-235.98 704.97,-223.03 684.63,-212.16"/>
|
<path fill="none" stroke="black" d="M1566.68,-393.54C1484.46,-369.17 1289.3,-311.32 1188.44,-281.41"/>
|
||||||
<polygon fill="black" stroke="black" points="686.47,-208.64 676,-207.02 683.17,-214.82 686.47,-208.64"/>
|
<polygon fill="black" stroke="black" points="1189.53,-278.09 1178.95,-278.6 1187.54,-284.8 1189.53,-278.09"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- node4 -->
|
<!-- node4 -->
|
||||||
<g id="node4" class="node">
|
|
||||||
<title>node4</title>
|
|
||||||
<polygon fill="none" stroke="black" points="939.33,-182.35 939.33,-197.26 920.78,-207.8 894.54,-207.8 875.99,-197.26 875.99,-182.35 894.54,-171.8 920.78,-171.8 939.33,-182.35"/>
|
|
||||||
<text text-anchor="middle" x="907.66" y="-185.53" font-family="Times,serif" font-size="12.00">mdlp</text>
|
|
||||||
</g>
|
|
||||||
<!-- node1->node4 -->
|
|
||||||
<g id="edge3" class="edge">
|
|
||||||
<title>node1->node4</title>
|
|
||||||
<path fill="none" stroke="black" d="M803.66,-245.96C824.66,-234.82 853.45,-219.56 875.41,-207.91"/>
|
|
||||||
<polygon fill="black" stroke="black" points="876.78,-210.61 883.97,-202.84 873.5,-204.43 876.78,-210.61"/>
|
|
||||||
</g>
|
|
||||||
<!-- node9 -->
|
|
||||||
<g id="node5" class="node">
|
<g id="node5" class="node">
|
||||||
<title>node9</title>
|
<title>node4</title>
|
||||||
<polygon fill="none" stroke="black" points="1107.74,-195.37 1032.66,-207.8 957.58,-195.37 986.26,-175.24 1079.06,-175.24 1107.74,-195.37"/>
|
<polygon fill="none" stroke="black" points="1552.26,-257.8 1532.93,-273.03 1454.66,-279.8 1376.4,-273.03 1357.07,-257.8 1411.23,-245.59 1498.1,-245.59 1552.26,-257.8"/>
|
||||||
<text text-anchor="middle" x="1032.66" y="-185.53" font-family="Times,serif" font-size="12.00">torch_library</text>
|
<text text-anchor="middle" x="1454.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/lib64/libcuda.so</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- node1->node9 -->
|
<!-- node0->node4 -->
|
||||||
<g id="edge4" class="edge">
|
<g id="edge4" class="edge">
|
||||||
<title>node1->node9</title>
|
<title>node0->node4</title>
|
||||||
<path fill="none" stroke="black" d="M815.25,-250.02C860.25,-237.77 933.77,-217.74 982.68,-204.42"/>
|
<path fill="none" stroke="black" d="M1586.27,-387.39C1559.5,-362.05 1509.72,-314.92 1479.65,-286.46"/>
|
||||||
<polygon fill="black" stroke="black" points="983.3,-207.61 992.02,-201.6 981.46,-200.85 983.3,-207.61"/>
|
<polygon fill="black" stroke="black" points="1482.13,-283.99 1472.46,-279.65 1477.31,-289.07 1482.13,-283.99"/>
|
||||||
</g>
|
|
||||||
<!-- node10 -->
|
|
||||||
<g id="node6" class="node">
|
|
||||||
<title>node10</title>
|
|
||||||
<polygon fill="none" stroke="black" points="1159.81,-113.8 1086.89,-129.03 791.66,-135.8 496.43,-129.03 423.52,-113.8 627.82,-101.59 955.5,-101.59 1159.81,-113.8"/>
|
|
||||||
<text text-anchor="middle" x="791.66" y="-113.53" font-family="Times,serif" font-size="12.00">-Wl,--no-as-needed,"/home/rmontanana/Code/libtorch/lib/libtorch.so" -Wl,--as-needed</text>
|
|
||||||
</g>
|
|
||||||
<!-- node9->node10 -->
|
|
||||||
<g id="edge5" class="edge">
|
|
||||||
<title>node9->node10</title>
|
|
||||||
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M985.62,-175.14C949.2,-164.56 898.31,-149.78 857.79,-138.01"/>
|
|
||||||
<polygon fill="black" stroke="black" points="859.04,-134.44 848.46,-135.01 857.09,-141.16 859.04,-134.44"/>
|
|
||||||
</g>
|
</g>
|
||||||
<!-- node5 -->
|
<!-- node5 -->
|
||||||
<g id="node7" class="node">
|
<g id="node6" class="node">
|
||||||
<title>node5</title>
|
<title>node5</title>
|
||||||
<polygon fill="none" stroke="black" points="1371.56,-123.37 1274.66,-135.8 1177.77,-123.37 1214.78,-103.24 1334.55,-103.24 1371.56,-123.37"/>
|
<polygon fill="none" stroke="black" points="1873.26,-257.8 1843.23,-273.03 1721.66,-279.8 1600.09,-273.03 1570.06,-257.8 1654.19,-245.59 1789.13,-245.59 1873.26,-257.8"/>
|
||||||
<text text-anchor="middle" x="1274.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch_cpu_library</text>
|
<text text-anchor="middle" x="1721.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libcudart.so</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- node9->node5 -->
|
<!-- node0->node5 -->
|
||||||
<g id="edge6" class="edge">
|
<g id="edge5" class="edge">
|
||||||
<title>node9->node5</title>
|
<title>node0->node5</title>
|
||||||
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M1079.61,-175.22C1120.66,-163.35 1180.2,-146.13 1222.68,-133.84"/>
|
<path fill="none" stroke="black" d="M1619.76,-387.77C1628.83,-377.46 1640.53,-363.98 1650.66,-351.8 1668.32,-330.59 1687.84,-306.03 1701.94,-288.1"/>
|
||||||
<polygon fill="black" stroke="black" points="1223.46,-136.97 1232.09,-130.83 1221.51,-130.24 1223.46,-136.97"/>
|
<polygon fill="black" stroke="black" points="1704.43,-290.59 1707.84,-280.56 1698.92,-286.27 1704.43,-290.59"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- node6 -->
|
<!-- node6 -->
|
||||||
<g id="node8" class="node">
|
<g id="node7" class="node">
|
||||||
<title>node6</title>
|
<title>node6</title>
|
||||||
<polygon fill="none" stroke="black" points="1191.4,-27.9 1114.6,-43.12 803.66,-49.9 492.72,-43.12 415.93,-27.9 631.1,-15.68 976.22,-15.68 1191.4,-27.9"/>
|
<polygon fill="none" stroke="black" points="2231.79,-257.8 2198.1,-273.03 2061.66,-279.8 1925.23,-273.03 1891.53,-257.8 1985.95,-245.59 2137.38,-245.59 2231.79,-257.8"/>
|
||||||
<text text-anchor="middle" x="803.66" y="-27.63" font-family="Times,serif" font-size="12.00">-Wl,--no-as-needed,"/home/rmontanana/Code/libtorch/lib/libtorch_cpu.so" -Wl,--as-needed</text>
|
<text text-anchor="middle" x="2061.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libnvToolsExt.so</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- node5->node6 -->
|
<!-- node0->node6 -->
|
||||||
<g id="edge7" class="edge">
|
<g id="edge6" class="edge">
|
||||||
<title>node5->node6</title>
|
<title>node0->node6</title>
|
||||||
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M1210.16,-105.31C1130.55,-91.13 994.37,-66.87 901.77,-50.38"/>
|
<path fill="none" stroke="black" d="M1642.06,-393.18C1721.31,-368.56 1906.71,-310.95 2002.32,-281.24"/>
|
||||||
<polygon fill="black" stroke="black" points="902.44,-46.77 891.98,-48.46 901.22,-53.66 902.44,-46.77"/>
|
<polygon fill="black" stroke="black" points="2003.28,-284.61 2011.79,-278.3 2001.21,-277.92 2003.28,-284.61"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- node7 -->
|
<!-- node7 -->
|
||||||
<g id="node9" class="node">
|
<g id="node8" class="node">
|
||||||
<title>node7</title>
|
<title>node7</title>
|
||||||
<polygon fill="none" stroke="black" points="1339.72,-37.46 1274.66,-49.9 1209.61,-37.46 1234.46,-17.34 1314.87,-17.34 1339.72,-37.46"/>
|
<polygon fill="none" stroke="black" points="2541.44,-257.8 2512.56,-273.03 2395.66,-279.8 2278.76,-273.03 2249.89,-257.8 2330.79,-245.59 2460.54,-245.59 2541.44,-257.8"/>
|
||||||
<text text-anchor="middle" x="1274.66" y="-27.63" font-family="Times,serif" font-size="12.00">caffe2::mkl</text>
|
<text text-anchor="middle" x="2395.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libnvrtc.so</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- node5->node7 -->
|
<!-- node0->node7 -->
|
||||||
<g id="edge8" class="edge">
|
<g id="edge7" class="edge">
|
||||||
<title>node5->node7</title>
|
<title>node0->node7</title>
|
||||||
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M1274.66,-102.95C1274.66,-91.56 1274.66,-75.07 1274.66,-60.95"/>
|
<path fill="none" stroke="black" d="M1651.19,-396.45C1780.36,-373.26 2144.76,-307.85 2311.05,-277.99"/>
|
||||||
<polygon fill="black" stroke="black" points="1278.16,-61.27 1274.66,-51.27 1271.16,-61.27 1278.16,-61.27"/>
|
<polygon fill="black" stroke="black" points="2311.47,-281.47 2320.7,-276.26 2310.24,-274.58 2311.47,-281.47"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- node8 -->
|
<!-- node8 -->
|
||||||
<g id="node10" class="node">
|
<g id="node9" class="node">
|
||||||
<title>node8</title>
|
<title>node8</title>
|
||||||
<polygon fill="none" stroke="black" points="1623.95,-41.76 1490.66,-63.8 1357.37,-41.76 1408.28,-6.09 1573.04,-6.09 1623.95,-41.76"/>
|
<polygon fill="none" stroke="black" points="1642.01,-326.35 1642.01,-341.26 1620.13,-351.8 1589.19,-351.8 1567.31,-341.26 1567.31,-326.35 1589.19,-315.8 1620.13,-315.8 1642.01,-326.35"/>
|
||||||
<text text-anchor="middle" x="1490.66" y="-34.75" font-family="Times,serif" font-size="12.00">dummy</text>
|
<text text-anchor="middle" x="1604.66" y="-329.53" font-family="Times,serif" font-size="12.00">fimdlp</text>
|
||||||
<text text-anchor="middle" x="1490.66" y="-20.5" font-family="Times,serif" font-size="12.00">(protobuf::libprotobuf)</text>
|
|
||||||
</g>
|
</g>
|
||||||
<!-- node5->node8 -->
|
<!-- node0->node8 -->
|
||||||
|
<g id="edge8" class="edge">
|
||||||
|
<title>node0->node8</title>
|
||||||
|
<path fill="none" stroke="black" d="M1604.66,-387.5C1604.66,-380.21 1604.66,-371.53 1604.66,-363.34"/>
|
||||||
|
<polygon fill="black" stroke="black" points="1608.16,-363.42 1604.66,-353.42 1601.16,-363.42 1608.16,-363.42"/>
|
||||||
|
</g>
|
||||||
|
<!-- node19 -->
|
||||||
|
<g id="node10" class="node">
|
||||||
|
<title>node19</title>
|
||||||
|
<polygon fill="none" stroke="black" points="2709.74,-267.37 2634.66,-279.8 2559.58,-267.37 2588.26,-247.24 2681.06,-247.24 2709.74,-267.37"/>
|
||||||
|
<text text-anchor="middle" x="2634.66" y="-257.53" font-family="Times,serif" font-size="12.00">torch_library</text>
|
||||||
|
</g>
|
||||||
|
<!-- node0->node19 -->
|
||||||
|
<g id="edge29" class="edge">
|
||||||
|
<title>node0->node19</title>
|
||||||
|
<path fill="none" stroke="black" d="M1655.87,-399.32C1798.23,-383.79 2210.64,-336.94 2550.66,-279.8 2559.43,-278.33 2568.68,-276.62 2577.72,-274.86"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2578.38,-278.3 2587.5,-272.92 2577.01,-271.43 2578.38,-278.3"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node1 -->
|
||||||
<g id="edge9" class="edge">
|
<g id="edge9" class="edge">
|
||||||
<title>node5->node8</title>
|
<title>node8->node1</title>
|
||||||
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M1310.82,-102.76C1341.68,-90.77 1386.88,-73.21 1424.25,-58.7"/>
|
<path fill="none" stroke="black" d="M1566.84,-331.58C1419.81,-326.72 872.06,-307.69 421.66,-279.8 401.07,-278.53 379.38,-277.02 358.03,-275.43"/>
|
||||||
<polygon fill="black" stroke="black" points="1425.01,-61.77 1433.06,-54.89 1422.47,-55.25 1425.01,-61.77"/>
|
<polygon fill="black" stroke="black" points="358.3,-271.94 348.06,-274.67 357.77,-278.92 358.3,-271.94"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node2 -->
|
||||||
|
<g id="edge10" class="edge">
|
||||||
|
<title>node8->node2</title>
|
||||||
|
<path fill="none" stroke="black" d="M1566.86,-330C1445.11,-320.95 1057.97,-292.18 831.67,-275.36"/>
|
||||||
|
<polygon fill="black" stroke="black" points="832.09,-271.89 821.86,-274.63 831.57,-278.87 832.09,-271.89"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node3 -->
|
||||||
|
<g id="edge11" class="edge">
|
||||||
|
<title>node8->node3</title>
|
||||||
|
<path fill="none" stroke="black" d="M1567.08,-327.31C1495.4,-316.84 1336.86,-293.67 1230.62,-278.14"/>
|
||||||
|
<polygon fill="black" stroke="black" points="1231.44,-274.72 1221.04,-276.74 1230.42,-281.65 1231.44,-274.72"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node4 -->
|
||||||
|
<g id="edge12" class="edge">
|
||||||
|
<title>node8->node4</title>
|
||||||
|
<path fill="none" stroke="black" d="M1578.53,-320.61C1555.96,-310.08 1522.92,-294.66 1496.64,-282.4"/>
|
||||||
|
<polygon fill="black" stroke="black" points="1498.12,-279.22 1487.58,-278.17 1495.16,-285.57 1498.12,-279.22"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node5 -->
|
||||||
|
<g id="edge13" class="edge">
|
||||||
|
<title>node8->node5</title>
|
||||||
|
<path fill="none" stroke="black" d="M1627.78,-318.97C1644.15,-309.18 1666.44,-295.84 1685.2,-284.62"/>
|
||||||
|
<polygon fill="black" stroke="black" points="1686.83,-287.73 1693.61,-279.59 1683.23,-281.72 1686.83,-287.73"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node6 -->
|
||||||
|
<g id="edge14" class="edge">
|
||||||
|
<title>node8->node6</title>
|
||||||
|
<path fill="none" stroke="black" d="M1642.45,-327.02C1712.36,-316.31 1863.89,-293.1 1964.32,-277.71"/>
|
||||||
|
<polygon fill="black" stroke="black" points="1964.84,-281.18 1974.2,-276.2 1963.78,-274.26 1964.84,-281.18"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node7 -->
|
||||||
|
<g id="edge15" class="edge">
|
||||||
|
<title>node8->node7</title>
|
||||||
|
<path fill="none" stroke="black" d="M1642.33,-330.01C1740.75,-322.64 2013.75,-301.7 2240.66,-279.8 2254.16,-278.5 2268.32,-277.06 2282.35,-275.58"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2282.49,-279.08 2292.06,-274.54 2281.75,-272.12 2282.49,-279.08"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8->node19 -->
|
||||||
|
<g id="edge16" class="edge">
|
||||||
|
<title>node8->node19</title>
|
||||||
|
<path fill="none" stroke="black" d="M1642.25,-332.63C1770.06,-331.64 2199.48,-324.94 2550.66,-279.8 2560.1,-278.59 2570.07,-276.92 2579.71,-275.1"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2580.21,-278.57 2589.34,-273.21 2578.86,-271.7 2580.21,-278.57"/>
|
||||||
|
</g>
|
||||||
|
<!-- node20 -->
|
||||||
|
<g id="node11" class="node">
|
||||||
|
<title>node20</title>
|
||||||
|
<polygon fill="none" stroke="black" points="2606.81,-185.8 2533.89,-201.03 2238.66,-207.8 1943.43,-201.03 1870.52,-185.8 2074.82,-173.59 2402.5,-173.59 2606.81,-185.8"/>
|
||||||
|
<text text-anchor="middle" x="2238.66" y="-185.53" font-family="Times,serif" font-size="12.00">-Wl,--no-as-needed,"/home/rmontanana/Code/libtorch/lib/libtorch.so" -Wl,--as-needed</text>
|
||||||
|
</g>
|
||||||
|
<!-- node19->node20 -->
|
||||||
|
<g id="edge17" class="edge">
|
||||||
|
<title>node19->node20</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2583.63,-250.21C2572.76,-248.03 2561.34,-245.79 2550.66,-243.8 2482.14,-231.05 2404.92,-217.93 2344.44,-207.93"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2345.28,-204.52 2334.84,-206.34 2344.14,-211.42 2345.28,-204.52"/>
|
||||||
|
</g>
|
||||||
|
<!-- node9 -->
|
||||||
|
<g id="node12" class="node">
|
||||||
|
<title>node9</title>
|
||||||
|
<polygon fill="none" stroke="black" points="2542.56,-123.37 2445.66,-135.8 2348.77,-123.37 2385.78,-103.24 2505.55,-103.24 2542.56,-123.37"/>
|
||||||
|
<text text-anchor="middle" x="2445.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch_cpu_library</text>
|
||||||
|
</g>
|
||||||
|
<!-- node19->node9 -->
|
||||||
|
<g id="edge18" class="edge">
|
||||||
|
<title>node19->node9</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2635.72,-246.84C2636.4,-227.49 2634.61,-192.58 2615.66,-171.8 2601.13,-155.87 2551.93,-141.56 2510.18,-131.84"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2511.2,-128.48 2500.67,-129.68 2509.65,-135.31 2511.2,-128.48"/>
|
||||||
|
</g>
|
||||||
|
<!-- node13 -->
|
||||||
|
<g id="node16" class="node">
|
||||||
|
<title>node13</title>
|
||||||
|
<polygon fill="none" stroke="black" points="3056.45,-195.37 2953.66,-207.8 2850.87,-195.37 2890.13,-175.24 3017.19,-175.24 3056.45,-195.37"/>
|
||||||
|
<text text-anchor="middle" x="2953.66" y="-185.53" font-family="Times,serif" font-size="12.00">torch_cuda_library</text>
|
||||||
|
</g>
|
||||||
|
<!-- node19->node13 -->
|
||||||
|
<g id="edge22" class="edge">
|
||||||
|
<title>node19->node13</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2685.21,-249.71C2741.11,-237.45 2831.21,-217.67 2891.42,-204.46"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2891.8,-207.96 2900.82,-202.4 2890.3,-201.13 2891.8,-207.96"/>
|
||||||
|
</g>
|
||||||
|
<!-- node10 -->
|
||||||
|
<g id="node13" class="node">
|
||||||
|
<title>node10</title>
|
||||||
|
<polygon fill="none" stroke="black" points="2362.4,-27.9 2285.6,-43.12 1974.66,-49.9 1663.72,-43.12 1586.93,-27.9 1802.1,-15.68 2147.22,-15.68 2362.4,-27.9"/>
|
||||||
|
<text text-anchor="middle" x="1974.66" y="-27.63" font-family="Times,serif" font-size="12.00">-Wl,--no-as-needed,"/home/rmontanana/Code/libtorch/lib/libtorch_cpu.so" -Wl,--as-needed</text>
|
||||||
|
</g>
|
||||||
|
<!-- node9->node10 -->
|
||||||
|
<g id="edge19" class="edge">
|
||||||
|
<title>node9->node10</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2381.16,-105.31C2301.63,-91.15 2165.65,-66.92 2073.05,-50.43"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2073.93,-47.03 2063.48,-48.72 2072.71,-53.92 2073.93,-47.03"/>
|
||||||
|
</g>
|
||||||
|
<!-- node11 -->
|
||||||
|
<g id="node14" class="node">
|
||||||
|
<title>node11</title>
|
||||||
|
<polygon fill="none" stroke="black" points="2510.72,-37.46 2445.66,-49.9 2380.61,-37.46 2405.46,-17.34 2485.87,-17.34 2510.72,-37.46"/>
|
||||||
|
<text text-anchor="middle" x="2445.66" y="-27.63" font-family="Times,serif" font-size="12.00">caffe2::mkl</text>
|
||||||
|
</g>
|
||||||
|
<!-- node9->node11 -->
|
||||||
|
<g id="edge20" class="edge">
|
||||||
|
<title>node9->node11</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2445.66,-102.95C2445.66,-91.68 2445.66,-75.4 2445.66,-61.37"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2449.16,-61.78 2445.66,-51.78 2442.16,-61.78 2449.16,-61.78"/>
|
||||||
|
</g>
|
||||||
|
<!-- node12 -->
|
||||||
|
<g id="node15" class="node">
|
||||||
|
<title>node12</title>
|
||||||
|
<polygon fill="none" stroke="black" points="2794.95,-41.76 2661.66,-63.8 2528.37,-41.76 2579.28,-6.09 2744.04,-6.09 2794.95,-41.76"/>
|
||||||
|
<text text-anchor="middle" x="2661.66" y="-34.75" font-family="Times,serif" font-size="12.00">dummy</text>
|
||||||
|
<text text-anchor="middle" x="2661.66" y="-20.5" font-family="Times,serif" font-size="12.00">(protobuf::libprotobuf)</text>
|
||||||
|
</g>
|
||||||
|
<!-- node9->node12 -->
|
||||||
|
<g id="edge21" class="edge">
|
||||||
|
<title>node9->node12</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2481.82,-102.76C2512.55,-90.82 2557.5,-73.36 2594.77,-58.89"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2595.6,-62.32 2603.65,-55.44 2593.06,-55.79 2595.6,-62.32"/>
|
||||||
|
</g>
|
||||||
|
<!-- node13->node9 -->
|
||||||
|
<g id="edge28" class="edge">
|
||||||
|
<title>node13->node9</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2880.59,-179.79C2799.97,-169.71 2666.42,-152.57 2551.66,-135.8 2540.2,-134.13 2528.06,-132.27 2516.24,-130.41"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2516.96,-126.98 2506.54,-128.86 2515.87,-133.89 2516.96,-126.98"/>
|
||||||
|
</g>
|
||||||
|
<!-- node14 -->
|
||||||
|
<g id="node17" class="node">
|
||||||
|
<title>node14</title>
|
||||||
|
<polygon fill="none" stroke="black" points="3346.69,-113.8 3268.85,-129.03 2953.66,-135.8 2638.48,-129.03 2560.63,-113.8 2778.75,-101.59 3128.58,-101.59 3346.69,-113.8"/>
|
||||||
|
<text text-anchor="middle" x="2953.66" y="-113.53" font-family="Times,serif" font-size="12.00">-Wl,--no-as-needed,"/home/rmontanana/Code/libtorch/lib/libtorch_cuda.so" -Wl,--as-needed</text>
|
||||||
|
</g>
|
||||||
|
<!-- node13->node14 -->
|
||||||
|
<g id="edge23" class="edge">
|
||||||
|
<title>node13->node14</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2953.66,-174.97C2953.66,-167.13 2953.66,-157.01 2953.66,-147.53"/>
|
||||||
|
<polygon fill="black" stroke="black" points="2957.16,-147.59 2953.66,-137.59 2950.16,-147.59 2957.16,-147.59"/>
|
||||||
|
</g>
|
||||||
|
<!-- node15 -->
|
||||||
|
<g id="node18" class="node">
|
||||||
|
<title>node15</title>
|
||||||
|
<polygon fill="none" stroke="black" points="3514.74,-123.37 3439.66,-135.8 3364.58,-123.37 3393.26,-103.24 3486.06,-103.24 3514.74,-123.37"/>
|
||||||
|
<text text-anchor="middle" x="3439.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch::cudart</text>
|
||||||
|
</g>
|
||||||
|
<!-- node13->node15 -->
|
||||||
|
<g id="edge24" class="edge">
|
||||||
|
<title>node13->node15</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3028.35,-180.51C3109.24,-171.17 3241.96,-154.78 3355.66,-135.8 3364.43,-134.34 3373.69,-132.63 3382.72,-130.88"/>
|
||||||
|
<polygon fill="black" stroke="black" points="3383.38,-134.31 3392.51,-128.93 3382.02,-127.45 3383.38,-134.31"/>
|
||||||
|
</g>
|
||||||
|
<!-- node17 -->
|
||||||
|
<g id="node20" class="node">
|
||||||
|
<title>node17</title>
|
||||||
|
<polygon fill="none" stroke="black" points="3716.84,-123.37 3624.66,-135.8 3532.48,-123.37 3567.69,-103.24 3681.63,-103.24 3716.84,-123.37"/>
|
||||||
|
<text text-anchor="middle" x="3624.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch::nvtoolsext</text>
|
||||||
|
</g>
|
||||||
|
<!-- node13->node17 -->
|
||||||
|
<g id="edge26" class="edge">
|
||||||
|
<title>node13->node17</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3033.64,-183.25C3144.1,-175.14 3349.47,-158.53 3523.66,-135.8 3534.84,-134.35 3546.67,-132.57 3558.15,-130.72"/>
|
||||||
|
<polygon fill="black" stroke="black" points="3558.68,-134.18 3567.98,-129.1 3557.54,-127.27 3558.68,-134.18"/>
|
||||||
|
</g>
|
||||||
|
<!-- node16 -->
|
||||||
|
<g id="node19" class="node">
|
||||||
|
<title>node16</title>
|
||||||
|
<polygon fill="none" stroke="black" points="3510.78,-27.9 3496.7,-43.12 3439.66,-49.9 3382.63,-43.12 3368.54,-27.9 3408.01,-15.68 3471.31,-15.68 3510.78,-27.9"/>
|
||||||
|
<text text-anchor="middle" x="3439.66" y="-27.63" font-family="Times,serif" font-size="12.00">CUDA::cudart</text>
|
||||||
|
</g>
|
||||||
|
<!-- node15->node16 -->
|
||||||
|
<g id="edge25" class="edge">
|
||||||
|
<title>node15->node16</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3439.66,-102.95C3439.66,-91.68 3439.66,-75.4 3439.66,-61.37"/>
|
||||||
|
<polygon fill="black" stroke="black" points="3443.16,-61.78 3439.66,-51.78 3436.16,-61.78 3443.16,-61.78"/>
|
||||||
|
</g>
|
||||||
|
<!-- node18 -->
|
||||||
|
<g id="node21" class="node">
|
||||||
|
<title>node18</title>
|
||||||
|
<polygon fill="none" stroke="black" points="3714.32,-27.9 3696.56,-43.12 3624.66,-49.9 3552.77,-43.12 3535.01,-27.9 3584.76,-15.68 3664.56,-15.68 3714.32,-27.9"/>
|
||||||
|
<text text-anchor="middle" x="3624.66" y="-27.63" font-family="Times,serif" font-size="12.00">CUDA::nvToolsExt</text>
|
||||||
|
</g>
|
||||||
|
<!-- node17->node18 -->
|
||||||
|
<g id="edge27" class="edge">
|
||||||
|
<title>node17->node18</title>
|
||||||
|
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3624.66,-102.95C3624.66,-91.68 3624.66,-75.4 3624.66,-61.37"/>
|
||||||
|
<polygon fill="black" stroke="black" points="3628.16,-61.78 3624.66,-51.78 3621.16,-61.78 3628.16,-61.78"/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 18 KiB |
@ -27,4 +27,4 @@ The hyperparameters defined in the algorithm are:
|
|||||||
|
|
||||||
## Operation
|
## Operation
|
||||||
|
|
||||||
### [Algorithm](./algorithm.md)
|
### [Base Algorithm](./algorithm.md)
|
||||||
|
2912
docs/Doxyfile.in
Normal file
BIN
docs/logo_small.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
html/amber.png
Before Width: | Height: | Size: 141 B |
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet</a> - BaseClassifier.h<span style="font-size: 80%;"> (<a href="BaseClassifier.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="BaseClassifier.h.func.html"><img src="../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="BaseClassifier.h.gcov.html#L19">bayesnet::BaseClassifier::~BaseClassifier()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1680</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet</a> - BaseClassifier.h<span style="font-size: 80%;"> (<a href="BaseClassifier.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="BaseClassifier.h.func-c.html"><img src="../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="BaseClassifier.h.gcov.html#L19">bayesnet::BaseClassifier::~BaseClassifier()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1680</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="BaseClassifier.h.gcov.overview.html" name="overview">
|
|
||||||
<frame src="BaseClassifier.h.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,129 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet</a> - BaseClassifier.h<span style="font-size: 80%;"> (source / <a href="BaseClassifier.h.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #pragma once</span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : #include <vector></span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : #include <torch/torch.h></span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> : #include <nlohmann/json.hpp></span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> : enum status_t { NORMAL, WARNING, ERROR };</span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : class BaseClassifier {</span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> : // X is nxm std::vector, y is nx1 std::vector</span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> : virtual BaseClassifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;</span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> : // X is nxm tensor, y is nx1 tensor</span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> : virtual BaseClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;</span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> : virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;</span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> : virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) = 0;</span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC tlaBgGNC"> 1680 : virtual ~BaseClassifier() = default;</span></span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> : torch::Tensor virtual predict(torch::Tensor& X) = 0;</span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> : std::vector<int> virtual predict(std::vector<std::vector<int >>& X) = 0;</span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> : torch::Tensor virtual predict_proba(torch::Tensor& X) = 0;</span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> : std::vector<std::vector<double>> virtual predict_proba(std::vector<std::vector<int >>& X) = 0;</span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> : status_t virtual getStatus() const = 0;</span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> : float virtual score(std::vector<std::vector<int>>& X, std::vector<int>& y) = 0;</span>
|
|
||||||
<span id="L28"><span class="lineNum"> 28</span> : float virtual score(torch::Tensor& X, torch::Tensor& y) = 0;</span>
|
|
||||||
<span id="L29"><span class="lineNum"> 29</span> : int virtual getNumberOfNodes()const = 0;</span>
|
|
||||||
<span id="L30"><span class="lineNum"> 30</span> : int virtual getNumberOfEdges()const = 0;</span>
|
|
||||||
<span id="L31"><span class="lineNum"> 31</span> : int virtual getNumberOfStates() const = 0;</span>
|
|
||||||
<span id="L32"><span class="lineNum"> 32</span> : int virtual getClassNumStates() const = 0;</span>
|
|
||||||
<span id="L33"><span class="lineNum"> 33</span> : std::vector<std::string> virtual show() const = 0;</span>
|
|
||||||
<span id="L34"><span class="lineNum"> 34</span> : std::vector<std::string> virtual graph(const std::string& title = "") const = 0;</span>
|
|
||||||
<span id="L35"><span class="lineNum"> 35</span> : virtual std::string getVersion() = 0;</span>
|
|
||||||
<span id="L36"><span class="lineNum"> 36</span> : std::vector<std::string> virtual topological_order() = 0;</span>
|
|
||||||
<span id="L37"><span class="lineNum"> 37</span> : std::vector<std::string> virtual getNotes() const = 0;</span>
|
|
||||||
<span id="L38"><span class="lineNum"> 38</span> : std::string virtual dump_cpt()const = 0;</span>
|
|
||||||
<span id="L39"><span class="lineNum"> 39</span> : virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;</span>
|
|
||||||
<span id="L40"><span class="lineNum"> 40</span> : std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }</span>
|
|
||||||
<span id="L41"><span class="lineNum"> 41</span> : protected:</span>
|
|
||||||
<span id="L42"><span class="lineNum"> 42</span> : virtual void trainModel(const torch::Tensor& weights) = 0;</span>
|
|
||||||
<span id="L43"><span class="lineNum"> 43</span> : std::vector<std::string> validHyperparameters;</span>
|
|
||||||
<span id="L44"><span class="lineNum"> 44</span> : };</span>
|
|
||||||
<span id="L45"><span class="lineNum"> 45</span> : }</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,32 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="BaseClassifier.h.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="BaseClassifier.h.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="BaseClassifier.h.gcov.html#L13" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,28,79,31" href="BaseClassifier.h.gcov.html#L17" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,32,79,35" href="BaseClassifier.h.gcov.html#L21" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,36,79,39" href="BaseClassifier.h.gcov.html#L25" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,40,79,43" href="BaseClassifier.h.gcov.html#L29" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,44,79,47" href="BaseClassifier.h.gcov.html#L33" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="BaseClassifier.h.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="BaseClassifier.h.gcov.png" width=80 height=44 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 372 B |
@ -1,251 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.cc<span style="font-size: 80%;"> (<a href="Classifier.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">126</td>
|
|
||||||
<td class="headerCovTableEntry">126</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">24</td>
|
|
||||||
<td class="headerCovTableEntry">24</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="Classifier.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">bayesnet::Classifier::dump_cpt[abi:cxx11]() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">4</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">bayesnet::Classifier::topological_order[abi:cxx11]()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">4</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">16</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">16</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">bayesnet::Classifier::getNumberOfStates() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">24</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">bayesnet::Classifier::show[abi:cxx11]() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">24</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">bayesnet::Classifier::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">92</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&, at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">112</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&, at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">128</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">136</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">bayesnet::Classifier::getNumberOfEdges() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">332</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">bayesnet::Classifier::getNumberOfNodes() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">332</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">340</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">bayesnet::Classifier::getClassNumStates() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">348</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">bayesnet::Classifier::predict_proba(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">548</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">660</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">852</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">bayesnet::Classifier::predict_proba(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1484</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">bayesnet::Classifier::addNodes()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1576</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">bayesnet::Classifier::trainModel(at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1576</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1760</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">bayesnet::Classifier::checkFitParameters()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1760</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">bayesnet::Classifier::predict(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1844</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">bayesnet::Classifier::Classifier(bayesnet::Network)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">2240</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,251 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.cc<span style="font-size: 80%;"> (<a href="Classifier.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">126</td>
|
|
||||||
<td class="headerCovTableEntry">126</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">24</td>
|
|
||||||
<td class="headerCovTableEntry">24</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="Classifier.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">bayesnet::Classifier::Classifier(bayesnet::Network)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">2240</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">bayesnet::Classifier::addNodes()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1576</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1760</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">340</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">bayesnet::Classifier::checkFitParameters()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1760</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">bayesnet::Classifier::dump_cpt[abi:cxx11]() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">4</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&, at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">128</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">852</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">660</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">136</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">bayesnet::Classifier::getClassNumStates() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">348</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">bayesnet::Classifier::getNumberOfEdges() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">332</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">bayesnet::Classifier::getNumberOfNodes() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">332</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">bayesnet::Classifier::getNumberOfStates() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">24</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">bayesnet::Classifier::predict(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1844</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">16</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">bayesnet::Classifier::predict_proba(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1484</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">bayesnet::Classifier::predict_proba(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">548</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&, at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">112</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">16</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">bayesnet::Classifier::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">92</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">bayesnet::Classifier::show[abi:cxx11]() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">24</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">bayesnet::Classifier::topological_order[abi:cxx11]()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">4</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">bayesnet::Classifier::trainModel(at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1576</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="Classifier.cc.gcov.overview.html" name="overview">
|
|
||||||
<frame src="Classifier.cc.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,278 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.cc<span style="font-size: 80%;"> (source / <a href="Classifier.cc.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">126</td>
|
|
||||||
<td class="headerCovTableEntry">126</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">24</td>
|
|
||||||
<td class="headerCovTableEntry">24</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #include <sstream></span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : #include "bayesnet/utils/bayesnetUtils.h"</span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : #include "Classifier.h"</span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> : </span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC tlaBgGNC"> 2240 : Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}</span></span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : const std::string CLASSIFIER_NOT_FITTED = "Classifier has not been fitted";</span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 1760 : Classifier& Classifier::build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)</span></span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> : {</span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 1760 : this->features = features;</span></span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 1760 : this->className = className;</span></span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 1760 : this->states = states;</span></span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 1760 : m = dataset.size(1);</span></span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 1760 : n = features.size();</span></span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 1760 : checkFitParameters();</span></span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 1728 : auto n_classes = states.at(className).size();</span></span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 1728 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 1728 : model.initialize();</span></span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 1728 : buildModel(weights);</span></span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 1728 : trainModel(weights);</span></span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 1712 : fitted = true;</span></span>
|
|
||||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 1712 : return *this;</span></span>
|
|
||||||
<span id="L29"><span class="lineNum"> 29</span> : }</span>
|
|
||||||
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 340 : void Classifier::buildDataset(torch::Tensor& ytmp)</span></span>
|
|
||||||
<span id="L31"><span class="lineNum"> 31</span> : {</span>
|
|
||||||
<span id="L32"><span class="lineNum"> 32</span> : try {</span>
|
|
||||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 340 : auto yresized = torch::transpose(ytmp.view({ ytmp.size(0), 1 }), 0, 1);</span></span>
|
|
||||||
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 1052 : dataset = torch::cat({ dataset, yresized }, 0);</span></span>
|
|
||||||
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 340 : }</span></span>
|
|
||||||
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 16 : catch (const std::exception& e) {</span></span>
|
|
||||||
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 16 : std::stringstream oss;</span></span>
|
|
||||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 16 : oss << "* Error in X and y dimensions *\n";</span></span>
|
|
||||||
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 16 : oss << "X dimensions: " << dataset.sizes() << "\n";</span></span>
|
|
||||||
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 16 : oss << "y dimensions: " << ytmp.sizes();</span></span>
|
|
||||||
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 16 : throw std::runtime_error(oss.str());</span></span>
|
|
||||||
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 32 : }</span></span>
|
|
||||||
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 680 : }</span></span>
|
|
||||||
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 1576 : void Classifier::trainModel(const torch::Tensor& weights)</span></span>
|
|
||||||
<span id="L45"><span class="lineNum"> 45</span> : {</span>
|
|
||||||
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 1576 : model.fit(dataset, weights, features, className, states);</span></span>
|
|
||||||
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 1576 : }</span></span>
|
|
||||||
<span id="L48"><span class="lineNum"> 48</span> : // X is nxm where n is the number of features and m the number of samples</span>
|
|
||||||
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 128 : Classifier& Classifier::fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)</span></span>
|
|
||||||
<span id="L50"><span class="lineNum"> 50</span> : {</span>
|
|
||||||
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 128 : dataset = X;</span></span>
|
|
||||||
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 128 : buildDataset(y);</span></span>
|
|
||||||
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 120 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
|
|
||||||
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 208 : return build(features, className, states, weights);</span></span>
|
|
||||||
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 120 : }</span></span>
|
|
||||||
<span id="L56"><span class="lineNum"> 56</span> : // X is nxm where n is the number of features and m the number of samples</span>
|
|
||||||
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 136 : Classifier& Classifier::fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)</span></span>
|
|
||||||
<span id="L58"><span class="lineNum"> 58</span> : {</span>
|
|
||||||
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 136 : dataset = torch::zeros({ static_cast<int>(X.size()), static_cast<int>(X[0].size()) }, torch::kInt32);</span></span>
|
|
||||||
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 976 : for (int i = 0; i < X.size(); ++i) {</span></span>
|
|
||||||
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 3360 : dataset.index_put_({ i, "..." }, torch::tensor(X[i], torch::kInt32));</span></span>
|
|
||||||
<span id="L62"><span class="lineNum"> 62</span> : }</span>
|
|
||||||
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 136 : auto ytmp = torch::tensor(y, torch::kInt32);</span></span>
|
|
||||||
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 136 : buildDataset(ytmp);</span></span>
|
|
||||||
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 128 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
|
|
||||||
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 240 : return build(features, className, states, weights);</span></span>
|
|
||||||
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 992 : }</span></span>
|
|
||||||
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 852 : Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)</span></span>
|
|
||||||
<span id="L69"><span class="lineNum"> 69</span> : {</span>
|
|
||||||
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 852 : this->dataset = dataset;</span></span>
|
|
||||||
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 852 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
|
|
||||||
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 1704 : return build(features, className, states, weights);</span></span>
|
|
||||||
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 852 : }</span></span>
|
|
||||||
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 660 : Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)</span></span>
|
|
||||||
<span id="L75"><span class="lineNum"> 75</span> : {</span>
|
|
||||||
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 660 : this->dataset = dataset;</span></span>
|
|
||||||
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 660 : return build(features, className, states, weights);</span></span>
|
|
||||||
<span id="L78"><span class="lineNum"> 78</span> : }</span>
|
|
||||||
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 1760 : void Classifier::checkFitParameters()</span></span>
|
|
||||||
<span id="L80"><span class="lineNum"> 80</span> : {</span>
|
|
||||||
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 1760 : if (torch::is_floating_point(dataset)) {</span></span>
|
|
||||||
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("dataset (X, y) must be of type Integer");</span></span>
|
|
||||||
<span id="L83"><span class="lineNum"> 83</span> : }</span>
|
|
||||||
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 1752 : if (dataset.size(0) - 1 != features.size()) {</span></span>
|
|
||||||
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("Classifier: X " + std::to_string(dataset.size(0) - 1) + " and features " + std::to_string(features.size()) + " must have the same number of features");</span></span>
|
|
||||||
<span id="L86"><span class="lineNum"> 86</span> : }</span>
|
|
||||||
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 1744 : if (states.find(className) == states.end()) {</span></span>
|
|
||||||
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("class name not found in states");</span></span>
|
|
||||||
<span id="L89"><span class="lineNum"> 89</span> : }</span>
|
|
||||||
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 32996 : for (auto feature : features) {</span></span>
|
|
||||||
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 31268 : if (states.find(feature) == states.end()) {</span></span>
|
|
||||||
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("feature [" + feature + "] not found in states");</span></span>
|
|
||||||
<span id="L93"><span class="lineNum"> 93</span> : }</span>
|
|
||||||
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 31268 : }</span></span>
|
|
||||||
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 1728 : }</span></span>
|
|
||||||
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 1844 : torch::Tensor Classifier::predict(torch::Tensor& X)</span></span>
|
|
||||||
<span id="L97"><span class="lineNum"> 97</span> : {</span>
|
|
||||||
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 1844 : if (!fitted) {</span></span>
|
|
||||||
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 16 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
|
||||||
<span id="L100"><span class="lineNum"> 100</span> : }</span>
|
|
||||||
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 1828 : return model.predict(X);</span></span>
|
|
||||||
<span id="L102"><span class="lineNum"> 102</span> : }</span>
|
|
||||||
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 16 : std::vector<int> Classifier::predict(std::vector<std::vector<int>>& X)</span></span>
|
|
||||||
<span id="L104"><span class="lineNum"> 104</span> : {</span>
|
|
||||||
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 16 : if (!fitted) {</span></span>
|
|
||||||
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
|
||||||
<span id="L107"><span class="lineNum"> 107</span> : }</span>
|
|
||||||
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 8 : auto m_ = X[0].size();</span></span>
|
|
||||||
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 8 : auto n_ = X.size();</span></span>
|
|
||||||
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 8 : std::vector<std::vector<int>> Xd(n_, std::vector<int>(m_, 0));</span></span>
|
|
||||||
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 40 : for (auto i = 0; i < n_; i++) {</span></span>
|
|
||||||
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 64 : Xd[i] = std::vector<int>(X[i].begin(), X[i].end());</span></span>
|
|
||||||
<span id="L113"><span class="lineNum"> 113</span> : }</span>
|
|
||||||
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 8 : auto yp = model.predict(Xd);</span></span>
|
|
||||||
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 16 : return yp;</span></span>
|
|
||||||
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 8 : }</span></span>
|
|
||||||
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 1484 : torch::Tensor Classifier::predict_proba(torch::Tensor& X)</span></span>
|
|
||||||
<span id="L118"><span class="lineNum"> 118</span> : {</span>
|
|
||||||
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 1484 : if (!fitted) {</span></span>
|
|
||||||
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
|
||||||
<span id="L121"><span class="lineNum"> 121</span> : }</span>
|
|
||||||
<span id="L122"><span class="lineNum"> 122</span> <span class="tlaGNC"> 1476 : return model.predict_proba(X);</span></span>
|
|
||||||
<span id="L123"><span class="lineNum"> 123</span> : }</span>
|
|
||||||
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 548 : std::vector<std::vector<double>> Classifier::predict_proba(std::vector<std::vector<int>>& X)</span></span>
|
|
||||||
<span id="L125"><span class="lineNum"> 125</span> : {</span>
|
|
||||||
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 548 : if (!fitted) {</span></span>
|
|
||||||
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
|
||||||
<span id="L128"><span class="lineNum"> 128</span> : }</span>
|
|
||||||
<span id="L129"><span class="lineNum"> 129</span> <span class="tlaGNC"> 540 : auto m_ = X[0].size();</span></span>
|
|
||||||
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 540 : auto n_ = X.size();</span></span>
|
|
||||||
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 540 : std::vector<std::vector<int>> Xd(n_, std::vector<int>(m_, 0));</span></span>
|
|
||||||
<span id="L132"><span class="lineNum"> 132</span> : // Convert to nxm vector</span>
|
|
||||||
<span id="L133"><span class="lineNum"> 133</span> <span class="tlaGNC"> 5040 : for (auto i = 0; i < n_; i++) {</span></span>
|
|
||||||
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 9000 : Xd[i] = std::vector<int>(X[i].begin(), X[i].end());</span></span>
|
|
||||||
<span id="L135"><span class="lineNum"> 135</span> : }</span>
|
|
||||||
<span id="L136"><span class="lineNum"> 136</span> <span class="tlaGNC"> 540 : auto yp = model.predict_proba(Xd);</span></span>
|
|
||||||
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 1080 : return yp;</span></span>
|
|
||||||
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 540 : }</span></span>
|
|
||||||
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 112 : float Classifier::score(torch::Tensor& X, torch::Tensor& y)</span></span>
|
|
||||||
<span id="L140"><span class="lineNum"> 140</span> : {</span>
|
|
||||||
<span id="L141"><span class="lineNum"> 141</span> <span class="tlaGNC"> 112 : torch::Tensor y_pred = predict(X);</span></span>
|
|
||||||
<span id="L142"><span class="lineNum"> 142</span> <span class="tlaGNC"> 208 : return (y_pred == y).sum().item<float>() / y.size(0);</span></span>
|
|
||||||
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 104 : }</span></span>
|
|
||||||
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 16 : float Classifier::score(std::vector<std::vector<int>>& X, std::vector<int>& y)</span></span>
|
|
||||||
<span id="L145"><span class="lineNum"> 145</span> : {</span>
|
|
||||||
<span id="L146"><span class="lineNum"> 146</span> <span class="tlaGNC"> 16 : if (!fitted) {</span></span>
|
|
||||||
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
|
||||||
<span id="L148"><span class="lineNum"> 148</span> : }</span>
|
|
||||||
<span id="L149"><span class="lineNum"> 149</span> <span class="tlaGNC"> 8 : return model.score(X, y);</span></span>
|
|
||||||
<span id="L150"><span class="lineNum"> 150</span> : }</span>
|
|
||||||
<span id="L151"><span class="lineNum"> 151</span> <span class="tlaGNC"> 24 : std::vector<std::string> Classifier::show() const</span></span>
|
|
||||||
<span id="L152"><span class="lineNum"> 152</span> : {</span>
|
|
||||||
<span id="L153"><span class="lineNum"> 153</span> <span class="tlaGNC"> 24 : return model.show();</span></span>
|
|
||||||
<span id="L154"><span class="lineNum"> 154</span> : }</span>
|
|
||||||
<span id="L155"><span class="lineNum"> 155</span> <span class="tlaGNC"> 1576 : void Classifier::addNodes()</span></span>
|
|
||||||
<span id="L156"><span class="lineNum"> 156</span> : {</span>
|
|
||||||
<span id="L157"><span class="lineNum"> 157</span> : // Add all nodes to the network</span>
|
|
||||||
<span id="L158"><span class="lineNum"> 158</span> <span class="tlaGNC"> 30872 : for (const auto& feature : features) {</span></span>
|
|
||||||
<span id="L159"><span class="lineNum"> 159</span> <span class="tlaGNC"> 29296 : model.addNode(feature);</span></span>
|
|
||||||
<span id="L160"><span class="lineNum"> 160</span> : }</span>
|
|
||||||
<span id="L161"><span class="lineNum"> 161</span> <span class="tlaGNC"> 1576 : model.addNode(className);</span></span>
|
|
||||||
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 1576 : }</span></span>
|
|
||||||
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 332 : int Classifier::getNumberOfNodes() const</span></span>
|
|
||||||
<span id="L164"><span class="lineNum"> 164</span> : {</span>
|
|
||||||
<span id="L165"><span class="lineNum"> 165</span> : // Features does not include class</span>
|
|
||||||
<span id="L166"><span class="lineNum"> 166</span> <span class="tlaGNC"> 332 : return fitted ? model.getFeatures().size() : 0;</span></span>
|
|
||||||
<span id="L167"><span class="lineNum"> 167</span> : }</span>
|
|
||||||
<span id="L168"><span class="lineNum"> 168</span> <span class="tlaGNC"> 332 : int Classifier::getNumberOfEdges() const</span></span>
|
|
||||||
<span id="L169"><span class="lineNum"> 169</span> : {</span>
|
|
||||||
<span id="L170"><span class="lineNum"> 170</span> <span class="tlaGNC"> 332 : return fitted ? model.getNumEdges() : 0;</span></span>
|
|
||||||
<span id="L171"><span class="lineNum"> 171</span> : }</span>
|
|
||||||
<span id="L172"><span class="lineNum"> 172</span> <span class="tlaGNC"> 24 : int Classifier::getNumberOfStates() const</span></span>
|
|
||||||
<span id="L173"><span class="lineNum"> 173</span> : {</span>
|
|
||||||
<span id="L174"><span class="lineNum"> 174</span> <span class="tlaGNC"> 24 : return fitted ? model.getStates() : 0;</span></span>
|
|
||||||
<span id="L175"><span class="lineNum"> 175</span> : }</span>
|
|
||||||
<span id="L176"><span class="lineNum"> 176</span> <span class="tlaGNC"> 348 : int Classifier::getClassNumStates() const</span></span>
|
|
||||||
<span id="L177"><span class="lineNum"> 177</span> : {</span>
|
|
||||||
<span id="L178"><span class="lineNum"> 178</span> <span class="tlaGNC"> 348 : return fitted ? model.getClassNumStates() : 0;</span></span>
|
|
||||||
<span id="L179"><span class="lineNum"> 179</span> : }</span>
|
|
||||||
<span id="L180"><span class="lineNum"> 180</span> <span class="tlaGNC"> 4 : std::vector<std::string> Classifier::topological_order()</span></span>
|
|
||||||
<span id="L181"><span class="lineNum"> 181</span> : {</span>
|
|
||||||
<span id="L182"><span class="lineNum"> 182</span> <span class="tlaGNC"> 4 : return model.topological_sort();</span></span>
|
|
||||||
<span id="L183"><span class="lineNum"> 183</span> : }</span>
|
|
||||||
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 4 : std::string Classifier::dump_cpt() const</span></span>
|
|
||||||
<span id="L185"><span class="lineNum"> 185</span> : {</span>
|
|
||||||
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 4 : return model.dump_cpt();</span></span>
|
|
||||||
<span id="L187"><span class="lineNum"> 187</span> : }</span>
|
|
||||||
<span id="L188"><span class="lineNum"> 188</span> <span class="tlaGNC"> 92 : void Classifier::setHyperparameters(const nlohmann::json& hyperparameters)</span></span>
|
|
||||||
<span id="L189"><span class="lineNum"> 189</span> : {</span>
|
|
||||||
<span id="L190"><span class="lineNum"> 190</span> <span class="tlaGNC"> 92 : if (!hyperparameters.empty()) {</span></span>
|
|
||||||
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("Invalid hyperparameters" + hyperparameters.dump());</span></span>
|
|
||||||
<span id="L192"><span class="lineNum"> 192</span> : }</span>
|
|
||||||
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 84 : }</span></span>
|
|
||||||
<span id="L194"><span class="lineNum"> 194</span> : }</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,69 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="Classifier.cc.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="Classifier.cc.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="Classifier.cc.gcov.html#L13" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,28,79,31" href="Classifier.cc.gcov.html#L17" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,32,79,35" href="Classifier.cc.gcov.html#L21" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,36,79,39" href="Classifier.cc.gcov.html#L25" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,40,79,43" href="Classifier.cc.gcov.html#L29" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,44,79,47" href="Classifier.cc.gcov.html#L33" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,48,79,51" href="Classifier.cc.gcov.html#L37" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,52,79,55" href="Classifier.cc.gcov.html#L41" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,56,79,59" href="Classifier.cc.gcov.html#L45" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,60,79,63" href="Classifier.cc.gcov.html#L49" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,64,79,67" href="Classifier.cc.gcov.html#L53" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,68,79,71" href="Classifier.cc.gcov.html#L57" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,72,79,75" href="Classifier.cc.gcov.html#L61" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,76,79,79" href="Classifier.cc.gcov.html#L65" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,80,79,83" href="Classifier.cc.gcov.html#L69" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,84,79,87" href="Classifier.cc.gcov.html#L73" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,88,79,91" href="Classifier.cc.gcov.html#L77" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,92,79,95" href="Classifier.cc.gcov.html#L81" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,96,79,99" href="Classifier.cc.gcov.html#L85" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,100,79,103" href="Classifier.cc.gcov.html#L89" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,104,79,107" href="Classifier.cc.gcov.html#L93" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,108,79,111" href="Classifier.cc.gcov.html#L97" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,112,79,115" href="Classifier.cc.gcov.html#L101" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,116,79,119" href="Classifier.cc.gcov.html#L105" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,120,79,123" href="Classifier.cc.gcov.html#L109" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,124,79,127" href="Classifier.cc.gcov.html#L113" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,128,79,131" href="Classifier.cc.gcov.html#L117" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,132,79,135" href="Classifier.cc.gcov.html#L121" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,136,79,139" href="Classifier.cc.gcov.html#L125" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,140,79,143" href="Classifier.cc.gcov.html#L129" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,144,79,147" href="Classifier.cc.gcov.html#L133" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,148,79,151" href="Classifier.cc.gcov.html#L137" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,152,79,155" href="Classifier.cc.gcov.html#L141" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,156,79,159" href="Classifier.cc.gcov.html#L145" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,160,79,163" href="Classifier.cc.gcov.html#L149" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,164,79,167" href="Classifier.cc.gcov.html#L153" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,168,79,171" href="Classifier.cc.gcov.html#L157" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,172,79,175" href="Classifier.cc.gcov.html#L161" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,176,79,179" href="Classifier.cc.gcov.html#L165" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,180,79,183" href="Classifier.cc.gcov.html#L169" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,184,79,187" href="Classifier.cc.gcov.html#L173" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,188,79,191" href="Classifier.cc.gcov.html#L177" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,192,79,195" href="Classifier.cc.gcov.html#L181" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="Classifier.cc.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="Classifier.cc.gcov.png" width=80 height=193 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 852 B |
@ -1,111 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.h<span style="font-size: 80%;"> (<a href="Classifier.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="Classifier.h.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L31">bayesnet::Classifier::getVersion[abi:cxx11]()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">32</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">bayesnet::Classifier::getNotes[abi:cxx11]() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">80</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">bayesnet::Classifier::getStatus() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">128</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">bayesnet::Classifier::~Classifier()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1680</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,111 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.h<span style="font-size: 80%;"> (<a href="Classifier.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="Classifier.h.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">bayesnet::Classifier::getNotes[abi:cxx11]() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">80</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">bayesnet::Classifier::getStatus() const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">128</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L31">bayesnet::Classifier::getVersion[abi:cxx11]()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">32</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">bayesnet::Classifier::~Classifier()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1680</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="Classifier.h.gcov.overview.html" name="overview">
|
|
||||||
<frame src="Classifier.h.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,149 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.h<span style="font-size: 80%;"> (source / <a href="Classifier.h.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #ifndef CLASSIFIER_H</span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : #define CLASSIFIER_H</span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : #include <torch/torch.h></span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> : #include "bayesnet/utils/BayesMetrics.h"</span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> : #include "bayesnet/network/Network.h"</span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> : #include "bayesnet/BaseClassifier.h"</span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : </span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> : class Classifier : public BaseClassifier {</span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> : public:</span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> : Classifier(Network model);</span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC tlaBgGNC"> 1680 : virtual ~Classifier() = default;</span></span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> : Classifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;</span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> : Classifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;</span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> : Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;</span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> : Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) override;</span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> : void addNodes();</span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> : int getNumberOfNodes() const override;</span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> : int getNumberOfEdges() const override;</span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> : int getNumberOfStates() const override;</span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> : int getClassNumStates() const override;</span>
|
|
||||||
<span id="L28"><span class="lineNum"> 28</span> : torch::Tensor predict(torch::Tensor& X) override;</span>
|
|
||||||
<span id="L29"><span class="lineNum"> 29</span> : std::vector<int> predict(std::vector<std::vector<int>>& X) override;</span>
|
|
||||||
<span id="L30"><span class="lineNum"> 30</span> : torch::Tensor predict_proba(torch::Tensor& X) override;</span>
|
|
||||||
<span id="L31"><span class="lineNum"> 31</span> : std::vector<std::vector<double>> predict_proba(std::vector<std::vector<int>>& X) override;</span>
|
|
||||||
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 128 : status_t getStatus() const override { return status; }</span></span>
|
|
||||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 96 : std::string getVersion() override { return { project_version.begin(), project_version.end() }; };</span></span>
|
|
||||||
<span id="L34"><span class="lineNum"> 34</span> : float score(torch::Tensor& X, torch::Tensor& y) override;</span>
|
|
||||||
<span id="L35"><span class="lineNum"> 35</span> : float score(std::vector<std::vector<int>>& X, std::vector<int>& y) override;</span>
|
|
||||||
<span id="L36"><span class="lineNum"> 36</span> : std::vector<std::string> show() const override;</span>
|
|
||||||
<span id="L37"><span class="lineNum"> 37</span> : std::vector<std::string> topological_order() override;</span>
|
|
||||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 80 : std::vector<std::string> getNotes() const override { return notes; }</span></span>
|
|
||||||
<span id="L39"><span class="lineNum"> 39</span> : std::string dump_cpt() const override;</span>
|
|
||||||
<span id="L40"><span class="lineNum"> 40</span> : void setHyperparameters(const nlohmann::json& hyperparameters) override; //For classifiers that don't have hyperparameters</span>
|
|
||||||
<span id="L41"><span class="lineNum"> 41</span> : protected:</span>
|
|
||||||
<span id="L42"><span class="lineNum"> 42</span> : bool fitted;</span>
|
|
||||||
<span id="L43"><span class="lineNum"> 43</span> : unsigned int m, n; // m: number of samples, n: number of features</span>
|
|
||||||
<span id="L44"><span class="lineNum"> 44</span> : Network model;</span>
|
|
||||||
<span id="L45"><span class="lineNum"> 45</span> : Metrics metrics;</span>
|
|
||||||
<span id="L46"><span class="lineNum"> 46</span> : std::vector<std::string> features;</span>
|
|
||||||
<span id="L47"><span class="lineNum"> 47</span> : std::string className;</span>
|
|
||||||
<span id="L48"><span class="lineNum"> 48</span> : std::map<std::string, std::vector<int>> states;</span>
|
|
||||||
<span id="L49"><span class="lineNum"> 49</span> : torch::Tensor dataset; // (n+1)xm tensor</span>
|
|
||||||
<span id="L50"><span class="lineNum"> 50</span> : status_t status = NORMAL;</span>
|
|
||||||
<span id="L51"><span class="lineNum"> 51</span> : std::vector<std::string> notes; // Used to store messages occurred during the fit process</span>
|
|
||||||
<span id="L52"><span class="lineNum"> 52</span> : void checkFitParameters();</span>
|
|
||||||
<span id="L53"><span class="lineNum"> 53</span> : virtual void buildModel(const torch::Tensor& weights) = 0;</span>
|
|
||||||
<span id="L54"><span class="lineNum"> 54</span> : void trainModel(const torch::Tensor& weights) override;</span>
|
|
||||||
<span id="L55"><span class="lineNum"> 55</span> : void buildDataset(torch::Tensor& y);</span>
|
|
||||||
<span id="L56"><span class="lineNum"> 56</span> : private:</span>
|
|
||||||
<span id="L57"><span class="lineNum"> 57</span> : Classifier& build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);</span>
|
|
||||||
<span id="L58"><span class="lineNum"> 58</span> : };</span>
|
|
||||||
<span id="L59"><span class="lineNum"> 59</span> : }</span>
|
|
||||||
<span id="L60"><span class="lineNum"> 60</span> : #endif</span>
|
|
||||||
<span id="L61"><span class="lineNum"> 61</span> : </span>
|
|
||||||
<span id="L62"><span class="lineNum"> 62</span> : </span>
|
|
||||||
<span id="L63"><span class="lineNum"> 63</span> : </span>
|
|
||||||
<span id="L64"><span class="lineNum"> 64</span> : </span>
|
|
||||||
<span id="L65"><span class="lineNum"> 65</span> : </span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,37 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="Classifier.h.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="Classifier.h.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="Classifier.h.gcov.html#L13" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,28,79,31" href="Classifier.h.gcov.html#L17" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,32,79,35" href="Classifier.h.gcov.html#L21" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,36,79,39" href="Classifier.h.gcov.html#L25" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,40,79,43" href="Classifier.h.gcov.html#L29" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,44,79,47" href="Classifier.h.gcov.html#L33" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,48,79,51" href="Classifier.h.gcov.html#L37" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,52,79,55" href="Classifier.h.gcov.html#L41" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,56,79,59" href="Classifier.h.gcov.html#L45" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,60,79,63" href="Classifier.h.gcov.html#L49" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,64,79,67" href="Classifier.h.gcov.html#L53" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="Classifier.h.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="Classifier.h.gcov.png" width=80 height=64 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 453 B |
@ -1,118 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.cc<span style="font-size: 80%;"> (<a href="KDB.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">96.3 %</td>
|
|
||||||
<td class="headerCovTableEntry">54</td>
|
|
||||||
<td class="headerCovTableEntry">52</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">5</td>
|
|
||||||
<td class="headerCovTableEntry">5</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDB.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">bayesnet::KDB::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">8</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">bayesnet::KDB::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">12</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">bayesnet::KDB::buildModel(at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">52</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">bayesnet::KDB::KDB(int, float)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">148</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">bayesnet::KDB::add_m_edges(int, std::vector<int, std::allocator<int> >&, at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">344</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,118 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.cc<span style="font-size: 80%;"> (<a href="KDB.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">96.3 %</td>
|
|
||||||
<td class="headerCovTableEntry">54</td>
|
|
||||||
<td class="headerCovTableEntry">52</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">5</td>
|
|
||||||
<td class="headerCovTableEntry">5</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDB.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">bayesnet::KDB::KDB(int, float)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">148</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">bayesnet::KDB::add_m_edges(int, std::vector<int, std::allocator<int> >&, at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">344</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">bayesnet::KDB::buildModel(at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">52</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">bayesnet::KDB::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">8</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">bayesnet::KDB::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">12</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="KDB.cc.gcov.overview.html" name="overview">
|
|
||||||
<frame src="KDB.cc.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,195 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.cc<span style="font-size: 80%;"> (source / <a href="KDB.cc.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">96.3 %</td>
|
|
||||||
<td class="headerCovTableEntry">54</td>
|
|
||||||
<td class="headerCovTableEntry">52</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">5</td>
|
|
||||||
<td class="headerCovTableEntry">5</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #include "KDB.h"</span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : </span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 148 : KDB::KDB(int k, float theta) : Classifier(Network()), k(k), theta(theta)</span></span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> : {</span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 444 : validHyperparameters = { "k", "theta" };</span></span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : </span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 444 : }</span></span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 12 : void KDB::setHyperparameters(const nlohmann::json& hyperparameters_)</span></span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> : {</span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 12 : auto hyperparameters = hyperparameters_;</span></span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 12 : if (hyperparameters.contains("k")) {</span></span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 4 : k = hyperparameters["k"];</span></span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 4 : hyperparameters.erase("k");</span></span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> : }</span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 12 : if (hyperparameters.contains("theta")) {</span></span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 4 : theta = hyperparameters["theta"];</span></span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 4 : hyperparameters.erase("theta");</span></span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> : }</span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 12 : Classifier::setHyperparameters(hyperparameters);</span></span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 12 : }</span></span>
|
|
||||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 52 : void KDB::buildModel(const torch::Tensor& weights)</span></span>
|
|
||||||
<span id="L29"><span class="lineNum"> 29</span> : {</span>
|
|
||||||
<span id="L30"><span class="lineNum"> 30</span> : /*</span>
|
|
||||||
<span id="L31"><span class="lineNum"> 31</span> : 1. For each feature Xi, compute mutual information, I(X;C),</span>
|
|
||||||
<span id="L32"><span class="lineNum"> 32</span> : where C is the class.</span>
|
|
||||||
<span id="L33"><span class="lineNum"> 33</span> : 2. Compute class conditional mutual information I(Xi;XjIC), f or each</span>
|
|
||||||
<span id="L34"><span class="lineNum"> 34</span> : pair of features Xi and Xj, where i#j.</span>
|
|
||||||
<span id="L35"><span class="lineNum"> 35</span> : 3. Let the used variable list, S, be empty.</span>
|
|
||||||
<span id="L36"><span class="lineNum"> 36</span> : 4. Let the DAG network being constructed, BN, begin with a single</span>
|
|
||||||
<span id="L37"><span class="lineNum"> 37</span> : class node, C.</span>
|
|
||||||
<span id="L38"><span class="lineNum"> 38</span> : 5. Repeat until S includes all domain features</span>
|
|
||||||
<span id="L39"><span class="lineNum"> 39</span> : 5.1. Select feature Xmax which is not in S and has the largest value</span>
|
|
||||||
<span id="L40"><span class="lineNum"> 40</span> : I(Xmax;C).</span>
|
|
||||||
<span id="L41"><span class="lineNum"> 41</span> : 5.2. Add a node to BN representing Xmax.</span>
|
|
||||||
<span id="L42"><span class="lineNum"> 42</span> : 5.3. Add an arc from C to Xmax in BN.</span>
|
|
||||||
<span id="L43"><span class="lineNum"> 43</span> : 5.4. Add m = min(lSl,/c) arcs from m distinct features Xj in S with</span>
|
|
||||||
<span id="L44"><span class="lineNum"> 44</span> : the highest value for I(Xmax;X,jC).</span>
|
|
||||||
<span id="L45"><span class="lineNum"> 45</span> : 5.5. Add Xmax to S.</span>
|
|
||||||
<span id="L46"><span class="lineNum"> 46</span> : Compute the conditional probabilility infered by the structure of BN by</span>
|
|
||||||
<span id="L47"><span class="lineNum"> 47</span> : using counts from DB, and output BN.</span>
|
|
||||||
<span id="L48"><span class="lineNum"> 48</span> : */</span>
|
|
||||||
<span id="L49"><span class="lineNum"> 49</span> : // 1. For each feature Xi, compute mutual information, I(X;C),</span>
|
|
||||||
<span id="L50"><span class="lineNum"> 50</span> : // where C is the class.</span>
|
|
||||||
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 52 : addNodes();</span></span>
|
|
||||||
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 156 : const torch::Tensor& y = dataset.index({ -1, "..." });</span></span>
|
|
||||||
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 52 : std::vector<double> mi;</span></span>
|
|
||||||
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 396 : for (auto i = 0; i < features.size(); i++) {</span></span>
|
|
||||||
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 1032 : torch::Tensor firstFeature = dataset.index({ i, "..." });</span></span>
|
|
||||||
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 344 : mi.push_back(metrics.mutualInformation(firstFeature, y, weights));</span></span>
|
|
||||||
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 344 : }</span></span>
|
|
||||||
<span id="L58"><span class="lineNum"> 58</span> : // 2. Compute class conditional mutual information I(Xi;XjIC), f or each</span>
|
|
||||||
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 52 : auto conditionalEdgeWeights = metrics.conditionalEdge(weights);</span></span>
|
|
||||||
<span id="L60"><span class="lineNum"> 60</span> : // 3. Let the used variable list, S, be empty.</span>
|
|
||||||
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 52 : std::vector<int> S;</span></span>
|
|
||||||
<span id="L62"><span class="lineNum"> 62</span> : // 4. Let the DAG network being constructed, BN, begin with a single</span>
|
|
||||||
<span id="L63"><span class="lineNum"> 63</span> : // class node, C.</span>
|
|
||||||
<span id="L64"><span class="lineNum"> 64</span> : // 5. Repeat until S includes all domain features</span>
|
|
||||||
<span id="L65"><span class="lineNum"> 65</span> : // 5.1. Select feature Xmax which is not in S and has the largest value</span>
|
|
||||||
<span id="L66"><span class="lineNum"> 66</span> : // I(Xmax;C).</span>
|
|
||||||
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 52 : auto order = argsort(mi);</span></span>
|
|
||||||
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 396 : for (auto idx : order) {</span></span>
|
|
||||||
<span id="L69"><span class="lineNum"> 69</span> : // 5.2. Add a node to BN representing Xmax.</span>
|
|
||||||
<span id="L70"><span class="lineNum"> 70</span> : // 5.3. Add an arc from C to Xmax in BN.</span>
|
|
||||||
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 344 : model.addEdge(className, features[idx]);</span></span>
|
|
||||||
<span id="L72"><span class="lineNum"> 72</span> : // 5.4. Add m = min(lSl,/c) arcs from m distinct features Xj in S with</span>
|
|
||||||
<span id="L73"><span class="lineNum"> 73</span> : // the highest value for I(Xmax;X,jC).</span>
|
|
||||||
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 344 : add_m_edges(idx, S, conditionalEdgeWeights);</span></span>
|
|
||||||
<span id="L75"><span class="lineNum"> 75</span> : // 5.5. Add Xmax to S.</span>
|
|
||||||
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 344 : S.push_back(idx);</span></span>
|
|
||||||
<span id="L77"><span class="lineNum"> 77</span> : }</span>
|
|
||||||
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 448 : }</span></span>
|
|
||||||
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 344 : void KDB::add_m_edges(int idx, std::vector<int>& S, torch::Tensor& weights)</span></span>
|
|
||||||
<span id="L80"><span class="lineNum"> 80</span> : {</span>
|
|
||||||
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 344 : auto n_edges = std::min(k, static_cast<int>(S.size()));</span></span>
|
|
||||||
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 344 : auto cond_w = clone(weights);</span></span>
|
|
||||||
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 344 : bool exit_cond = k == 0;</span></span>
|
|
||||||
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 344 : int num = 0;</span></span>
|
|
||||||
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 1004 : while (!exit_cond) {</span></span>
|
|
||||||
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 2640 : auto max_minfo = argmax(cond_w.index({ idx, "..." })).item<int>();</span></span>
|
|
||||||
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 660 : auto belongs = find(S.begin(), S.end(), max_minfo) != S.end();</span></span>
|
|
||||||
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 1764 : if (belongs && cond_w.index({ idx, max_minfo }).item<float>() > theta) {</span></span>
|
|
||||||
<span id="L89"><span class="lineNum"> 89</span> : try {</span>
|
|
||||||
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 320 : model.addEdge(features[max_minfo], features[idx]);</span></span>
|
|
||||||
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 320 : num++;</span></span>
|
|
||||||
<span id="L92"><span class="lineNum"> 92</span> : }</span>
|
|
||||||
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaUNC tlaBgUNC"> 0 : catch (const std::invalid_argument& e) {</span></span>
|
|
||||||
<span id="L94"><span class="lineNum"> 94</span> : // Loops are not allowed</span>
|
|
||||||
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaUNC"> 0 : }</span></span>
|
|
||||||
<span id="L96"><span class="lineNum"> 96</span> : }</span>
|
|
||||||
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC tlaBgGNC"> 2640 : cond_w.index_put_({ idx, max_minfo }, -1);</span></span>
|
|
||||||
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 1980 : auto candidates_mask = cond_w.index({ idx, "..." }).gt(theta);</span></span>
|
|
||||||
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 660 : auto candidates = candidates_mask.nonzero();</span></span>
|
|
||||||
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 660 : exit_cond = num == n_edges || candidates.size(0) == 0;</span></span>
|
|
||||||
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 660 : }</span></span>
|
|
||||||
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 2692 : }</span></span>
|
|
||||||
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 8 : std::vector<std::string> KDB::graph(const std::string& title) const</span></span>
|
|
||||||
<span id="L104"><span class="lineNum"> 104</span> : {</span>
|
|
||||||
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 8 : std::string header{ title };</span></span>
|
|
||||||
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 8 : if (title == "KDB") {</span></span>
|
|
||||||
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 8 : header += " (k=" + std::to_string(k) + ", theta=" + std::to_string(theta) + ")";</span></span>
|
|
||||||
<span id="L108"><span class="lineNum"> 108</span> : }</span>
|
|
||||||
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 16 : return model.graph(header);</span></span>
|
|
||||||
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 8 : }</span></span>
|
|
||||||
<span id="L111"><span class="lineNum"> 111</span> : }</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="KDB.cc.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="KDB.cc.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="KDB.cc.gcov.html#L13" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,28,79,31" href="KDB.cc.gcov.html#L17" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,32,79,35" href="KDB.cc.gcov.html#L21" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,36,79,39" href="KDB.cc.gcov.html#L25" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,40,79,43" href="KDB.cc.gcov.html#L29" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,44,79,47" href="KDB.cc.gcov.html#L33" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,48,79,51" href="KDB.cc.gcov.html#L37" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,52,79,55" href="KDB.cc.gcov.html#L41" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,56,79,59" href="KDB.cc.gcov.html#L45" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,60,79,63" href="KDB.cc.gcov.html#L49" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,64,79,67" href="KDB.cc.gcov.html#L53" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,68,79,71" href="KDB.cc.gcov.html#L57" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,72,79,75" href="KDB.cc.gcov.html#L61" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,76,79,79" href="KDB.cc.gcov.html#L65" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,80,79,83" href="KDB.cc.gcov.html#L69" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,84,79,87" href="KDB.cc.gcov.html#L73" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,88,79,91" href="KDB.cc.gcov.html#L77" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,92,79,95" href="KDB.cc.gcov.html#L81" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,96,79,99" href="KDB.cc.gcov.html#L85" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,100,79,103" href="KDB.cc.gcov.html#L89" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,104,79,107" href="KDB.cc.gcov.html#L93" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,108,79,111" href="KDB.cc.gcov.html#L97" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="KDB.cc.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="KDB.cc.gcov.png" width=80 height=110 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 814 B |
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.h<span style="font-size: 80%;"> (<a href="KDB.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDB.h.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.h.gcov.html#L20">bayesnet::KDB::~KDB()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">44</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.h<span style="font-size: 80%;"> (<a href="KDB.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDB.h.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDB.h.gcov.html#L20">bayesnet::KDB::~KDB()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">44</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="KDB.h.gcov.overview.html" name="overview">
|
|
||||||
<frame src="KDB.h.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,111 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.h<span style="font-size: 80%;"> (source / <a href="KDB.h.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #ifndef KDB_H</span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : #define KDB_H</span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : #include <torch/torch.h></span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> : #include "bayesnet/utils/bayesnetUtils.h"</span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> : #include "Classifier.h"</span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : class KDB : public Classifier {</span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> : private:</span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> : int k;</span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> : float theta;</span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> : void add_m_edges(int idx, std::vector<int>& S, torch::Tensor& weights);</span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> : protected:</span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> : void buildModel(const torch::Tensor& weights) override;</span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> : public:</span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> : explicit KDB(int k, float theta = 0.03);</span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC tlaBgGNC"> 44 : virtual ~KDB() = default;</span></span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> : void setHyperparameters(const nlohmann::json& hyperparameters_) override;</span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> : std::vector<std::string> graph(const std::string& name = "KDB") const override;</span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> : };</span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> : }</span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> : #endif</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,27 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.h</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="KDB.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="KDB.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="KDB.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="KDB.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="KDB.h.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="KDB.h.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="KDB.h.gcov.html#L13" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="KDB.h.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="KDB.h.gcov.png" width=80 height=26 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 279 B |
@ -1,111 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.cc<span style="font-size: 80%;"> (<a href="KDBLd.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">17</td>
|
|
||||||
<td class="headerCovTableEntry">17</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDBLd.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">bayesnet::KDBLd::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">4</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">bayesnet::KDBLd::predict(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">16</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">bayesnet::KDBLd::fit(at::Tensor&, at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">20</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">bayesnet::KDBLd::KDBLd(int)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">68</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,111 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.cc<span style="font-size: 80%;"> (<a href="KDBLd.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">17</td>
|
|
||||||
<td class="headerCovTableEntry">17</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDBLd.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">bayesnet::KDBLd::KDBLd(int)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">68</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">bayesnet::KDBLd::fit(at::Tensor&, at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">20</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">bayesnet::KDBLd::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">4</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">bayesnet::KDBLd::predict(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">16</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="KDBLd.cc.gcov.overview.html" name="overview">
|
|
||||||
<frame src="KDBLd.cc.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,119 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.cc<span style="font-size: 80%;"> (source / <a href="KDBLd.cc.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">17</td>
|
|
||||||
<td class="headerCovTableEntry">17</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
<td class="headerCovTableEntry">4</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #include "KDBLd.h"</span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : </span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 68 : KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}</span></span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 20 : KDBLd& KDBLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)</span></span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> : {</span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 20 : checkInput(X_, y_);</span></span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 20 : features = features_;</span></span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 20 : className = className_;</span></span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 20 : Xf = X_;</span></span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 20 : y = y_;</span></span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> : // Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y</span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 20 : states = fit_local_discretization(y);</span></span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> : // We have discretized the input data</span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> : // 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network</span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 20 : KDB::fit(dataset, features, className, states);</span></span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 20 : states = localDiscretizationProposal(states, model);</span></span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 20 : return *this;</span></span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> : }</span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 16 : torch::Tensor KDBLd::predict(torch::Tensor& X)</span></span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> : {</span>
|
|
||||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 16 : auto Xt = prepareX(X);</span></span>
|
|
||||||
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 32 : return KDB::predict(Xt);</span></span>
|
|
||||||
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 16 : }</span></span>
|
|
||||||
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 4 : std::vector<std::string> KDBLd::graph(const std::string& name) const</span></span>
|
|
||||||
<span id="L32"><span class="lineNum"> 32</span> : {</span>
|
|
||||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 4 : return KDB::graph(name);</span></span>
|
|
||||||
<span id="L34"><span class="lineNum"> 34</span> : }</span>
|
|
||||||
<span id="L35"><span class="lineNum"> 35</span> : }</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,29 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="KDBLd.cc.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="KDBLd.cc.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="KDBLd.cc.gcov.html#L13" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,28,79,31" href="KDBLd.cc.gcov.html#L17" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,32,79,35" href="KDBLd.cc.gcov.html#L21" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="KDBLd.cc.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="KDBLd.cc.gcov.png" width=80 height=34 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 333 B |
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.h<span style="font-size: 80%;"> (<a href="KDBLd.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDBLd.h.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.h.gcov.html#L15">bayesnet::KDBLd::~KDBLd()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">20</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.h<span style="font-size: 80%;"> (<a href="KDBLd.h.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDBLd.h.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="KDBLd.h.gcov.html#L15">bayesnet::KDBLd::~KDBLd()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">20</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="KDBLd.h.gcov.overview.html" name="overview">
|
|
||||||
<frame src="KDBLd.h.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,108 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.h<span style="font-size: 80%;"> (source / <a href="KDBLd.h.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
<td class="headerCovTableEntry">1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #ifndef KDBLD_H</span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : #define KDBLD_H</span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : #include "Proposal.h"</span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> : #include "KDB.h"</span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> : </span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : class KDBLd : public KDB, public Proposal {</span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> : private:</span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> : explicit KDBLd(int k);</span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 20 : virtual ~KDBLd() = default;</span></span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> : KDBLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;</span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> : std::vector<std::string> graph(const std::string& name = "KDB") const override;</span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> : torch::Tensor predict(torch::Tensor& X) override;</span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> : static inline std::string version() { return "0.0.1"; };</span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> : };</span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> : }</span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> : #endif // !KDBLD_H</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,26 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="KDBLd.h.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="KDBLd.h.gcov.html#L9" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="KDBLd.h.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="KDBLd.h.gcov.png" width=80 height=23 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 265 B |
@ -1,139 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Proposal.cc<span style="font-size: 80%;"> (<a href="Proposal.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">97.7 %</td>
|
|
||||||
<td class="headerCovTableEntry">86</td>
|
|
||||||
<td class="headerCovTableEntry">84</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">8</td>
|
|
||||||
<td class="headerCovTableEntry">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="Proposal.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">bayesnet::Proposal::prepareX(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">168</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">bayesnet::Proposal::~Proposal()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">200</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">bayesnet::Proposal::localDiscretizationProposal(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > > const&, bayesnet::Network&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">212</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">bayesnet::Proposal::checkInput(at::Tensor const&, at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">228</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">bayesnet::Proposal::fit_local_discretization[abi:cxx11](at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">232</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">bayesnet::Proposal::Proposal(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">424</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">auto bayesnet::Proposal::localDiscretizationProposal(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > > const&, bayesnet::Network&)::{lambda(auto:1 const&)#2}::operator()<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1372</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">auto bayesnet::Proposal::localDiscretizationProposal(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > > const&, bayesnet::Network&)::{lambda(auto:1 const&)#1}::operator()<bayesnet::Node*>(bayesnet::Node* const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">2696</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,139 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Proposal.cc<span style="font-size: 80%;"> (<a href="Proposal.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">97.7 %</td>
|
|
||||||
<td class="headerCovTableEntry">86</td>
|
|
||||||
<td class="headerCovTableEntry">84</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">8</td>
|
|
||||||
<td class="headerCovTableEntry">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="Proposal.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">auto bayesnet::Proposal::localDiscretizationProposal(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > > const&, bayesnet::Network&)::{lambda(auto:1 const&)#1}::operator()<bayesnet::Node*>(bayesnet::Node* const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">2696</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">auto bayesnet::Proposal::localDiscretizationProposal(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > > const&, bayesnet::Network&)::{lambda(auto:1 const&)#2}::operator()<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1372</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">bayesnet::Proposal::Proposal(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">424</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">bayesnet::Proposal::checkInput(at::Tensor const&, at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">228</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">bayesnet::Proposal::fit_local_discretization[abi:cxx11](at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">232</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">bayesnet::Proposal::localDiscretizationProposal(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > > const&, bayesnet::Network&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">212</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">bayesnet::Proposal::prepareX(at::Tensor&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">168</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">bayesnet::Proposal::~Proposal()</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">200</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="Proposal.cc.gcov.overview.html" name="overview">
|
|
||||||
<frame src="Proposal.cc.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,200 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Proposal.cc<span style="font-size: 80%;"> (source / <a href="Proposal.cc.func-c.html">functions</a>)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">97.7 %</td>
|
|
||||||
<td class="headerCovTableEntry">86</td>
|
|
||||||
<td class="headerCovTableEntry">84</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">8</td>
|
|
||||||
<td class="headerCovTableEntry">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table cellpadding=0 cellspacing=0 border=0>
|
|
||||||
<tr>
|
|
||||||
<td><br></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre class="sourceHeading"> Line data Source code</pre>
|
|
||||||
<pre class="source">
|
|
||||||
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
|
||||||
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
|
||||||
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
|
||||||
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
|
||||||
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
|
||||||
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
|
||||||
<span id="L7"><span class="lineNum"> 7</span> : #include <ArffFiles.h></span>
|
|
||||||
<span id="L8"><span class="lineNum"> 8</span> : #include "Proposal.h"</span>
|
|
||||||
<span id="L9"><span class="lineNum"> 9</span> : </span>
|
|
||||||
<span id="L10"><span class="lineNum"> 10</span> : namespace bayesnet {</span>
|
|
||||||
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 424 : Proposal::Proposal(torch::Tensor& dataset_, std::vector<std::string>& features_, std::string& className_) : pDataset(dataset_), pFeatures(features_), pClassName(className_) {}</span></span>
|
|
||||||
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 200 : Proposal::~Proposal()</span></span>
|
|
||||||
<span id="L13"><span class="lineNum"> 13</span> : {</span>
|
|
||||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 1896 : for (auto& [key, value] : discretizers) {</span></span>
|
|
||||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 1696 : delete value;</span></span>
|
|
||||||
<span id="L16"><span class="lineNum"> 16</span> : }</span>
|
|
||||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 200 : }</span></span>
|
|
||||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 228 : void Proposal::checkInput(const torch::Tensor& X, const torch::Tensor& y)</span></span>
|
|
||||||
<span id="L19"><span class="lineNum"> 19</span> : {</span>
|
|
||||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 228 : if (!torch::is_floating_point(X)) {</span></span>
|
|
||||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaUNC tlaBgUNC"> 0 : throw std::invalid_argument("X must be a floating point tensor");</span></span>
|
|
||||||
<span id="L22"><span class="lineNum"> 22</span> : }</span>
|
|
||||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC tlaBgGNC"> 228 : if (torch::is_floating_point(y)) {</span></span>
|
|
||||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaUNC tlaBgUNC"> 0 : throw std::invalid_argument("y must be an integer tensor");</span></span>
|
|
||||||
<span id="L25"><span class="lineNum"> 25</span> : }</span>
|
|
||||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC tlaBgGNC"> 228 : }</span></span>
|
|
||||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 212 : map<std::string, std::vector<int>> Proposal::localDiscretizationProposal(const map<std::string, std::vector<int>>& oldStates, Network& model)</span></span>
|
|
||||||
<span id="L28"><span class="lineNum"> 28</span> : {</span>
|
|
||||||
<span id="L29"><span class="lineNum"> 29</span> : // order of local discretization is important. no good 0, 1, 2...</span>
|
|
||||||
<span id="L30"><span class="lineNum"> 30</span> : // although we rediscretize features after the local discretization of every feature</span>
|
|
||||||
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 212 : auto order = model.topological_sort();</span></span>
|
|
||||||
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 212 : auto& nodes = model.getNodes();</span></span>
|
|
||||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 212 : map<std::string, std::vector<int>> states = oldStates;</span></span>
|
|
||||||
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 212 : std::vector<int> indicesToReDiscretize;</span></span>
|
|
||||||
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 212 : bool upgrade = false; // Flag to check if we need to upgrade the model</span></span>
|
|
||||||
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 1776 : for (auto feature : order) {</span></span>
|
|
||||||
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 1564 : auto nodeParents = nodes[feature]->getParents();</span></span>
|
|
||||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 1564 : if (nodeParents.size() < 2) continue; // Only has class as parent</span></span>
|
|
||||||
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 1324 : upgrade = true;</span></span>
|
|
||||||
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 1324 : int index = find(pFeatures.begin(), pFeatures.end(), feature) - pFeatures.begin();</span></span>
|
|
||||||
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 1324 : indicesToReDiscretize.push_back(index); // We need to re-discretize this feature</span></span>
|
|
||||||
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 1324 : std::vector<std::string> parents;</span></span>
|
|
||||||
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 4020 : transform(nodeParents.begin(), nodeParents.end(), back_inserter(parents), [](const auto& p) { return p->getName(); });</span></span>
|
|
||||||
<span id="L44"><span class="lineNum"> 44</span> : // Remove class as parent as it will be added later</span>
|
|
||||||
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 1324 : parents.erase(remove(parents.begin(), parents.end(), pClassName), parents.end());</span></span>
|
|
||||||
<span id="L46"><span class="lineNum"> 46</span> : // Get the indices of the parents</span>
|
|
||||||
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 1324 : std::vector<int> indices;</span></span>
|
|
||||||
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 1324 : indices.push_back(-1); // Add class index</span></span>
|
|
||||||
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 2696 : transform(parents.begin(), parents.end(), back_inserter(indices), [&](const auto& p) {return find(pFeatures.begin(), pFeatures.end(), p) - pFeatures.begin(); });</span></span>
|
|
||||||
<span id="L50"><span class="lineNum"> 50</span> : // Now we fit the discretizer of the feature, conditioned on its parents and the class i.e. discretizer.fit(X[index], X[indices] + y)</span>
|
|
||||||
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 1324 : std::vector<std::string> yJoinParents(Xf.size(1));</span></span>
|
|
||||||
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 4020 : for (auto idx : indices) {</span></span>
|
|
||||||
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 958640 : for (int i = 0; i < Xf.size(1); ++i) {</span></span>
|
|
||||||
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 2867832 : yJoinParents[i] += to_string(pDataset.index({ idx, i }).item<int>());</span></span>
|
|
||||||
<span id="L55"><span class="lineNum"> 55</span> : }</span>
|
|
||||||
<span id="L56"><span class="lineNum"> 56</span> : }</span>
|
|
||||||
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 1324 : auto arff = ArffFiles();</span></span>
|
|
||||||
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 1324 : auto yxv = arff.factorize(yJoinParents);</span></span>
|
|
||||||
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 2648 : auto xvf_ptr = Xf.index({ index }).data_ptr<float>();</span></span>
|
|
||||||
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 1324 : auto xvf = std::vector<mdlp::precision_t>(xvf_ptr, xvf_ptr + Xf.size(1));</span></span>
|
|
||||||
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 1324 : discretizers[feature]->fit(xvf, yxv);</span></span>
|
|
||||||
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 1804 : }</span></span>
|
|
||||||
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 212 : if (upgrade) {</span></span>
|
|
||||||
<span id="L64"><span class="lineNum"> 64</span> : // Discretize again X (only the affected indices) with the new fitted discretizers</span>
|
|
||||||
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 1536 : for (auto index : indicesToReDiscretize) {</span></span>
|
|
||||||
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 2648 : auto Xt_ptr = Xf.index({ index }).data_ptr<float>();</span></span>
|
|
||||||
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 1324 : auto Xt = std::vector<float>(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
|
|
||||||
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 5296 : pDataset.index_put_({ index, "..." }, torch::tensor(discretizers[pFeatures[index]]->transform(Xt)));</span></span>
|
|
||||||
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 1324 : auto xStates = std::vector<int>(discretizers[pFeatures[index]]->getCutPoints().size() + 1);</span></span>
|
|
||||||
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 1324 : iota(xStates.begin(), xStates.end(), 0);</span></span>
|
|
||||||
<span id="L71"><span class="lineNum"> 71</span> : //Update new states of the feature/node</span>
|
|
||||||
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 1324 : states[pFeatures[index]] = xStates;</span></span>
|
|
||||||
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 1324 : }</span></span>
|
|
||||||
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 212 : const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);</span></span>
|
|
||||||
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 212 : model.fit(pDataset, weights, pFeatures, pClassName, states);</span></span>
|
|
||||||
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 212 : }</span></span>
|
|
||||||
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 424 : return states;</span></span>
|
|
||||||
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 960128 : }</span></span>
|
|
||||||
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 232 : map<std::string, std::vector<int>> Proposal::fit_local_discretization(const torch::Tensor& y)</span></span>
|
|
||||||
<span id="L80"><span class="lineNum"> 80</span> : {</span>
|
|
||||||
<span id="L81"><span class="lineNum"> 81</span> : // Discretize the continuous input data and build pDataset (Classifier::dataset)</span>
|
|
||||||
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 232 : int m = Xf.size(1);</span></span>
|
|
||||||
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 232 : int n = Xf.size(0);</span></span>
|
|
||||||
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 232 : map<std::string, std::vector<int>> states;</span></span>
|
|
||||||
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 232 : pDataset = torch::zeros({ n + 1, m }, torch::kInt32);</span></span>
|
|
||||||
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 232 : auto yv = std::vector<int>(y.data_ptr<int>(), y.data_ptr<int>() + y.size(0));</span></span>
|
|
||||||
<span id="L87"><span class="lineNum"> 87</span> : // discretize input data by feature(row)</span>
|
|
||||||
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 1944 : for (auto i = 0; i < pFeatures.size(); ++i) {</span></span>
|
|
||||||
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 1712 : auto* discretizer = new mdlp::CPPFImdlp();</span></span>
|
|
||||||
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 3424 : auto Xt_ptr = Xf.index({ i }).data_ptr<float>();</span></span>
|
|
||||||
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 1712 : auto Xt = std::vector<float>(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
|
|
||||||
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 1712 : discretizer->fit(Xt, yv);</span></span>
|
|
||||||
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 6848 : pDataset.index_put_({ i, "..." }, torch::tensor(discretizer->transform(Xt)));</span></span>
|
|
||||||
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 1712 : auto xStates = std::vector<int>(discretizer->getCutPoints().size() + 1);</span></span>
|
|
||||||
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 1712 : iota(xStates.begin(), xStates.end(), 0);</span></span>
|
|
||||||
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 1712 : states[pFeatures[i]] = xStates;</span></span>
|
|
||||||
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 1712 : discretizers[pFeatures[i]] = discretizer;</span></span>
|
|
||||||
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 1712 : }</span></span>
|
|
||||||
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 232 : int n_classes = torch::max(y).item<int>() + 1;</span></span>
|
|
||||||
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 232 : auto yStates = std::vector<int>(n_classes);</span></span>
|
|
||||||
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 232 : iota(yStates.begin(), yStates.end(), 0);</span></span>
|
|
||||||
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 232 : states[pClassName] = yStates;</span></span>
|
|
||||||
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 696 : pDataset.index_put_({ n, "..." }, y);</span></span>
|
|
||||||
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 464 : return states;</span></span>
|
|
||||||
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 3888 : }</span></span>
|
|
||||||
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 168 : torch::Tensor Proposal::prepareX(torch::Tensor& X)</span></span>
|
|
||||||
<span id="L107"><span class="lineNum"> 107</span> : {</span>
|
|
||||||
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 168 : auto Xtd = torch::zeros_like(X, torch::kInt32);</span></span>
|
|
||||||
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 1376 : for (int i = 0; i < X.size(0); ++i) {</span></span>
|
|
||||||
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 1208 : auto Xt = std::vector<float>(X[i].data_ptr<float>(), X[i].data_ptr<float>() + X.size(1));</span></span>
|
|
||||||
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 1208 : auto Xd = discretizers[pFeatures[i]]->transform(Xt);</span></span>
|
|
||||||
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 3624 : Xtd.index_put_({ i }, torch::tensor(Xd, torch::kInt32));</span></span>
|
|
||||||
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 1208 : }</span></span>
|
|
||||||
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 336 : return Xtd;</span></span>
|
|
||||||
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 1376 : }</span></span>
|
|
||||||
<span id="L116"><span class="lineNum"> 116</span> : }</span>
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<map name="overview">
|
|
||||||
<area shape="rect" coords="0,0,79,3" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,4,79,7" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,8,79,11" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,12,79,15" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,16,79,19" href="Proposal.cc.gcov.html#L5" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,20,79,23" href="Proposal.cc.gcov.html#L9" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,24,79,27" href="Proposal.cc.gcov.html#L13" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,28,79,31" href="Proposal.cc.gcov.html#L17" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,32,79,35" href="Proposal.cc.gcov.html#L21" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,36,79,39" href="Proposal.cc.gcov.html#L25" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,40,79,43" href="Proposal.cc.gcov.html#L29" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,44,79,47" href="Proposal.cc.gcov.html#L33" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,48,79,51" href="Proposal.cc.gcov.html#L37" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,52,79,55" href="Proposal.cc.gcov.html#L41" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,56,79,59" href="Proposal.cc.gcov.html#L45" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,60,79,63" href="Proposal.cc.gcov.html#L49" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,64,79,67" href="Proposal.cc.gcov.html#L53" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,68,79,71" href="Proposal.cc.gcov.html#L57" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,72,79,75" href="Proposal.cc.gcov.html#L61" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,76,79,79" href="Proposal.cc.gcov.html#L65" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,80,79,83" href="Proposal.cc.gcov.html#L69" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,84,79,87" href="Proposal.cc.gcov.html#L73" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,88,79,91" href="Proposal.cc.gcov.html#L77" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,92,79,95" href="Proposal.cc.gcov.html#L81" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,96,79,99" href="Proposal.cc.gcov.html#L85" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,100,79,103" href="Proposal.cc.gcov.html#L89" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,104,79,107" href="Proposal.cc.gcov.html#L93" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,108,79,111" href="Proposal.cc.gcov.html#L97" target="source" alt="overview">
|
|
||||||
<area shape="rect" coords="0,112,79,115" href="Proposal.cc.gcov.html#L101" target="source" alt="overview">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="Proposal.cc.gcov.html#top" target="source">Top</a><br><br>
|
|
||||||
<img src="Proposal.cc.gcov.png" width=80 height=115 alt="Overview" border=0 usemap="#overview">
|
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Before Width: | Height: | Size: 796 B |
@ -1,104 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/SPODE.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - SPODE.cc<span style="font-size: 80%;"> (<a href="SPODE.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">10</td>
|
|
||||||
<td class="headerCovTableEntry">10</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">3</td>
|
|
||||||
<td class="headerCovTableEntry">3</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="SPODE.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">bayesnet::SPODE::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">68</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">bayesnet::SPODE::buildModel(at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1016</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">bayesnet::SPODE::SPODE(int)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1124</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,104 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/SPODE.cc - functions</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td width="100%">
|
|
||||||
<table cellpadding=1 border=0 width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="10%" class="headerItem">Current view:</td>
|
|
||||||
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - SPODE.cc<span style="font-size: 80%;"> (<a href="SPODE.cc.gcov.html">source</a> / functions)</span></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%"></td>
|
|
||||||
<td width="5%" class="headerCovTableHead">Coverage</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
|
||||||
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test:</td>
|
|
||||||
<td class="headerValue">BayesNet Coverage Report</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Lines:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">10</td>
|
|
||||||
<td class="headerCovTableEntry">10</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Test Date:</td>
|
|
||||||
<td class="headerValue">2024-05-06 17:54:04</td>
|
|
||||||
<td></td>
|
|
||||||
<td class="headerItem">Functions:</td>
|
|
||||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
||||||
<td class="headerCovTableEntry">3</td>
|
|
||||||
<td class="headerCovTableEntry">3</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="headerItem">Legend:</td>
|
|
||||||
<td class="headerValueLeg"> Lines:
|
|
||||||
<span class="coverLegendCov">hit</span>
|
|
||||||
<span class="coverLegendNoCov">not hit</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<table cellpadding=1 cellspacing=1 border=0>
|
|
||||||
<tr><td><br></td></tr>
|
|
||||||
<tr>
|
|
||||||
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
|
||||||
|
|
||||||
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="SPODE.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">bayesnet::SPODE::SPODE(int)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1124</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">bayesnet::SPODE::buildModel(at::Tensor const&)</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">1016</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">bayesnet::SPODE::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
|
||||||
|
|
||||||
<td class="coverFnHi">68</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
</center>
|
|
||||||
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
||||||
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
||||||
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/SPODE.cc</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<frameset cols="120,*">
|
|
||||||
<frame src="SPODE.cc.gcov.overview.html" name="overview">
|
|
||||||
<frame src="SPODE.cc.gcov.html" name="source">
|
|
||||||
<noframes>
|
|
||||||
<center>Frames not supported by your browser!<br></center>
|
|
||||||
</noframes>
|
|
||||||
</frameset>
|
|
||||||
|
|
||||||
</html>
|
|