Compare commits
73 Commits
convergenc
...
main
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 | |||
0e24135d46 | |||
521bfd2a8e | |||
e2e0fb0c40 | |||
56b62a67cc | |||
c0fc107abb | |||
d8c44b3b7c | |||
6ab7cd2cbd | |||
b578ea8a2d | |||
9a752d15dc | |||
4992685e94 | |||
346b693c79 | |||
164c8bd90c | |||
ced29a2c2e | |||
0ec53f405f | |||
f806015b29 | |||
8115f25c06 | |||
618a1e539c | |||
7aeffba740 | |||
e79ea63afb |
@ -1,4 +1,4 @@
|
||||
compilation_database_dir: build_debug
|
||||
compilation_database_dir: build_Debug
|
||||
output_directory: diagrams
|
||||
diagrams:
|
||||
BayesNet:
|
||||
|
57
.devcontainer/Dockerfile
Normal file
57
.devcontainer/Dockerfile
Normal file
@ -0,0 +1,57 @@
|
||||
FROM mcr.microsoft.com/devcontainers/cpp:ubuntu22.04
|
||||
|
||||
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.29.3"
|
||||
|
||||
# Optionally install the cmake for vcpkg
|
||||
COPY ./reinstall-cmake.sh /tmp/
|
||||
|
||||
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
|
||||
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
|
||||
fi \
|
||||
&& rm -f /tmp/reinstall-cmake.sh
|
||||
|
||||
|
||||
# [Optional] Uncomment this section to install additional vcpkg ports.
|
||||
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"
|
||||
|
||||
# [Optional] Uncomment this section to install additional packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends wget software-properties-common libdatetime-perl libcapture-tiny-perl libdatetime-format-dateparse-perl libgd-perl
|
||||
|
||||
# Add PPA for GCC 13
|
||||
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||
RUN apt-get update
|
||||
|
||||
# Install GCC 13.1
|
||||
RUN apt-get install -y gcc-13 g++-13 doxygen
|
||||
|
||||
# Install lcov 2.1
|
||||
RUN wget --quiet https://github.com/linux-test-project/lcov/releases/download/v2.1/lcov-2.1.tar.gz && \
|
||||
tar -xvf lcov-2.1.tar.gz && \
|
||||
cd lcov-2.1 && \
|
||||
make install
|
||||
RUN rm lcov-2.1.tar.gz
|
||||
RUN rm -fr lcov-2.1
|
||||
|
||||
# Install Miniconda
|
||||
RUN mkdir -p /opt/conda
|
||||
RUN wget --quiet "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh" -O /opt/conda/miniconda.sh && \
|
||||
bash /opt/conda/miniconda.sh -b -p /opt/miniconda
|
||||
|
||||
# Add conda to PATH
|
||||
ENV PATH=/opt/miniconda/bin:$PATH
|
||||
|
||||
# add CXX and CC to the environment with gcc 13
|
||||
ENV CXX=/usr/bin/g++-13
|
||||
ENV CC=/usr/bin/gcc-13
|
||||
|
||||
# link the last gcov version
|
||||
RUN rm /usr/bin/gcov
|
||||
RUN ln -s /usr/bin/gcov-13 /usr/bin/gcov
|
||||
|
||||
# change ownership of /opt/miniconda to vscode user
|
||||
RUN chown -R vscode:vscode /opt/miniconda
|
||||
|
||||
USER vscode
|
||||
RUN conda init
|
||||
RUN conda install -y -c conda-forge yaml pytorch
|
37
.devcontainer/devcontainer.json
Normal file
37
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,37 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
|
||||
{
|
||||
"name": "C++",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
// "features": {
|
||||
// "ghcr.io/devcontainers/features/conda:1": {}
|
||||
// }
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
// "features": {},
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "make release && make debug && echo 'Done!'",
|
||||
// Configure tool-specific properties.
|
||||
// "customizations": {},
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
"settings": {},
|
||||
"extensions": [
|
||||
"ms-vscode.cpptools",
|
||||
"ms-vscode.cpptools-extension-pack",
|
||||
"ms-vscode.cpptools-themes",
|
||||
"ms-vscode.cmake-tools",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"jbenden.c-cpp-flylint",
|
||||
"matepek.vscode-catch2-test-adapter",
|
||||
"GitHub.copilot"
|
||||
]
|
||||
}
|
||||
}
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
59
.devcontainer/reinstall-cmake.sh
Normal file
59
.devcontainer/reinstall-cmake.sh
Normal file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
set -e
|
||||
|
||||
CMAKE_VERSION=${1:-"none"}
|
||||
|
||||
if [ "${CMAKE_VERSION}" = "none" ]; then
|
||||
echo "No CMake version specified, skipping CMake reinstallation"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Cleanup temporary directory and associated files when exiting the script.
|
||||
cleanup() {
|
||||
EXIT_CODE=$?
|
||||
set +e
|
||||
if [[ -n "${TMP_DIR}" ]]; then
|
||||
echo "Executing cleanup of tmp files"
|
||||
rm -Rf "${TMP_DIR}"
|
||||
fi
|
||||
exit $EXIT_CODE
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
|
||||
echo "Installing CMake..."
|
||||
apt-get -y purge --auto-remove cmake
|
||||
mkdir -p /opt/cmake
|
||||
|
||||
architecture=$(dpkg --print-architecture)
|
||||
case "${architecture}" in
|
||||
arm64)
|
||||
ARCH=aarch64 ;;
|
||||
amd64)
|
||||
ARCH=x86_64 ;;
|
||||
*)
|
||||
echo "Unsupported architecture ${architecture}."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
|
||||
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
|
||||
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)
|
||||
|
||||
echo "${TMP_DIR}"
|
||||
cd "${TMP_DIR}"
|
||||
|
||||
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
|
||||
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O
|
||||
|
||||
sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
|
||||
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license
|
||||
|
||||
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
|
||||
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest
|
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for more information:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
# https://containers.dev/guide/dependabot
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "devcontainers"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -39,4 +39,9 @@ cmake-build*/**
|
||||
puml/**
|
||||
.vscode/settings.json
|
||||
sample/build
|
||||
**/.DS_Store
|
||||
docs/manual
|
||||
docs/man3
|
||||
docs/man
|
||||
docs/Doxyfile
|
||||
|
||||
|
16
.gitmodules
vendored
16
.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"]
|
||||
path = lib/json
|
||||
url = https://github.com/nlohmann/json.git
|
||||
@ -13,3 +8,14 @@
|
||||
url = https://github.com/rmontanana/folding
|
||||
main = main
|
||||
update = merge
|
||||
[submodule "tests/lib/catch2"]
|
||||
path = tests/lib/catch2
|
||||
url = https://github.com/catchorg/Catch2.git
|
||||
main = main
|
||||
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
6
.vscode/launch.json
vendored
@ -14,11 +14,11 @@
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "test",
|
||||
"program": "${workspaceFolder}/build_debug/tests/TestBayesNet",
|
||||
"program": "${workspaceFolder}/build_Debug/tests/TestBayesNet",
|
||||
"args": [
|
||||
"\"Bisection Best\""
|
||||
"No features selected"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/build_debug/tests"
|
||||
"cwd": "${workspaceFolder}/build_Debug/tests"
|
||||
},
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
|
45
CHANGELOG.md
45
CHANGELOG.md
@ -7,18 +7,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [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
|
||||
|
||||
- Add the Library logo generated with <https://openart.ai> to README.md
|
||||
- Add link to the coverage report in the README.md coverage label.
|
||||
- Add the *convergence_best* hyperparameter to the BoostAODE class, to control the way the prior accuracy is computed if convergence is set. Default value is *false*.
|
||||
- Library logo generated with <https://openart.ai> to README.md
|
||||
- Link to the coverage report in the README.md coverage label.
|
||||
- *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.
|
||||
- A2DE model.
|
||||
- BoostA2DE model.
|
||||
- A2DE & SPnDE tests.
|
||||
- Add tests to reach 99% of coverage.
|
||||
- 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
|
||||
|
||||
- Refactor library ArffFile to limit the number of samples with a parameter.
|
||||
- Refactor tests libraries location to test/lib
|
||||
- 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.
|
||||
- Refactor catch2 library location to test/lib
|
||||
- Refactor loadDataset function in tests.
|
||||
- Remove conditionalEdgeWeights method in BayesMetrics.
|
||||
- Refactor Coverage Report generation.
|
||||
- Add devcontainer to work on apple silicon.
|
||||
- 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,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(BayesNet
|
||||
VERSION 1.0.5
|
||||
VERSION 1.0.6
|
||||
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
||||
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
||||
LANGUAGES CXX
|
||||
@ -25,8 +25,12 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -O0 -g")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||
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} -Ofast")
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
|
||||
endif()
|
||||
|
||||
# Options
|
||||
# -------
|
||||
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
||||
@ -45,11 +49,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CODE_COVERAGE ON)
|
||||
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
message(STATUS "Languages=${LANGUAGES}")
|
||||
if (CODE_COVERAGE)
|
||||
enable_testing()
|
||||
include(CodeCoverage)
|
||||
MESSAGE("Code coverage enabled")
|
||||
MESSAGE(STATUS "Code coverage enabled")
|
||||
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||
endif (CODE_COVERAGE)
|
||||
|
||||
@ -59,9 +64,10 @@ endif (ENABLE_CLANG_TIDY)
|
||||
|
||||
# External libraries - dependencies of BayesNet
|
||||
# ---------------------------------------------
|
||||
|
||||
# include(FetchContent)
|
||||
add_git_submodule("lib/mdlp")
|
||||
add_git_submodule("lib/json")
|
||||
add_git_submodule("lib/mdlp")
|
||||
|
||||
# Subdirectories
|
||||
# --------------
|
||||
@ -71,9 +77,8 @@ add_subdirectory(bayesnet)
|
||||
# Testing
|
||||
# -------
|
||||
if (ENABLE_TESTING)
|
||||
MESSAGE("Testing enabled")
|
||||
MESSAGE(STATUS "Testing enabled")
|
||||
add_subdirectory(tests/lib/catch2)
|
||||
add_subdirectory(tests/lib/Files)
|
||||
include(CTest)
|
||||
add_subdirectory(tests)
|
||||
endif (ENABLE_TESTING)
|
||||
@ -85,4 +90,19 @@ install(TARGETS BayesNet
|
||||
LIBRARY DESTINATION lib
|
||||
CONFIGURATIONS Release)
|
||||
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)
|
||||
|
72
Makefile
72
Makefile
@ -1,19 +1,22 @@
|
||||
SHELL := /bin/bash
|
||||
.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_debug = build_debug
|
||||
f_release = build_Release
|
||||
f_debug = build_Debug
|
||||
f_diagrams = diagrams
|
||||
app_targets = BayesNet
|
||||
test_targets = TestBayesNet
|
||||
clang-uml = clang-uml
|
||||
plantuml = plantuml
|
||||
gcovr = gcovr
|
||||
lcov = lcov
|
||||
genhtml = genhtml
|
||||
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
|
||||
@for t in $(test_targets); do \
|
||||
@ -40,7 +43,7 @@ setup: ## Install dependencies for tests and coverage
|
||||
fi
|
||||
@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 $(dot) || (echo ">>> Please install graphviz"; exit 1)
|
||||
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
|
||||
@ -55,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
|
||||
|
||||
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
|
||||
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
|
||||
@echo ">>> Cleaning Debug BayesNet tests...";
|
||||
@ -102,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
|
||||
@echo ">>> Running BayesNet tests...";
|
||||
@$(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 \
|
||||
echo ">>> Running $$t...";\
|
||||
if [ -f $(f_debug)/tests/$$t ]; then \
|
||||
@ -115,25 +118,30 @@ test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximu
|
||||
|
||||
coverage: ## Run tests and generate coverage report (build/index.html)
|
||||
@echo ">>> Building tests with coverage..."
|
||||
@which $(gcovr) || (echo ">>> Please install gcovr"; exit 1)
|
||||
@which $(lcov) || (echo ">>> Please install lcov"; exit 1)
|
||||
@which $(genhtml) || (echo ">>> Please install lcov"; exit 1)
|
||||
@$(MAKE) test
|
||||
@$(gcovr) $(f_debug)/tests
|
||||
@which $(lcov) || (echo ">>ease install lcov"; exit 1)
|
||||
@if [ ! -f $(f_debug)/tests/coverage.info ] ; then $(MAKE) test ; fi
|
||||
@echo ">>> Building report..."
|
||||
@cd $(f_debug)/tests; \
|
||||
$(lcov) --directory CMakeFiles --capture --ignore-errors source,source --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --directory CMakeFiles --capture --demangle-cpp --ignore-errors source,source --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info '/usr/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'lib/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'libtorch/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'tests/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'bayesnet/utils/loguru.*' --ignore-errors unused --output-file coverage.info >/dev/null 2>&1
|
||||
@$(genhtml) $(f_debug)/tests/coverage.info --demangle-cpp --output-directory html >/dev/null 2>&1;
|
||||
$(lcov) --remove coverage.info 'bayesnet/utils/loguru.*' --ignore-errors unused --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info '/opt/miniconda/*' --ignore-errors unused --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --summary coverage.info
|
||||
@$(MAKE) updatebadge
|
||||
@echo ">>> Done";
|
||||
|
||||
viewcoverage: ## View the html coverage report
|
||||
@xdg-open html/index.html || open html/index.html 2>/dev/null
|
||||
@which $(genhtml) >/dev/null || (echo ">>> Please install lcov (genhtml not found)"; exit 1)
|
||||
@if [ ! -d $(docsrcdir)/coverage ]; then mkdir -p $(docsrcdir)/coverage; fi
|
||||
@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";
|
||||
|
||||
updatebadge: ## Update the coverage badge in README.md
|
||||
@ -146,6 +154,34 @@ updatebadge: ## Update the coverage badge in README.md
|
||||
@env python update_coverage.py $(f_debug)/tests
|
||||
@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
|
||||
@IFS=$$'\n' ; \
|
||||
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
||||
|
41
README.md
41
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)
|
||||
[![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)
|
||||
[![Coverage Badge](https://img.shields.io/badge/Coverage-97,8%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
|
||||
|
||||
@ -61,7 +62,37 @@ make sample fname=tests/data/glass.arff
|
||||
|
||||
## Models
|
||||
|
||||
### [BoostAODE](docs/BoostAODE.md)
|
||||
#### - TAN
|
||||
|
||||
#### - KDB
|
||||
|
||||
#### - SPODE
|
||||
|
||||
#### - SPnDE
|
||||
|
||||
#### - AODE
|
||||
|
||||
#### - A2DE
|
||||
|
||||
#### - [BoostAODE](docs/BoostAODE.md)
|
||||
|
||||
#### - BoostA2DE
|
||||
|
||||
### With Local Discretization
|
||||
|
||||
#### - TANLd
|
||||
|
||||
#### - KDBLd
|
||||
|
||||
#### - SPODELd
|
||||
|
||||
#### - AODELd
|
||||
|
||||
## Documentation
|
||||
|
||||
### [Manual](https://rmontanana.github.io/bayesnet/)
|
||||
|
||||
### [Coverage report](https://rmontanana.github.io/bayesnet/coverage/index.html)
|
||||
|
||||
## Diagrams
|
||||
|
||||
@ -72,7 +103,3 @@ make sample fname=tests/data/glass.arff
|
||||
### Dependency Diagram
|
||||
|
||||
![BayesNet Dependency Diagram](diagrams/dependency.svg)
|
||||
|
||||
## Coverage report
|
||||
|
||||
### [Coverage report](docs/coverage.pdf)
|
||||
|
@ -8,16 +8,18 @@
|
||||
#include <vector>
|
||||
#include <torch/torch.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "bayesnet/network/Network.h"
|
||||
|
||||
namespace bayesnet {
|
||||
enum status_t { NORMAL, WARNING, ERROR };
|
||||
class BaseClassifier {
|
||||
public:
|
||||
// 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
|
||||
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& 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 torch::Tensor& weights) = 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, 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, const Smoothing_t smoothing) = 0;
|
||||
virtual ~BaseClassifier() = default;
|
||||
torch::Tensor virtual predict(torch::Tensor& 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;
|
||||
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
|
||||
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;
|
||||
};
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
include_directories(
|
||||
${BayesNet_SOURCE_DIR}/lib/mdlp
|
||||
${BayesNet_SOURCE_DIR}/lib/Files
|
||||
${BayesNet_SOURCE_DIR}/lib/mdlp/src
|
||||
${BayesNet_SOURCE_DIR}/lib/folding
|
||||
${BayesNet_SOURCE_DIR}/lib/json/include
|
||||
${BayesNet_SOURCE_DIR}
|
||||
@ -10,4 +9,4 @@ include_directories(
|
||||
file(GLOB_RECURSE Sources "*.cc")
|
||||
|
||||
add_library(BayesNet ${Sources})
|
||||
target_link_libraries(BayesNet mdlp "${TORCH_LIBRARIES}")
|
||||
target_link_libraries(BayesNet fimdlp "${TORCH_LIBRARIES}")
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace bayesnet {
|
||||
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";
|
||||
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->className = className;
|
||||
@ -23,7 +23,7 @@ namespace bayesnet {
|
||||
metrics = Metrics(dataset, features, className, n_classes);
|
||||
model.initialize();
|
||||
buildModel(weights);
|
||||
trainModel(weights);
|
||||
trainModel(weights, smoothing);
|
||||
fitted = true;
|
||||
return *this;
|
||||
}
|
||||
@ -41,20 +41,20 @@ namespace bayesnet {
|
||||
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
|
||||
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;
|
||||
buildDataset(y);
|
||||
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
|
||||
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);
|
||||
for (int i = 0; i < X.size(); ++i) {
|
||||
@ -63,18 +63,18 @@ namespace bayesnet {
|
||||
auto ytmp = torch::tensor(y, torch::kInt32);
|
||||
buildDataset(ytmp);
|
||||
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;
|
||||
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;
|
||||
return build(features, className, states, weights);
|
||||
return build(features, className, states, weights, smoothing);
|
||||
}
|
||||
void Classifier::checkFitParameters()
|
||||
{
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define CLASSIFIER_H
|
||||
#include <torch/torch.h>
|
||||
#include "bayesnet/utils/BayesMetrics.h"
|
||||
#include "bayesnet/network/Network.h"
|
||||
#include "bayesnet/BaseClassifier.h"
|
||||
|
||||
namespace bayesnet {
|
||||
@ -16,10 +15,10 @@ namespace bayesnet {
|
||||
public:
|
||||
Classifier(Network model);
|
||||
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(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& 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 torch::Tensor& weights) 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, 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 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, const Smoothing_t smoothing) override;
|
||||
void addNodes();
|
||||
int getNumberOfNodes() 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
|
||||
void checkFitParameters();
|
||||
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);
|
||||
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
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace bayesnet {
|
||||
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_);
|
||||
features = features_;
|
||||
@ -19,7 +19,7 @@ namespace bayesnet {
|
||||
states = fit_local_discretization(y);
|
||||
// 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
|
||||
KDB::fit(dataset, features, className, states);
|
||||
KDB::fit(dataset, features, className, states, smoothing);
|
||||
states = localDiscretizationProposal(states, model);
|
||||
return *this;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace bayesnet {
|
||||
public:
|
||||
explicit KDBLd(int k);
|
||||
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;
|
||||
torch::Tensor predict(torch::Tensor& X) override;
|
||||
static inline std::string version() { return "0.0.1"; };
|
||||
|
@ -4,7 +4,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#include <ArffFiles.h>
|
||||
#include "Proposal.h"
|
||||
|
||||
namespace bayesnet {
|
||||
@ -54,8 +53,7 @@ namespace bayesnet {
|
||||
yJoinParents[i] += to_string(pDataset.index({ idx, i }).item<int>());
|
||||
}
|
||||
}
|
||||
auto arff = ArffFiles();
|
||||
auto yxv = arff.factorize(yJoinParents);
|
||||
auto yxv = factorize(yJoinParents);
|
||||
auto xvf_ptr = Xf.index({ index }).data_ptr<float>();
|
||||
auto xvf = std::vector<mdlp::precision_t>(xvf_ptr, xvf_ptr + Xf.size(1));
|
||||
discretizers[feature]->fit(xvf, yxv);
|
||||
@ -72,7 +70,7 @@ namespace bayesnet {
|
||||
states[pFeatures[index]] = xStates;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -113,4 +111,19 @@ namespace bayesnet {
|
||||
}
|
||||
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
|
||||
map<std::string, mdlp::CPPFImdlp*> discretizers;
|
||||
private:
|
||||
std::vector<int> factorize(const std::vector<std::string>& labels_t);
|
||||
torch::Tensor& pDataset; // (n+1)xm tensor
|
||||
std::vector<std::string>& pFeatures;
|
||||
std::string& pClassName;
|
||||
|
@ -8,25 +8,25 @@
|
||||
|
||||
namespace bayesnet {
|
||||
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_);
|
||||
Xf = X_;
|
||||
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)) {
|
||||
throw std::runtime_error("Dataset must be a floating point tensor");
|
||||
}
|
||||
Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();
|
||||
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_;
|
||||
className = className_;
|
||||
@ -34,7 +34,7 @@ namespace bayesnet {
|
||||
states = fit_local_discretization(y);
|
||||
// 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
|
||||
SPODE::fit(dataset, features, className, states);
|
||||
SPODE::fit(dataset, features, className, states, smoothing);
|
||||
states = localDiscretizationProposal(states, model);
|
||||
return *this;
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ namespace bayesnet {
|
||||
public:
|
||||
explicit SPODELd(int root);
|
||||
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& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
||||
SPODELd& commonFit(const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states);
|
||||
std::vector<std::string> graph(const std::string& name = "SPODE") const 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, const Smoothing_t smoothing) override;
|
||||
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 = "SPODELd") const override;
|
||||
torch::Tensor predict(torch::Tensor& X) override;
|
||||
static inline std::string version() { return "0.0.1"; };
|
||||
};
|
||||
|
38
bayesnet/classifiers/SPnDE.cc
Normal file
38
bayesnet/classifiers/SPnDE.cc
Normal file
@ -0,0 +1,38 @@
|
||||
// ***************************************************************
|
||||
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX-FileType: SOURCE
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#include "SPnDE.h"
|
||||
|
||||
namespace bayesnet {
|
||||
|
||||
SPnDE::SPnDE(std::vector<int> parents) : Classifier(Network()), parents(parents) {}
|
||||
|
||||
void SPnDE::buildModel(const torch::Tensor& weights)
|
||||
{
|
||||
// 0. Add all nodes to the model
|
||||
addNodes();
|
||||
std::vector<int> attributes;
|
||||
for (int i = 0; i < static_cast<int>(features.size()); ++i) {
|
||||
if (std::find(parents.begin(), parents.end(), i) == parents.end()) {
|
||||
attributes.push_back(i);
|
||||
}
|
||||
}
|
||||
// 1. Add edges from the class node to all other nodes
|
||||
// 2. Add edges from the parents nodes to all other nodes
|
||||
for (const auto& attribute : attributes) {
|
||||
model.addEdge(className, features[attribute]);
|
||||
for (const auto& root : parents) {
|
||||
|
||||
model.addEdge(features[root], features[attribute]);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<std::string> SPnDE::graph(const std::string& name) const
|
||||
{
|
||||
return model.graph(name);
|
||||
}
|
||||
|
||||
}
|
26
bayesnet/classifiers/SPnDE.h
Normal file
26
bayesnet/classifiers/SPnDE.h
Normal file
@ -0,0 +1,26 @@
|
||||
// ***************************************************************
|
||||
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX-FileType: SOURCE
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#ifndef SPnDE_H
|
||||
#define SPnDE_H
|
||||
#include <vector>
|
||||
#include "Classifier.h"
|
||||
|
||||
namespace bayesnet {
|
||||
class SPnDE : public Classifier {
|
||||
public:
|
||||
explicit SPnDE(std::vector<int> parents);
|
||||
virtual ~SPnDE() = default;
|
||||
std::vector<std::string> graph(const std::string& name = "SPnDE") const override;
|
||||
protected:
|
||||
void buildModel(const torch::Tensor& weights) override;
|
||||
private:
|
||||
std::vector<int> parents;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace bayesnet {
|
||||
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_);
|
||||
features = features_;
|
||||
@ -19,7 +19,7 @@ namespace bayesnet {
|
||||
states = fit_local_discretization(y);
|
||||
// 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
|
||||
TAN::fit(dataset, features, className, states);
|
||||
TAN::fit(dataset, features, className, states, smoothing);
|
||||
states = localDiscretizationProposal(states, model);
|
||||
return *this;
|
||||
|
||||
|
@ -15,10 +15,9 @@ namespace bayesnet {
|
||||
public:
|
||||
TANLd();
|
||||
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;
|
||||
std::vector<std::string> graph(const std::string& name = "TAN") const 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 = "TANLd") const override;
|
||||
torch::Tensor predict(torch::Tensor& X) override;
|
||||
static inline std::string version() { return "0.0.1"; };
|
||||
};
|
||||
}
|
||||
#endif // !TANLD_H
|
40
bayesnet/ensembles/A2DE.cc
Normal file
40
bayesnet/ensembles/A2DE.cc
Normal file
@ -0,0 +1,40 @@
|
||||
// ***************************************************************
|
||||
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX-FileType: SOURCE
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#include "A2DE.h"
|
||||
|
||||
namespace bayesnet {
|
||||
A2DE::A2DE(bool predict_voting) : Ensemble(predict_voting)
|
||||
{
|
||||
validHyperparameters = { "predict_voting" };
|
||||
}
|
||||
void A2DE::setHyperparameters(const nlohmann::json& hyperparameters_)
|
||||
{
|
||||
auto hyperparameters = hyperparameters_;
|
||||
if (hyperparameters.contains("predict_voting")) {
|
||||
predict_voting = hyperparameters["predict_voting"];
|
||||
hyperparameters.erase("predict_voting");
|
||||
}
|
||||
Classifier::setHyperparameters(hyperparameters);
|
||||
}
|
||||
void A2DE::buildModel(const torch::Tensor& weights)
|
||||
{
|
||||
models.clear();
|
||||
significanceModels.clear();
|
||||
for (int i = 0; i < features.size() - 1; ++i) {
|
||||
for (int j = i + 1; j < features.size(); ++j) {
|
||||
auto model = std::make_unique<SPnDE>(std::vector<int>({ i, j }));
|
||||
models.push_back(std::move(model));
|
||||
}
|
||||
}
|
||||
n_models = static_cast<unsigned>(models.size());
|
||||
significanceModels = std::vector<double>(n_models, 1.0);
|
||||
}
|
||||
std::vector<std::string> A2DE::graph(const std::string& title) const
|
||||
{
|
||||
return Ensemble::graph(title);
|
||||
}
|
||||
}
|
22
bayesnet/ensembles/A2DE.h
Normal file
22
bayesnet/ensembles/A2DE.h
Normal file
@ -0,0 +1,22 @@
|
||||
// ***************************************************************
|
||||
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX-FileType: SOURCE
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#ifndef A2DE_H
|
||||
#define A2DE_H
|
||||
#include "bayesnet/classifiers/SPnDE.h"
|
||||
#include "Ensemble.h"
|
||||
namespace bayesnet {
|
||||
class A2DE : public Ensemble {
|
||||
public:
|
||||
A2DE(bool predict_voting = false);
|
||||
virtual ~A2DE() {};
|
||||
void setHyperparameters(const nlohmann::json& hyperparameters) override;
|
||||
std::vector<std::string> graph(const std::string& title = "A2DE") const override;
|
||||
protected:
|
||||
void buildModel(const torch::Tensor& weights) override;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -10,7 +10,7 @@ namespace bayesnet {
|
||||
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_);
|
||||
features = features_;
|
||||
@ -20,8 +20,9 @@ namespace bayesnet {
|
||||
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||
states = fit_local_discretization(y);
|
||||
// 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
|
||||
Ensemble::fit(dataset, features, className, states);
|
||||
// 1st we need to fit the model to build the normal AODE structure, Ensemble::fit
|
||||
// calls buildModel to initialize the base models
|
||||
Ensemble::fit(dataset, features, className, states, smoothing);
|
||||
return *this;
|
||||
|
||||
}
|
||||
@ -34,10 +35,10 @@ namespace bayesnet {
|
||||
n_models = models.size();
|
||||
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) {
|
||||
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
|
||||
|
@ -15,10 +15,10 @@ namespace bayesnet {
|
||||
public:
|
||||
AODELd(bool predict_voting = true);
|
||||
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;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
246
bayesnet/ensembles/Boost.cc
Normal file
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
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
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
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
|
||||
// ***************************************************************
|
||||
|
||||
#include <random>
|
||||
#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 "BoostAODE.h"
|
||||
#include "lib/log/loguru.cpp"
|
||||
|
||||
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);
|
||||
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 cfsFeatures = featureSelector->getFeatures();
|
||||
auto scores = featureSelector->getScores();
|
||||
for (const int& feature : cfsFeatures) {
|
||||
featuresUsed.push_back(feature);
|
||||
std::vector<int> featuresSelected = featureSelection(weights_);
|
||||
for (const int& feature : featuresSelected) {
|
||||
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));
|
||||
significanceModels.push_back(1.0); // They will be updated later in trainModel
|
||||
n_models++;
|
||||
}
|
||||
notes.push_back("Used features in initialization: " + std::to_string(featuresUsed.size()) + " of " + std::to_string(features.size()) + " with " + select_features_algorithm);
|
||||
delete featureSelector;
|
||||
return featuresUsed;
|
||||
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 BoostAODE::trainModel(const torch::Tensor& weights)
|
||||
void BoostAODE::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||
{
|
||||
//
|
||||
// Logging setup
|
||||
//
|
||||
loguru::set_thread_name("BoostAODE");
|
||||
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
|
||||
loguru::add_file("boostAODE.log", loguru::Truncate, loguru::Verbosity_MAX);
|
||||
// loguru::set_thread_name("BoostAODE");
|
||||
// loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
|
||||
// loguru::add_file("boostAODE.log", loguru::Truncate, loguru::Verbosity_MAX);
|
||||
|
||||
// Algorithm based on the adaboost algorithm for classification
|
||||
// as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
|
||||
@ -282,7 +47,7 @@ namespace bayesnet {
|
||||
bool finished = false;
|
||||
std::vector<int> featuresUsed;
|
||||
if (selectFeatures) {
|
||||
featuresUsed = initializeModels();
|
||||
featuresUsed = initializeModels(smoothing);
|
||||
auto ypred = predict(X_train);
|
||||
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
|
||||
// Update significance of the models
|
||||
@ -318,13 +83,13 @@ namespace bayesnet {
|
||||
);
|
||||
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());
|
||||
// VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
|
||||
while (counter++ < k && featureSelection.size() > 0) {
|
||||
auto feature = featureSelection[0];
|
||||
featureSelection.erase(featureSelection.begin());
|
||||
std::unique_ptr<Classifier> model;
|
||||
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;
|
||||
if (!block_update) {
|
||||
auto ypred = model->predict(X_train);
|
||||
@ -337,7 +102,7 @@ namespace bayesnet {
|
||||
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());
|
||||
// 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_);
|
||||
@ -351,10 +116,10 @@ namespace bayesnet {
|
||||
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);
|
||||
// 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);
|
||||
// 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;
|
||||
}
|
||||
@ -366,13 +131,13 @@ namespace bayesnet {
|
||||
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();
|
||||
}
|
||||
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);
|
||||
// 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();
|
||||
@ -380,7 +145,7 @@ namespace bayesnet {
|
||||
}
|
||||
} 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);
|
||||
// VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
|
||||
}
|
||||
}
|
||||
if (featuresUsed.size() != features.size()) {
|
||||
|
@ -6,45 +6,21 @@
|
||||
|
||||
#ifndef BOOSTAODE_H
|
||||
#define BOOSTAODE_H
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bayesnet/classifiers/SPODE.h"
|
||||
#include "bayesnet/feature_selection/FeatureSelect.h"
|
||||
#include "Ensemble.h"
|
||||
#include "Boost.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 BoostAODE : public Ensemble {
|
||||
class BoostAODE : public Boost {
|
||||
public:
|
||||
explicit BoostAODE(bool predict_voting = false);
|
||||
virtual ~BoostAODE() = default;
|
||||
std::vector<std::string> graph(const std::string& title = "BoostAODE") const override;
|
||||
void setHyperparameters(const nlohmann::json& hyperparameters_) override;
|
||||
protected:
|
||||
void buildModel(const torch::Tensor& weights) override;
|
||||
void trainModel(const torch::Tensor& weights) override;
|
||||
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
|
||||
private:
|
||||
std::tuple<torch::Tensor&, double, bool> update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights);
|
||||
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;
|
||||
std::vector<int> initializeModels(const Smoothing_t smoothing);
|
||||
};
|
||||
}
|
||||
#endif
|
@ -3,22 +3,21 @@
|
||||
// SPDX-FileType: SOURCE
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#include "Ensemble.h"
|
||||
#include "bayesnet/utils/CountingSemaphore.h"
|
||||
|
||||
namespace bayesnet {
|
||||
|
||||
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";
|
||||
void Ensemble::trainModel(const torch::Tensor& weights)
|
||||
void Ensemble::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
|
||||
{
|
||||
n_models = models.size();
|
||||
for (auto i = 0; i < n_models; ++i) {
|
||||
// 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)
|
||||
@ -85,17 +84,9 @@ namespace bayesnet {
|
||||
{
|
||||
auto n_states = models[0]->getClassNumStates();
|
||||
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) {
|
||||
threads.push_back(std::thread([&, i]() {
|
||||
auto ypredict = models[i]->predict_proba(X);
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
y_pred += ypredict * significanceModels[i];
|
||||
}));
|
||||
}
|
||||
for (auto& thread : threads) {
|
||||
thread.join();
|
||||
auto ypredict = models[i]->predict_proba(X);
|
||||
y_pred += ypredict * significanceModels[i];
|
||||
}
|
||||
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
|
||||
y_pred /= sum;
|
||||
@ -105,23 +96,15 @@ namespace bayesnet {
|
||||
{
|
||||
auto n_states = models[0]->getClassNumStates();
|
||||
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) {
|
||||
threads.push_back(std::thread([&, i]() {
|
||||
auto ypredict = models[i]->predict_proba(X);
|
||||
assert(ypredict.size() == y_pred.size());
|
||||
assert(ypredict[0].size() == y_pred[0].size());
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
// Multiply each prediction by the significance of the model and then add it to the final prediction
|
||||
for (auto j = 0; j < ypredict.size(); ++j) {
|
||||
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 ypredict = models[i]->predict_proba(X);
|
||||
assert(ypredict.size() == y_pred.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
|
||||
for (auto j = 0; j < ypredict.size(); ++j) {
|
||||
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; });
|
||||
}
|
||||
}
|
||||
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
|
||||
//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
|
||||
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) {
|
||||
threads.push_back(std::thread([&, i]() {
|
||||
auto ypredict = models[i]->predict(X);
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
y_pred.index_put_({ "...", i }, ypredict);
|
||||
}));
|
||||
}
|
||||
for (auto& thread : threads) {
|
||||
thread.join();
|
||||
auto ypredict = models[i]->predict(X);
|
||||
y_pred.index_put_({ "...", i }, ypredict);
|
||||
}
|
||||
return voting(y_pred);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace bayesnet {
|
||||
unsigned n_models;
|
||||
std::vector<std::unique_ptr<Classifier>> models;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
@ -5,20 +5,20 @@
|
||||
// ***************************************************************
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
#include "Network.h"
|
||||
#include "bayesnet/utils/bayesnetUtils.h"
|
||||
#include "bayesnet/utils/CountingSemaphore.h"
|
||||
#include <pthread.h>
|
||||
#include <fstream>
|
||||
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) : laplaceSmoothing(other.laplaceSmoothing), features(other.features), className(other.className), classNumStates(other.getClassNumStates()),
|
||||
maxThreads(other.getMaxThreads()), fitted(other.fitted), samples(other.samples)
|
||||
Network::Network(const Network& other) : features(other.features), className(other.className), classNumStates(other.getClassNumStates()),
|
||||
fitted(other.fitted), samples(other.samples)
|
||||
{
|
||||
if (samples.defined())
|
||||
samples = samples.clone();
|
||||
@ -35,16 +35,15 @@ namespace bayesnet {
|
||||
nodes.clear();
|
||||
samples = torch::Tensor();
|
||||
}
|
||||
float Network::getMaxThreads() const
|
||||
{
|
||||
return maxThreads;
|
||||
}
|
||||
torch::Tensor& Network::getSamples()
|
||||
{
|
||||
return samples;
|
||||
}
|
||||
void Network::addNode(const std::string& name)
|
||||
{
|
||||
if (fitted) {
|
||||
throw std::invalid_argument("Cannot add node to a fitted network. Initialize first.");
|
||||
}
|
||||
if (name == "") {
|
||||
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)
|
||||
{
|
||||
if (fitted) {
|
||||
throw std::invalid_argument("Cannot add edge to a fitted network. Initialize first.");
|
||||
}
|
||||
if (nodes.find(parent) == nodes.end()) {
|
||||
throw std::invalid_argument("Parent node " + parent + " does not exist");
|
||||
}
|
||||
if (nodes.find(child) == nodes.end()) {
|
||||
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
|
||||
nodes[parent]->addChild(nodes[child].get());
|
||||
nodes[child]->addParent(nodes[parent].get());
|
||||
@ -155,7 +163,7 @@ namespace bayesnet {
|
||||
classNumStates = nodes.at(className)->getNumStates();
|
||||
}
|
||||
// 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);
|
||||
this->className = className;
|
||||
@ -164,17 +172,17 @@ namespace bayesnet {
|
||||
for (int i = 0; i < featureNames.size(); ++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);
|
||||
this->className = className;
|
||||
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
|
||||
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);
|
||||
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_({ -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);
|
||||
laplaceSmoothing = 1.0 / samples.size(1); // To use in CPT computation
|
||||
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) {
|
||||
threads.emplace_back([this, &node, &weights]() {
|
||||
node.second->computeCPT(samples, features, laplaceSmoothing, weights);
|
||||
});
|
||||
semaphore.acquire();
|
||||
threads.emplace_back(worker, std::ref(node), i++);
|
||||
}
|
||||
for (auto& thread : threads) {
|
||||
thread.join();
|
||||
@ -207,14 +241,38 @@ namespace bayesnet {
|
||||
if (!fitted) {
|
||||
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;
|
||||
std::vector<std::thread> threads;
|
||||
std::mutex mtx;
|
||||
auto& semaphore = CountingSemaphore::getInstance();
|
||||
result = torch::zeros({ samples.size(1), classNumStates }, torch::kFloat64);
|
||||
for (int i = 0; i < samples.size(1); ++i) {
|
||||
const torch::Tensor sample = samples.index({ "...", i });
|
||||
auto worker = [&](const torch::Tensor& sample, int 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 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)
|
||||
return result;
|
||||
@ -239,18 +297,38 @@ namespace bayesnet {
|
||||
if (!fitted) {
|
||||
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<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) {
|
||||
sample.clear();
|
||||
for (int col = 0; col < tsamples.size(); ++col) {
|
||||
sample.push_back(tsamples[col][row]);
|
||||
}
|
||||
std::vector<double> classProbabilities = predict_sample(sample);
|
||||
// Find the class with the maximum posterior probability
|
||||
auto maxElem = max_element(classProbabilities.begin(), classProbabilities.end());
|
||||
int predictedClass = distance(classProbabilities.begin(), maxElem);
|
||||
predictions.push_back(predictedClass);
|
||||
semaphore.acquire();
|
||||
threads.emplace_back(worker, sample, row, std::ref(predictions[row]));
|
||||
}
|
||||
for (auto& thread : threads) {
|
||||
thread.join();
|
||||
}
|
||||
return predictions;
|
||||
}
|
||||
@ -261,14 +339,36 @@ namespace bayesnet {
|
||||
if (!fitted) {
|
||||
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<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) {
|
||||
sample.clear();
|
||||
for (int col = 0; col < tsamples.size(); ++col) {
|
||||
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;
|
||||
}
|
||||
@ -286,11 +386,6 @@ namespace bayesnet {
|
||||
// Return 1xn std::vector of probabilities
|
||||
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;
|
||||
for (int i = 0; i < sample.size(); ++i) {
|
||||
evidence[features[i]] = sample[i];
|
||||
@ -300,44 +395,26 @@ namespace bayesnet {
|
||||
// Return 1xn std::vector of probabilities
|
||||
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;
|
||||
for (int i = 0; i < sample.size(0); ++i) {
|
||||
evidence[features[i]] = sample[i].item<int>();
|
||||
}
|
||||
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> result(classNumStates, 0.0);
|
||||
std::vector<std::thread> threads;
|
||||
std::mutex mtx;
|
||||
auto completeEvidence = std::map<std::string, int>(evidence);
|
||||
for (int i = 0; i < classNumStates; ++i) {
|
||||
threads.emplace_back([this, &result, &evidence, i, &mtx]() {
|
||||
auto completeEvidence = std::map<std::string, int>(evidence);
|
||||
completeEvidence[getClassName()] = i;
|
||||
double factor = computeFactor(completeEvidence);
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
result[i] = factor;
|
||||
});
|
||||
}
|
||||
for (auto& thread : threads) {
|
||||
thread.join();
|
||||
completeEvidence[getClassName()] = i;
|
||||
double partial = 1.0;
|
||||
for (auto& node : getNodes()) {
|
||||
partial *= node.second->getFactorValue(completeEvidence);
|
||||
}
|
||||
result[i] = partial;
|
||||
}
|
||||
// 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; });
|
||||
return result;
|
||||
}
|
||||
|
@ -12,14 +12,18 @@
|
||||
#include "Node.h"
|
||||
|
||||
namespace bayesnet {
|
||||
enum class Smoothing_t {
|
||||
NONE = -1,
|
||||
ORIGINAL = 0,
|
||||
LAPLACE,
|
||||
CESTNIK
|
||||
};
|
||||
class Network {
|
||||
public:
|
||||
Network();
|
||||
explicit Network(float);
|
||||
explicit Network(const Network&);
|
||||
~Network() = default;
|
||||
torch::Tensor& getSamples();
|
||||
float getMaxThreads() const;
|
||||
void addNode(const std::string&);
|
||||
void addEdge(const std::string&, const std::string&);
|
||||
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.
|
||||
*/
|
||||
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 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& 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 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, 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, const Smoothing_t smoothing);
|
||||
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_tensor(const torch::Tensor& samples, const bool proba);
|
||||
@ -50,19 +54,16 @@ namespace bayesnet {
|
||||
private:
|
||||
std::map<std::string, std::unique_ptr<Node>> nodes;
|
||||
bool fitted;
|
||||
float maxThreads = 0.95;
|
||||
int classNumStates;
|
||||
std::vector<std::string> features; // Including classname
|
||||
std::string className;
|
||||
double laplaceSmoothing;
|
||||
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>&);
|
||||
std::vector<double> predict_sample(const std::vector<int>&);
|
||||
std::vector<double> predict_sample(const torch::Tensor&);
|
||||
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);
|
||||
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 completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing);
|
||||
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 setStates(const std::map<std::string, std::vector<int>>&);
|
||||
};
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace bayesnet {
|
||||
|
||||
Node::Node(const std::string& name)
|
||||
: name(name), numStates(0), cpTable(torch::Tensor()), parents(std::vector<Node*>()), children(std::vector<Node*>())
|
||||
: name(name)
|
||||
{
|
||||
}
|
||||
void Node::clear()
|
||||
@ -90,52 +90,54 @@ namespace bayesnet {
|
||||
}
|
||||
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();
|
||||
// Get dimensions of the CPT
|
||||
dimensions.push_back(numStates);
|
||||
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
|
||||
cpTable = torch::zeros(dimensions, torch::kFloat) + laplaceSmoothing;
|
||||
cpTable = torch::zeros(dimensions, torch::kDouble) + smoothing;
|
||||
// Fill table with counts
|
||||
auto pos = find(features.begin(), features.end(), name);
|
||||
if (pos == features.end()) {
|
||||
throw std::logic_error("Feature " + name + " not found in dataset");
|
||||
}
|
||||
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) {
|
||||
c10::List<c10::optional<at::Tensor>> coordinates;
|
||||
coordinates.push_back(dataset.index({ name_index, n_sample }));
|
||||
coordinates.clear();
|
||||
auto sample = dataset.index({ "...", n_sample });
|
||||
coordinates.push_back(sample[name_index]);
|
||||
for (auto parent : parents) {
|
||||
pos = find(features.begin(), features.end(), parent->getName());
|
||||
if (pos == features.end()) {
|
||||
throw std::logic_error("Feature parent " + parent->getName() + " not found in dataset");
|
||||
}
|
||||
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
|
||||
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
|
||||
// Divide each row by the sum of the row
|
||||
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;
|
||||
// following predetermined order of indices in the cpTable (see Node.h)
|
||||
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()]); });
|
||||
return cpTable.index({ coordinates }).item<float>();
|
||||
return cpTable.index({ coordinates }).item<double>();
|
||||
}
|
||||
std::vector<std::string> Node::graph(const std::string& className)
|
||||
{
|
||||
auto output = std::vector<std::string>();
|
||||
auto suffix = name == className ? ", fontcolor=red, fillcolor=lightblue, style=filled " : "";
|
||||
output.push_back(name + " [shape=circle" + suffix + "] \n");
|
||||
transform(children.begin(), children.end(), back_inserter(output), [this](const auto& child) { return name + " -> " + child->getName(); });
|
||||
output.push_back("\"" + name + "\" [shape=circle" + suffix + "] \n");
|
||||
transform(children.begin(), children.end(), back_inserter(output), [this](const auto& child) { return "\"" + name + "\" -> \"" + child->getName() + "\""; });
|
||||
return output;
|
||||
}
|
||||
}
|
@ -12,14 +12,6 @@
|
||||
#include <torch/torch.h>
|
||||
namespace bayesnet {
|
||||
class Node {
|
||||
private:
|
||||
std::string name;
|
||||
std::vector<Node*> parents;
|
||||
std::vector<Node*> children;
|
||||
int numStates; // number of states of the variable
|
||||
torch::Tensor cpTable; // Order of indices is 0-> node variable, 1-> 1st parent, 2-> 2nd parent, ...
|
||||
std::vector<int64_t> dimensions; // dimensions of the cpTable
|
||||
std::vector<std::pair<std::string, std::string>> combinations(const std::vector<std::string>&);
|
||||
public:
|
||||
explicit Node(const std::string&);
|
||||
void clear();
|
||||
@ -31,12 +23,20 @@ namespace bayesnet {
|
||||
std::vector<Node*>& getParents();
|
||||
std::vector<Node*>& getChildren();
|
||||
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;
|
||||
void setNumStates(int);
|
||||
unsigned minFill();
|
||||
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:
|
||||
std::string name;
|
||||
std::vector<Node*> parents;
|
||||
std::vector<Node*> children;
|
||||
int numStates = 0; // number of states of the variable
|
||||
torch::Tensor cpTable; // Order of indices is 0-> node variable, 1-> 1st parent, 2-> 2nd parent, ...
|
||||
std::vector<int64_t> dimensions; // dimensions of the cpTable
|
||||
std::vector<std::pair<std::string, std::string>> combinations(const std::vector<std::string>&);
|
||||
};
|
||||
}
|
||||
#endif
|
@ -4,6 +4,9 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ***************************************************************
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <tuple>
|
||||
#include "Mst.h"
|
||||
#include "BayesMetrics.h"
|
||||
namespace bayesnet {
|
||||
@ -27,6 +30,53 @@ namespace bayesnet {
|
||||
}
|
||||
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)
|
||||
{
|
||||
// Return the K Best features
|
||||
@ -66,7 +116,10 @@ namespace bayesnet {
|
||||
{
|
||||
return scoresKBest;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::pair<int, int>, double>> Metrics::getScoresKPairs() const
|
||||
{
|
||||
return scoresKPairs;
|
||||
}
|
||||
torch::Tensor Metrics::conditionalEdge(const torch::Tensor& weights)
|
||||
{
|
||||
auto result = std::vector<double>();
|
||||
@ -105,6 +158,8 @@ namespace bayesnet {
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
// Measured in nats (natural logarithm (log) base e)
|
||||
// Elements of Information Theory, 2nd Edition, Thomas M. Cover, Joy A. Thomas p. 14
|
||||
double Metrics::entropy(const torch::Tensor& feature, const torch::Tensor& weights)
|
||||
{
|
||||
torch::Tensor counts = feature.bincount(weights);
|
||||
@ -143,10 +198,54 @@ namespace bayesnet {
|
||||
}
|
||||
return entropyValue;
|
||||
}
|
||||
// I(X;Y) = H(Y) - H(Y|X)
|
||||
// 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)
|
||||
{
|
||||
// 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));
|
||||
// Convert tensors to vectors for easier processing
|
||||
auto firstFeatureData = firstFeature.accessor<int, 1>();
|
||||
auto secondFeatureData = secondFeature.accessor<int, 1>();
|
||||
auto labelsData = labels.accessor<int, 1>();
|
||||
auto weightsData = weights.accessor<double, 1>();
|
||||
int numSamples = firstFeature.size(0);
|
||||
// Maps for joint and marginal probabilities
|
||||
std::map<std::tuple<int, int, int>, double> jointCount;
|
||||
std::map<std::tuple<int, int>, double> marginalCount;
|
||||
// Compute joint and marginal counts
|
||||
for (int i = 0; i < numSamples; ++i) {
|
||||
auto keyJoint = std::make_tuple(firstFeatureData[i], labelsData[i], secondFeatureData[i]);
|
||||
auto keyMarginal = std::make_tuple(firstFeatureData[i], labelsData[i]);
|
||||
|
||||
jointCount[keyJoint] += weightsData[i];
|
||||
marginalCount[keyMarginal] += weightsData[i];
|
||||
}
|
||||
// Total weight sum
|
||||
double totalWeight = torch::sum(weights).item<double>();
|
||||
if (totalWeight == 0)
|
||||
return 0;
|
||||
// Compute the conditional entropy
|
||||
double conditionalEntropy = 0.0;
|
||||
for (const auto& [keyJoint, jointFreq] : jointCount) {
|
||||
auto [x, c, y] = keyJoint;
|
||||
auto keyMarginal = std::make_tuple(x, c);
|
||||
//double p_xc = marginalCount[keyMarginal] / totalWeight;
|
||||
double p_y_given_xc = jointFreq / marginalCount[keyMarginal];
|
||||
if (p_y_given_xc > 0) {
|
||||
conditionalEntropy -= (jointFreq / totalWeight) * std::log(p_y_given_xc);
|
||||
}
|
||||
}
|
||||
return conditionalEntropy;
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
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(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)
|
||||
{
|
||||
return std::max(conditionalEntropy(firstFeature, labels, weights) - conditionalEntropy(firstFeature, secondFeature, labels, weights), 0.0);
|
||||
}
|
||||
/*
|
||||
Compute the maximum spanning tree considering the weights as distances
|
||||
|
@ -16,20 +16,26 @@ namespace bayesnet {
|
||||
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);
|
||||
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<std::pair<std::pair<int, int>, double>> getScoresKPairs() const;
|
||||
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);
|
||||
torch::Tensor conditionalEdge(const torch::Tensor& weights);
|
||||
std::vector<std::pair<int, int>> maximumSpanningTree(const std::vector<std::string>& features, const torch::Tensor& weights, const int root);
|
||||
// Measured in nats (natural logarithm (log) base e)
|
||||
// Elements of Information Theory, 2nd Edition, Thomas M. Cover, Joy A. Thomas p. 14
|
||||
double entropy(const torch::Tensor& feature, const torch::Tensor& weights);
|
||||
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights);
|
||||
protected:
|
||||
torch::Tensor samples; // n+1xm torch::Tensor used to fit the model where samples[-1] is the y std::vector
|
||||
std::string className;
|
||||
double entropy(const torch::Tensor& feature, const torch::Tensor& weights);
|
||||
std::vector<std::string> features;
|
||||
template <class T>
|
||||
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
|
||||
{
|
||||
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];
|
||||
for (int j = i + 1; j < source.size(); ++j) {
|
||||
result.push_back({ temp, source[j] });
|
||||
@ -48,6 +54,8 @@ namespace bayesnet {
|
||||
int classNumStates = 0;
|
||||
std::vector<double> scoresKBest;
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
46
bayesnet/utils/CountingSemaphore.h
Normal file
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()) {
|
||||
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
|
||||
// replacing unordered_set with list because unordered_set cannot guarantee the order of the elements inserted
|
||||
|
@ -14,6 +14,8 @@ namespace bayesnet {
|
||||
public:
|
||||
MST() = default;
|
||||
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();
|
||||
private:
|
||||
torch::Tensor weights;
|
||||
|
@ -137,7 +137,7 @@
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
option(CODE_COVERAGE_VERBOSE "Verbose information" FALSE)
|
||||
option(CODE_COVERAGE_VERBOSE "Verbose information" TRUE)
|
||||
|
||||
# Check prereqs
|
||||
find_program( GCOV_PATH gcov )
|
||||
@ -160,7 +160,11 @@ foreach(LANG ${LANGUAGES})
|
||||
endif()
|
||||
elseif(NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU"
|
||||
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()
|
||||
endforeach()
|
||||
|
||||
|
@ -1,36 +1,16 @@
|
||||
@startuml
|
||||
title clang-uml class diagram model
|
||||
class "bayesnet::Metrics" as C_0000736965376885623323
|
||||
class C_0000736965376885623323 #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 {
|
||||
class "bayesnet::Node" as C_0010428199432536647474
|
||||
class C_0010428199432536647474 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+Node(const std::string &) : void
|
||||
..
|
||||
+addChild(Node *) : void
|
||||
+addParent(Node *) : 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 &
|
||||
+getChildren() : std::vector<Node *> &
|
||||
+getFactorValue(std::map<std::string,int> &) : float
|
||||
+getFactorValue(std::map<std::string,int> &) : double
|
||||
+getName() const : std::string
|
||||
+getNumStates() const : int
|
||||
+getParents() : std::vector<Node *> &
|
||||
@ -41,24 +21,29 @@ class C_0001303524929067080934 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+setNumStates(int) : void
|
||||
__
|
||||
}
|
||||
class "bayesnet::Network" as C_0001186707649890429575
|
||||
class C_0001186707649890429575 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
enum "bayesnet::Smoothing_t" as C_0013393078277439680282
|
||||
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(float) : void
|
||||
+Network(const Network &) : void
|
||||
+~Network() = default : void
|
||||
..
|
||||
+addEdge(const std::string &, const std::string &) : void
|
||||
+addNode(const std::string &) : void
|
||||
+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 & 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 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 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, 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, const Smoothing_t smoothing) : void
|
||||
+getClassName() const : std::string
|
||||
+getClassNumStates() const : int
|
||||
+getEdges() const : std::vector<std::pair<std::string,std::string>>
|
||||
+getFeatures() const : std::vector<std::string>
|
||||
+getMaxThreads() const : float
|
||||
+getNodes() : std::map<std::string,std::unique_ptr<Node>> &
|
||||
+getNumEdges() const : int
|
||||
+getSamples() : torch::Tensor &
|
||||
@ -76,21 +61,21 @@ class C_0001186707649890429575 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+version() : std::string
|
||||
__
|
||||
}
|
||||
enum "bayesnet::status_t" as C_0000738420730783851375
|
||||
enum C_0000738420730783851375 {
|
||||
enum "bayesnet::status_t" as C_0005907365846270811004
|
||||
enum C_0005907365846270811004 {
|
||||
NORMAL
|
||||
WARNING
|
||||
ERROR
|
||||
}
|
||||
abstract "bayesnet::BaseClassifier" as C_0000327135989451974539
|
||||
abstract C_0000327135989451974539 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
abstract "bayesnet::BaseClassifier" as C_0002617087915615796317
|
||||
abstract C_0002617087915615796317 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+~BaseClassifier() = default : void
|
||||
..
|
||||
{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 & 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 torch::Tensor & weights) = 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(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, 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, 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, const Smoothing_t smoothing) = 0 : BaseClassifier &
|
||||
{abstract} +getClassNumStates() const = 0 : int
|
||||
{abstract} +getNotes() const = 0 : std::vector<std::string>
|
||||
{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} +show() const = 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>
|
||||
}
|
||||
abstract "bayesnet::Classifier" as C_0002043996622900301644
|
||||
abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::Metrics" as C_0005895723015084986588
|
||||
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() = default : void
|
||||
..
|
||||
@ -123,10 +131,10 @@ abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
{abstract} #buildModel(const torch::Tensor & weights) = 0 : void
|
||||
#checkFitParameters() : void
|
||||
+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(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(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 torch::Tensor & weights) : 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, 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 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, const Smoothing_t smoothing) : Classifier &
|
||||
+getClassNumStates() const : int
|
||||
+getNotes() const : std::vector<std::string>
|
||||
+getNumberOfEdges() const : int
|
||||
@ -143,7 +151,7 @@ abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
||||
+show() const : 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
|
||||
#dataset : torch::Tensor
|
||||
@ -157,8 +165,8 @@ __
|
||||
#states : std::map<std::string,std::vector<int>>
|
||||
#status : status_t
|
||||
}
|
||||
class "bayesnet::KDB" as C_0001112865019015250005
|
||||
class C_0001112865019015250005 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::KDB" as C_0008902920152122000044
|
||||
class C_0008902920152122000044 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+KDB(int k, float theta = 0.03) : void
|
||||
+~KDB() = default : void
|
||||
..
|
||||
@ -167,8 +175,26 @@ class C_0001112865019015250005 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
||||
__
|
||||
}
|
||||
class "bayesnet::TAN" as C_0001760994424884323017
|
||||
class C_0001760994424884323017 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::SPODE" as C_0004096182510460307610
|
||||
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() = 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>
|
||||
__
|
||||
}
|
||||
class "bayesnet::Proposal" as C_0002219995589162262979
|
||||
class C_0002219995589162262979 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::Proposal" as C_0017759964713298103839
|
||||
class C_0017759964713298103839 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+Proposal(torch::Tensor & pDataset, std::vector<std::string> & features_, std::string & className_) : void
|
||||
+~Proposal() : void
|
||||
..
|
||||
@ -190,74 +216,42 @@ __
|
||||
#discretizers : map<std::string,mdlp::CPPFImdlp *>
|
||||
#y : torch::Tensor
|
||||
}
|
||||
class "bayesnet::TANLd" as C_0001668829096702037834
|
||||
class C_0001668829096702037834 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+TANLd() : void
|
||||
+~TANLd() = default : void
|
||||
class "bayesnet::KDBLd" as C_0002756018222998454702
|
||||
class C_0002756018222998454702 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+KDBLd(int k) : 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 &
|
||||
+graph(const std::string & name = "TAN") const : std::vector<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, const Smoothing_t smoothing) : KDBLd &
|
||||
+graph(const std::string & name = "KDB") const : std::vector<std::string>
|
||||
+predict(torch::Tensor & X) : torch::Tensor
|
||||
{static} +version() : std::string
|
||||
__
|
||||
}
|
||||
abstract "bayesnet::FeatureSelect" as C_0001695326193250580823
|
||||
abstract C_0001695326193250580823 #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
|
||||
class "bayesnet::SPODELd" as C_0010957245114062042836
|
||||
class C_0010957245114062042836 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+SPODELd(int root) : void
|
||||
+~SPODELd() = default : 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::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
|
||||
+commonFit(const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : 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, const Smoothing_t smoothing) : SPODELd &
|
||||
+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 &
|
||||
+graph(const std::string & name = "SPODELd") const : std::vector<std::string>
|
||||
+predict(torch::Tensor & X) : torch::Tensor
|
||||
{static} +version() : std::string
|
||||
__
|
||||
}
|
||||
class "bayesnet::FCBF" as C_0000144682015341746929
|
||||
class C_0000144682015341746929 #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
|
||||
class "bayesnet::TANLd" as C_0013350632773616302678
|
||||
class C_0013350632773616302678 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+TANLd() : 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 C_0000008268514674428553 #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 {
|
||||
class "bayesnet::Ensemble" as C_0015881931090842884611
|
||||
class C_0015881931090842884611 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+Ensemble(bool predict_voting = true) : 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
|
||||
+show() const : 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
|
||||
__
|
||||
#models : std::vector<std::unique_ptr<Classifier>>
|
||||
@ -288,41 +282,223 @@ __
|
||||
#predict_voting : bool
|
||||
#significanceModels : std::vector<double>
|
||||
}
|
||||
class "bayesnet::(anonymous_45089536)" as C_0001186398587753535158
|
||||
class C_0001186398587753535158 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::A2DE" as C_0001410789567057647859
|
||||
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
|
||||
+FCBF : std::string
|
||||
+IWSS : std::string
|
||||
}
|
||||
class "bayesnet::(anonymous_45090163)" as C_0000602764946063116717
|
||||
class C_0000602764946063116717 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::(anonymous_60343240)" as C_0016227156982041949444
|
||||
class C_0016227156982041949444 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
__
|
||||
+ASC : std::string
|
||||
+DESC : std::string
|
||||
+RAND : std::string
|
||||
}
|
||||
class "bayesnet::BoostAODE" as C_0000358471592399852382
|
||||
class C_0000358471592399852382 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::Boost" as C_0009819322948617116148
|
||||
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() = default : void
|
||||
..
|
||||
#buildModel(const torch::Tensor & weights) : void
|
||||
+graph(const std::string & title = "BoostAODE") const : std::vector<std::string>
|
||||
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
||||
#trainModel(const torch::Tensor & weights) : void
|
||||
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
|
||||
__
|
||||
}
|
||||
class "bayesnet::MST" as C_0000131858426172291700
|
||||
class C_0000131858426172291700 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::CFS" as C_0000093018845530739957
|
||||
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(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>>
|
||||
+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 C_0001197041682001898467 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
class "bayesnet::Graph" as C_0009576333456015187741
|
||||
class C_0009576333456015187741 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+Graph(int V) : 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
|
||||
__
|
||||
}
|
||||
class "bayesnet::KDBLd" as C_0000344502277874806837
|
||||
class C_0000344502277874806837 #aliceblue;line:blue;line.dotted;text:blue {
|
||||
+KDBLd(int k) : 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) : KDBLd &
|
||||
+graph(const std::string & name = "KDB") const : std::vector<std::string>
|
||||
+predict(torch::Tensor & X) : torch::Tensor
|
||||
{static} +version() : std::string
|
||||
__
|
||||
}
|
||||
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
|
||||
C_0010428199432536647474 --> C_0010428199432536647474 : -parents
|
||||
C_0010428199432536647474 --> C_0010428199432536647474 : -children
|
||||
C_0009493661199123436603 ..> C_0013393078277439680282
|
||||
C_0009493661199123436603 o-- C_0010428199432536647474 : -nodes
|
||||
C_0002617087915615796317 ..> C_0013393078277439680282
|
||||
C_0002617087915615796317 ..> C_0005907365846270811004
|
||||
C_0016351972983202413152 ..> C_0013393078277439680282
|
||||
C_0016351972983202413152 o-- C_0009493661199123436603 : #model
|
||||
C_0016351972983202413152 o-- C_0005895723015084986588 : #metrics
|
||||
C_0016351972983202413152 o-- C_0005907365846270811004 : #status
|
||||
C_0002617087915615796317 <|-- C_0016351972983202413152
|
||||
|
||||
'Generated with clang-uml, version 0.5.1
|
||||
'LLVM version clang version 17.0.6 (Fedora 17.0.6-2.fc39)
|
||||
C_0016351972983202413152 <|-- C_0008902920152122000044
|
||||
|
||||
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
|
||||
|
File diff suppressed because one or more lines are too long
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"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"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 -->
|
||||
<svg width="1632pt" height="288pt"
|
||||
viewBox="0.00 0.00 1631.95 287.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)">
|
||||
<svg width="3725pt" height="432pt"
|
||||
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 427.8)">
|
||||
<title>BayesNet</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-283.8 1627.95,-283.8 1627.95,4 -4,4"/>
|
||||
<!-- node1 -->
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-427.8 3720.84,-427.8 3720.84,4 -4,4"/>
|
||||
<!-- node0 -->
|
||||
<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>
|
||||
<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"/>
|
||||
<text text-anchor="middle" x="775.66" y="-257.53" font-family="Times,serif" font-size="12.00">BayesNet</text>
|
||||
<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="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>
|
||||
<!-- node2 -->
|
||||
<g id="node2" class="node">
|
||||
<g id="node3" class="node">
|
||||
<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"/>
|
||||
<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>
|
||||
<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="662.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libc10_cuda.so</text>
|
||||
</g>
|
||||
<!-- node1->node2 -->
|
||||
<g id="edge1" class="edge">
|
||||
<title>node1->node2</title>
|
||||
<path fill="none" stroke="black" d="M724.41,-254.5C634.7,-243.46 447.04,-220.38 324.01,-205.24"/>
|
||||
<polygon fill="black" stroke="black" points="324.77,-201.69 314.42,-203.94 323.92,-208.63 324.77,-201.69"/>
|
||||
<!-- node0->node2 -->
|
||||
<g id="edge2" class="edge">
|
||||
<title>node0->node2</title>
|
||||
<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="767.81,-275.12 757.4,-277.09 766.77,-282.04 767.81,-275.12"/>
|
||||
</g>
|
||||
<!-- node3 -->
|
||||
<g id="node3" class="node">
|
||||
<g id="node4" class="node">
|
||||
<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"/>
|
||||
<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>
|
||||
<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="1125.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libkineto.a</text>
|
||||
</g>
|
||||
<!-- node1->node3 -->
|
||||
<g id="edge2" class="edge">
|
||||
<title>node1->node3</title>
|
||||
<path fill="none" stroke="black" d="M747.56,-245.79C729.21,-235.98 704.97,-223.03 684.63,-212.16"/>
|
||||
<polygon fill="black" stroke="black" points="686.47,-208.64 676,-207.02 683.17,-214.82 686.47,-208.64"/>
|
||||
<!-- node0->node3 -->
|
||||
<g id="edge3" class="edge">
|
||||
<title>node0->node3</title>
|
||||
<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="1189.53,-278.09 1178.95,-278.6 1187.54,-284.8 1189.53,-278.09"/>
|
||||
</g>
|
||||
<!-- 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">
|
||||
<title>node9</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"/>
|
||||
<text text-anchor="middle" x="1032.66" y="-185.53" font-family="Times,serif" font-size="12.00">torch_library</text>
|
||||
<title>node4</title>
|
||||
<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="1454.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/lib64/libcuda.so</text>
|
||||
</g>
|
||||
<!-- node1->node9 -->
|
||||
<!-- node0->node4 -->
|
||||
<g id="edge4" class="edge">
|
||||
<title>node1->node9</title>
|
||||
<path fill="none" stroke="black" d="M815.25,-250.02C860.25,-237.77 933.77,-217.74 982.68,-204.42"/>
|
||||
<polygon fill="black" stroke="black" points="983.3,-207.61 992.02,-201.6 981.46,-200.85 983.3,-207.61"/>
|
||||
</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"/>
|
||||
<title>node0->node4</title>
|
||||
<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="1482.13,-283.99 1472.46,-279.65 1477.31,-289.07 1482.13,-283.99"/>
|
||||
</g>
|
||||
<!-- node5 -->
|
||||
<g id="node7" class="node">
|
||||
<g id="node6" class="node">
|
||||
<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"/>
|
||||
<text text-anchor="middle" x="1274.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch_cpu_library</text>
|
||||
<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="1721.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libcudart.so</text>
|
||||
</g>
|
||||
<!-- node9->node5 -->
|
||||
<g id="edge6" class="edge">
|
||||
<title>node9->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"/>
|
||||
<polygon fill="black" stroke="black" points="1223.46,-136.97 1232.09,-130.83 1221.51,-130.24 1223.46,-136.97"/>
|
||||
<!-- node0->node5 -->
|
||||
<g id="edge5" class="edge">
|
||||
<title>node0->node5</title>
|
||||
<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="1704.43,-290.59 1707.84,-280.56 1698.92,-286.27 1704.43,-290.59"/>
|
||||
</g>
|
||||
<!-- node6 -->
|
||||
<g id="node8" class="node">
|
||||
<g id="node7" class="node">
|
||||
<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"/>
|
||||
<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>
|
||||
<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="2061.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libnvToolsExt.so</text>
|
||||
</g>
|
||||
<!-- node5->node6 -->
|
||||
<g id="edge7" class="edge">
|
||||
<title>node5->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"/>
|
||||
<polygon fill="black" stroke="black" points="902.44,-46.77 891.98,-48.46 901.22,-53.66 902.44,-46.77"/>
|
||||
<!-- node0->node6 -->
|
||||
<g id="edge6" class="edge">
|
||||
<title>node0->node6</title>
|
||||
<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="2003.28,-284.61 2011.79,-278.3 2001.21,-277.92 2003.28,-284.61"/>
|
||||
</g>
|
||||
<!-- node7 -->
|
||||
<g id="node9" class="node">
|
||||
<g id="node8" class="node">
|
||||
<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"/>
|
||||
<text text-anchor="middle" x="1274.66" y="-27.63" font-family="Times,serif" font-size="12.00">caffe2::mkl</text>
|
||||
<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="2395.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libnvrtc.so</text>
|
||||
</g>
|
||||
<!-- node5->node7 -->
|
||||
<g id="edge8" class="edge">
|
||||
<title>node5->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"/>
|
||||
<polygon fill="black" stroke="black" points="1278.16,-61.27 1274.66,-51.27 1271.16,-61.27 1278.16,-61.27"/>
|
||||
<!-- node0->node7 -->
|
||||
<g id="edge7" class="edge">
|
||||
<title>node0->node7</title>
|
||||
<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="2311.47,-281.47 2320.7,-276.26 2310.24,-274.58 2311.47,-281.47"/>
|
||||
</g>
|
||||
<!-- node8 -->
|
||||
<g id="node10" class="node">
|
||||
<g id="node9" class="node">
|
||||
<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"/>
|
||||
<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="1490.66" y="-20.5" font-family="Times,serif" font-size="12.00">(protobuf::libprotobuf)</text>
|
||||
<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="1604.66" y="-329.53" font-family="Times,serif" font-size="12.00">fimdlp</text>
|
||||
</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">
|
||||
<title>node5->node8</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"/>
|
||||
<polygon fill="black" stroke="black" points="1425.01,-61.77 1433.06,-54.89 1422.47,-55.25 1425.01,-61.77"/>
|
||||
<title>node8->node1</title>
|
||||
<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="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>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 18 KiB |
@ -5,7 +5,7 @@
|
||||
The hyperparameters defined in the algorithm are:
|
||||
|
||||
- ***bisection*** (*boolean*): If set to true allows the algorithm to add *k* models at once (as specified in the algorithm) to the ensemble. Default value: *true*.
|
||||
- ***biesection_best*** (*boolean*): If set to *true*, the algorithm will take as *priorAccuracy* the best accuracy computed. If set to *false⁺ it will take the last accuracy as *priorAccuracy*. Default value: *false*.
|
||||
- ***bisection_best*** (*boolean*): If set to *true*, the algorithm will take as *priorAccuracy* the best accuracy computed. If set to *false⁺ it will take the last accuracy as *priorAccuracy*. Default value: *false*.
|
||||
|
||||
- ***order*** (*{"asc", "desc", "rand"}*): Sets the order (ascending/descending/random) in which dataset variables will be processed to choose the parents of the *SPODEs*. Default value: *"desc"*.
|
||||
|
||||
@ -27,4 +27,4 @@ The hyperparameters defined in the algorithm are:
|
||||
|
||||
## Operation
|
||||
|
||||
### [Algorithm](./algorithm.md)
|
||||
### [Base Algorithm](./algorithm.md)
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
docs/logo_small.png
Normal file
BIN
docs/logo_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -1,6 +0,0 @@
|
||||
filter = bayesnet/
|
||||
exclude-directories = build_debug/lib/
|
||||
exclude-directories = build_debug/tests/lib
|
||||
exclude = bayesnet/utils/loguru.*
|
||||
print-summary = yes
|
||||
sort = uncovered-percent
|
@ -1,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryLo">50.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">1</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">_ZN8bayesnet14BaseClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">606</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="BaseClassifier.h.gcov.html#L19">_ZN8bayesnet14BaseClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasLo">0</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="BaseClassifier.h.gcov.html#L19">_ZN8bayesnet14BaseClassifierD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">606</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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryLo">50.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">1</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">_ZN8bayesnet14BaseClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">606</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="BaseClassifier.h.gcov.html#L19">_ZN8bayesnet14BaseClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasLo">0</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="BaseClassifier.h.gcov.html#L19">_ZN8bayesnet14BaseClassifierD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">606</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,121 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryLo">50.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">1</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"> 606 : 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,243 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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#L178">_ZN8bayesnet10Classifier17topological_orderB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">2</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">_ZNK8bayesnet10Classifier8dump_cptB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">2</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">_ZN8bayesnet10Classifier5scoreERSt6vectorIS1_IiSaIiEESaIS3_EERS3_</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">_ZN8bayesnet10Classifier7predictERSt6vectorIS1_IiSaIiEESaIS3_EE</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">_ZNK8bayesnet10Classifier17getNumberOfStatesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">12</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">_ZNK8bayesnet10Classifier4showB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">12</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">_ZN8bayesnet10Classifier18setHyperparametersERKN8nlohmann16json_abi_v3_11_310basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEblmdSaNS2_14adl_serializerES5_IhSaIhEEvEE</a></td>
|
||||
|
||||
<td class="coverFnHi">42</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">_ZN8bayesnet10Classifier5scoreERN2at6TensorES3_</a></td>
|
||||
|
||||
<td class="coverFnHi">56</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">_ZN8bayesnet10Classifier3fitERSt6vectorIS1_IiSaIiEESaIS3_EERS3_RKS1_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISD_EERKSD_RSt3mapISD_S3_St4lessISD_ESaISt4pairISI_S3_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">60</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">_ZN8bayesnet10Classifier3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">64</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">_ZNK8bayesnet10Classifier16getNumberOfEdgesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">94</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">_ZNK8bayesnet10Classifier16getNumberOfNodesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">94</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">_ZN8bayesnet10Classifier13predict_probaERSt6vectorIS1_IiSaIiEESaIS3_EE</a></td>
|
||||
|
||||
<td class="coverFnHi">130</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">_ZN8bayesnet10Classifier12buildDatasetERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">162</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">_ZNK8bayesnet10Classifier17getClassNumStatesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">170</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">_ZN8bayesnet10Classifier3fitERN2at6TensorERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">198</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">_ZN8bayesnet10Classifier3fitERN2at6TensorERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEERKS2_</a></td>
|
||||
|
||||
<td class="coverFnHi">330</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">_ZN8bayesnet10Classifier10trainModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">560</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">_ZN8bayesnet10Classifier8addNodesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">560</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">_ZN8bayesnet10Classifier18checkFitParametersEv</a></td>
|
||||
|
||||
<td class="coverFnHi">644</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">_ZN8bayesnet10Classifier5buildERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EERKS7_RSt3mapIS7_S1_IiSaIiEESt4lessIS7_ESaISt4pairISC_SG_EEERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">644</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">_ZN8bayesnet10Classifier13predict_probaERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">742</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">_ZN8bayesnet10Classifier7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">850</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">_ZN8bayesnet10ClassifierC2ENS_7NetworkE</a></td>
|
||||
|
||||
<td class="coverFnHi">886</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,243 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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#L42">_ZN8bayesnet10Classifier10trainModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">560</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">_ZN8bayesnet10Classifier12buildDatasetERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">162</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">_ZN8bayesnet10Classifier13predict_probaERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">742</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">_ZN8bayesnet10Classifier13predict_probaERSt6vectorIS1_IiSaIiEESaIS3_EE</a></td>
|
||||
|
||||
<td class="coverFnHi">130</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">_ZN8bayesnet10Classifier17topological_orderB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">2</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">_ZN8bayesnet10Classifier18checkFitParametersEv</a></td>
|
||||
|
||||
<td class="coverFnHi">644</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">_ZN8bayesnet10Classifier18setHyperparametersERKN8nlohmann16json_abi_v3_11_310basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEblmdSaNS2_14adl_serializerES5_IhSaIhEEvEE</a></td>
|
||||
|
||||
<td class="coverFnHi">42</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">_ZN8bayesnet10Classifier3fitERN2at6TensorERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">198</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">_ZN8bayesnet10Classifier3fitERN2at6TensorERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEERKS2_</a></td>
|
||||
|
||||
<td class="coverFnHi">330</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">_ZN8bayesnet10Classifier3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">64</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">_ZN8bayesnet10Classifier3fitERSt6vectorIS1_IiSaIiEESaIS3_EERS3_RKS1_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISD_EERKSD_RSt3mapISD_S3_St4lessISD_ESaISt4pairISI_S3_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">60</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">_ZN8bayesnet10Classifier5buildERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EERKS7_RSt3mapIS7_S1_IiSaIiEESt4lessIS7_ESaISt4pairISC_SG_EEERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">644</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">_ZN8bayesnet10Classifier5scoreERN2at6TensorES3_</a></td>
|
||||
|
||||
<td class="coverFnHi">56</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">_ZN8bayesnet10Classifier5scoreERSt6vectorIS1_IiSaIiEESaIS3_EERS3_</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">_ZN8bayesnet10Classifier7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">850</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">_ZN8bayesnet10Classifier7predictERSt6vectorIS1_IiSaIiEESaIS3_EE</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">_ZN8bayesnet10Classifier8addNodesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">560</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">_ZN8bayesnet10ClassifierC2ENS_7NetworkE</a></td>
|
||||
|
||||
<td class="coverFnHi">886</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">_ZNK8bayesnet10Classifier16getNumberOfEdgesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">94</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">_ZNK8bayesnet10Classifier16getNumberOfNodesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">94</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">_ZNK8bayesnet10Classifier17getClassNumStatesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">170</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">_ZNK8bayesnet10Classifier17getNumberOfStatesEv</a></td>
|
||||
|
||||
<td class="coverFnHi">12</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">_ZNK8bayesnet10Classifier4showB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">12</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">_ZNK8bayesnet10Classifier8dump_cptB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">2</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,270 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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"> 886 : 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"> 644 : 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"> 644 : this->features = features;</span></span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 644 : this->className = className;</span></span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 644 : this->states = states;</span></span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 644 : m = dataset.size(1);</span></span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 644 : n = features.size();</span></span>
|
||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 644 : checkFitParameters();</span></span>
|
||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 628 : auto n_classes = states.at(className).size();</span></span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 628 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 628 : model.initialize();</span></span>
|
||||
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 628 : buildModel(weights);</span></span>
|
||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 628 : trainModel(weights);</span></span>
|
||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 620 : fitted = true;</span></span>
|
||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 620 : return *this;</span></span>
|
||||
<span id="L29"><span class="lineNum"> 29</span> : }</span>
|
||||
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 162 : 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"> 162 : 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"> 502 : dataset = torch::cat({ dataset, yresized }, 0);</span></span>
|
||||
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 162 : }</span></span>
|
||||
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 8 : catch (const std::exception& e) {</span></span>
|
||||
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 8 : std::stringstream oss;</span></span>
|
||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 8 : oss << "* Error in X and y dimensions *\n";</span></span>
|
||||
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 8 : oss << "X dimensions: " << dataset.sizes() << "\n";</span></span>
|
||||
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 8 : oss << "y dimensions: " << ytmp.sizes();</span></span>
|
||||
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 8 : throw std::runtime_error(oss.str());</span></span>
|
||||
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 16 : }</span></span>
|
||||
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 324 : }</span></span>
|
||||
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 560 : 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"> 560 : model.fit(dataset, weights, features, className, states);</span></span>
|
||||
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 560 : }</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"> 64 : 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"> 64 : dataset = X;</span></span>
|
||||
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 64 : buildDataset(y);</span></span>
|
||||
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 60 : 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"> 104 : return build(features, className, states, weights);</span></span>
|
||||
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 60 : }</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"> 60 : 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"> 60 : 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"> 418 : for (int i = 0; i < X.size(); ++i) {</span></span>
|
||||
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 1432 : 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"> 60 : auto ytmp = torch::tensor(y, torch::kInt32);</span></span>
|
||||
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 60 : buildDataset(ytmp);</span></span>
|
||||
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 56 : 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"> 104 : return build(features, className, states, weights);</span></span>
|
||||
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 426 : }</span></span>
|
||||
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 198 : 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"> 198 : this->dataset = dataset;</span></span>
|
||||
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 198 : 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"> 396 : return build(features, className, states, weights);</span></span>
|
||||
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 198 : }</span></span>
|
||||
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 330 : 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"> 330 : this->dataset = dataset;</span></span>
|
||||
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 330 : 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"> 644 : 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"> 644 : if (torch::is_floating_point(dataset)) {</span></span>
|
||||
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 4 : 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"> 640 : if (dataset.size(0) - 1 != features.size()) {</span></span>
|
||||
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 4 : 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"> 636 : if (states.find(className) == states.end()) {</span></span>
|
||||
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 4 : 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"> 14208 : for (auto feature : features) {</span></span>
|
||||
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 13580 : if (states.find(feature) == states.end()) {</span></span>
|
||||
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 4 : 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"> 13580 : }</span></span>
|
||||
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 628 : }</span></span>
|
||||
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 850 : 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"> 850 : if (!fitted) {</span></span>
|
||||
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 8 : 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"> 842 : 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"> 8 : 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"> 8 : if (!fitted) {</span></span>
|
||||
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 4 : 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"> 4 : auto m_ = X[0].size();</span></span>
|
||||
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 4 : auto n_ = X.size();</span></span>
|
||||
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 4 : 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"> 20 : for (auto i = 0; i < n_; i++) {</span></span>
|
||||
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 32 : 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"> 4 : auto yp = model.predict(Xd);</span></span>
|
||||
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 8 : return yp;</span></span>
|
||||
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 4 : }</span></span>
|
||||
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 742 : 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"> 742 : if (!fitted) {</span></span>
|
||||
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 4 : 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"> 738 : 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"> 130 : 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"> 130 : if (!fitted) {</span></span>
|
||||
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 4 : 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"> 126 : auto m_ = X[0].size();</span></span>
|
||||
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 126 : auto n_ = X.size();</span></span>
|
||||
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 126 : 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"> 1080 : for (auto i = 0; i < n_; i++) {</span></span>
|
||||
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 1908 : 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"> 126 : auto yp = model.predict_proba(Xd);</span></span>
|
||||
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 252 : return yp;</span></span>
|
||||
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 126 : }</span></span>
|
||||
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 56 : 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"> 56 : torch::Tensor y_pred = predict(X);</span></span>
|
||||
<span id="L142"><span class="lineNum"> 142</span> <span class="tlaGNC"> 104 : return (y_pred == y).sum().item<float>() / y.size(0);</span></span>
|
||||
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 52 : }</span></span>
|
||||
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 8 : 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"> 8 : if (!fitted) {</span></span>
|
||||
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 4 : 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"> 4 : 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"> 12 : 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"> 12 : 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"> 560 : 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"> 13216 : for (const auto& feature : features) {</span></span>
|
||||
<span id="L159"><span class="lineNum"> 159</span> <span class="tlaGNC"> 12656 : 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"> 560 : model.addNode(className);</span></span>
|
||||
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 560 : }</span></span>
|
||||
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 94 : 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"> 94 : 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"> 94 : 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"> 94 : 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"> 12 : 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"> 12 : 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"> 170 : 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"> 170 : 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"> 2 : 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"> 2 : 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"> 2 : 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"> 2 : 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"> 42 : 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"> 42 : if (!hyperparameters.empty()) {</span></span>
|
||||
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 4 : 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"> 38 : }</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,117 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryMed">80.0 %</td>
|
||||
<td class="headerCovTableEntry">5</td>
|
||||
<td class="headerCovTableEntry">4</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">_ZN8bayesnet10Classifier10getVersionB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">16</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">_ZNK8bayesnet10Classifier8getNotesB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">38</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">_ZNK8bayesnet10Classifier9getStatusEv</a></td>
|
||||
|
||||
<td class="coverFnHi">64</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">_ZN8bayesnet10ClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">606</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Classifier.h.gcov.html#L16">_ZN8bayesnet10ClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasLo">0</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Classifier.h.gcov.html#L16">_ZN8bayesnet10ClassifierD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">606</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,117 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryMed">80.0 %</td>
|
||||
<td class="headerCovTableEntry">5</td>
|
||||
<td class="headerCovTableEntry">4</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#L31">_ZN8bayesnet10Classifier10getVersionB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">16</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">_ZN8bayesnet10ClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">606</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Classifier.h.gcov.html#L16">_ZN8bayesnet10ClassifierD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasLo">0</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Classifier.h.gcov.html#L16">_ZN8bayesnet10ClassifierD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">606</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">_ZNK8bayesnet10Classifier8getNotesB5cxx11Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">38</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">_ZNK8bayesnet10Classifier9getStatusEv</a></td>
|
||||
|
||||
<td class="coverFnHi">64</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,141 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryMed">80.0 %</td>
|
||||
<td class="headerCovTableEntry">5</td>
|
||||
<td class="headerCovTableEntry">4</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"> 606 : 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"> 64 : status_t getStatus() const override { return status; }</span></span>
|
||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 48 : 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"> 38 : 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,110 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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">_ZNK8bayesnet3KDB5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">_ZN8bayesnet3KDB18setHyperparametersERKN8nlohmann16json_abi_v3_11_310basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEblmdSaNS2_14adl_serializerES5_IhSaIhEEvEE</a></td>
|
||||
|
||||
<td class="coverFnHi">6</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">_ZN8bayesnet3KDB10buildModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">26</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">_ZN8bayesnet3KDBC2Eif</a></td>
|
||||
|
||||
<td class="coverFnHi">74</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">_ZN8bayesnet3KDB11add_m_edgesEiRSt6vectorIiSaIiEERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">172</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,110 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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#L26">_ZN8bayesnet3KDB10buildModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">26</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">_ZN8bayesnet3KDB11add_m_edgesEiRSt6vectorIiSaIiEERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">172</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">_ZN8bayesnet3KDB18setHyperparametersERKN8nlohmann16json_abi_v3_11_310basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEblmdSaNS2_14adl_serializerES5_IhSaIhEEvEE</a></td>
|
||||
|
||||
<td class="coverFnHi">6</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">_ZN8bayesnet3KDBC2Eif</a></td>
|
||||
|
||||
<td class="coverFnHi">74</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">_ZNK8bayesnet3KDB5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">4</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,187 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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"> 74 : 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"> 222 : 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"> 222 : }</span></span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 6 : 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"> 6 : auto hyperparameters = hyperparameters_;</span></span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 6 : if (hyperparameters.contains("k")) {</span></span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 2 : k = hyperparameters["k"];</span></span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 2 : 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"> 6 : if (hyperparameters.contains("theta")) {</span></span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 2 : theta = hyperparameters["theta"];</span></span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 2 : 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"> 6 : Classifier::setHyperparameters(hyperparameters);</span></span>
|
||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 6 : }</span></span>
|
||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 26 : 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"> 26 : addNodes();</span></span>
|
||||
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 78 : const torch::Tensor& y = dataset.index({ -1, "..." });</span></span>
|
||||
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 26 : std::vector<double> mi;</span></span>
|
||||
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 198 : for (auto i = 0; i < features.size(); i++) {</span></span>
|
||||
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 516 : torch::Tensor firstFeature = dataset.index({ i, "..." });</span></span>
|
||||
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 172 : mi.push_back(metrics.mutualInformation(firstFeature, y, weights));</span></span>
|
||||
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 172 : }</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"> 26 : 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"> 26 : 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"> 26 : auto order = argsort(mi);</span></span>
|
||||
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 198 : 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"> 172 : 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"> 172 : 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"> 172 : 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"> 224 : }</span></span>
|
||||
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 172 : 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"> 172 : auto n_edges = std::min(k, static_cast<int>(S.size()));</span></span>
|
||||
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 172 : auto cond_w = clone(weights);</span></span>
|
||||
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 172 : bool exit_cond = k == 0;</span></span>
|
||||
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 172 : int num = 0;</span></span>
|
||||
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 502 : while (!exit_cond) {</span></span>
|
||||
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 1320 : auto max_minfo = argmax(cond_w.index({ idx, "..." })).item<int>();</span></span>
|
||||
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 330 : auto belongs = find(S.begin(), S.end(), max_minfo) != S.end();</span></span>
|
||||
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 882 : 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"> 160 : model.addEdge(features[max_minfo], features[idx]);</span></span>
|
||||
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 160 : 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"> 1320 : cond_w.index_put_({ idx, max_minfo }, -1);</span></span>
|
||||
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 990 : auto candidates_mask = cond_w.index({ idx, "..." }).gt(theta);</span></span>
|
||||
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 330 : auto candidates = candidates_mask.nonzero();</span></span>
|
||||
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 330 : exit_cond = num == n_edges || candidates.size(0) == 0;</span></span>
|
||||
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 330 : }</span></span>
|
||||
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 1346 : }</span></span>
|
||||
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 4 : 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"> 4 : std::string header{ title };</span></span>
|
||||
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 4 : if (title == "KDB") {</span></span>
|
||||
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 4 : 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"> 8 : return model.graph(header);</span></span>
|
||||
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 4 : }</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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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">_ZN8bayesnet3KDBD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">22</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDB.h.gcov.html#L20">_ZN8bayesnet3KDBD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDB.h.gcov.html#L20">_ZN8bayesnet3KDBD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">18</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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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">_ZN8bayesnet3KDBD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">22</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDB.h.gcov.html#L20">_ZN8bayesnet3KDBD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDB.h.gcov.html#L20">_ZN8bayesnet3KDBD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">18</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,103 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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"> 22 : 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,103 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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">_ZNK8bayesnet5KDBLd5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">2</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">_ZN8bayesnet5KDBLd7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">_ZN8bayesnet5KDBLd3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">10</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">_ZN8bayesnet5KDBLdC2Ei</a></td>
|
||||
|
||||
<td class="coverFnHi">34</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,103 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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#L9">_ZN8bayesnet5KDBLd3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">10</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">_ZN8bayesnet5KDBLd7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">_ZN8bayesnet5KDBLdC2Ei</a></td>
|
||||
|
||||
<td class="coverFnHi">34</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">_ZNK8bayesnet5KDBLd5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">2</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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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"> 34 : KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}</span></span>
|
||||
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 10 : 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"> 10 : checkInput(X_, y_);</span></span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 10 : features = features_;</span></span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 10 : className = className_;</span></span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 10 : Xf = X_;</span></span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 10 : 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"> 10 : 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"> 10 : KDB::fit(dataset, features, className, states);</span></span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 10 : states = localDiscretizationProposal(states, model);</span></span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 10 : return *this;</span></span>
|
||||
<span id="L25"><span class="lineNum"> 25</span> : }</span>
|
||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 8 : 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"> 8 : auto Xt = prepareX(X);</span></span>
|
||||
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 16 : return KDB::predict(Xt);</span></span>
|
||||
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 8 : }</span></span>
|
||||
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 2 : 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"> 2 : 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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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">_ZN8bayesnet5KDBLdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">10</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDBLd.h.gcov.html#L15">_ZN8bayesnet5KDBLdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDBLd.h.gcov.html#L15">_ZN8bayesnet5KDBLdD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">6</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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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">_ZN8bayesnet5KDBLdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">10</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDBLd.h.gcov.html#L15">_ZN8bayesnet5KDBLdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="KDBLd.h.gcov.html#L15">_ZN8bayesnet5KDBLdD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">6</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,100 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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"> 10 : 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,145 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryMed">88.9 %</td>
|
||||
<td class="headerCovTableEntry">9</td>
|
||||
<td class="headerCovTableEntry">8</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">_ZN8bayesnet8Proposal8prepareXERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">84</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">_ZN8bayesnet8ProposalD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">100</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Proposal.cc.gcov.html#L10">_ZN8bayesnet8ProposalD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasLo">0</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Proposal.cc.gcov.html#L10">_ZN8bayesnet8ProposalD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">100</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">_ZN8bayesnet8Proposal27localDiscretizationProposalERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIiSaIiEESt4lessIS7_ESaISt4pairIKS7_SA_EEERNS_7NetworkE</a></td>
|
||||
|
||||
<td class="coverFnHi">106</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">_ZN8bayesnet8Proposal10checkInputERKN2at6TensorES4_</a></td>
|
||||
|
||||
<td class="coverFnHi">114</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">_ZN8bayesnet8Proposal24fit_local_discretizationB5cxx11ERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">116</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">_ZN8bayesnet8ProposalC2ERN2at6TensorERSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERSA_</a></td>
|
||||
|
||||
<td class="coverFnHi">212</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">_ZZN8bayesnet8Proposal27localDiscretizationProposalERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIiSaIiEESt4lessIS7_ESaISt4pairIKS7_SA_EEERNS_7NetworkEENKUlRKT_E0_clIS7_EEDaSO_</a></td>
|
||||
|
||||
<td class="coverFnHi">686</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">_ZZN8bayesnet8Proposal27localDiscretizationProposalERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIiSaIiEESt4lessIS7_ESaISt4pairIKS7_SA_EEERNS_7NetworkEENKUlRKT_E_clIPNS_4NodeEEEDaSO_</a></td>
|
||||
|
||||
<td class="coverFnHi">1348</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,145 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryMed">88.9 %</td>
|
||||
<td class="headerCovTableEntry">9</td>
|
||||
<td class="headerCovTableEntry">8</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#L16">_ZN8bayesnet8Proposal10checkInputERKN2at6TensorES4_</a></td>
|
||||
|
||||
<td class="coverFnHi">114</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">_ZN8bayesnet8Proposal24fit_local_discretizationB5cxx11ERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">116</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">_ZN8bayesnet8Proposal27localDiscretizationProposalERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIiSaIiEESt4lessIS7_ESaISt4pairIKS7_SA_EEERNS_7NetworkE</a></td>
|
||||
|
||||
<td class="coverFnHi">106</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">_ZN8bayesnet8Proposal8prepareXERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">84</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">_ZN8bayesnet8ProposalC2ERN2at6TensorERSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERSA_</a></td>
|
||||
|
||||
<td class="coverFnHi">212</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">_ZN8bayesnet8ProposalD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">100</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Proposal.cc.gcov.html#L10">_ZN8bayesnet8ProposalD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasLo">0</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="Proposal.cc.gcov.html#L10">_ZN8bayesnet8ProposalD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">100</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">_ZZN8bayesnet8Proposal27localDiscretizationProposalERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIiSaIiEESt4lessIS7_ESaISt4pairIKS7_SA_EEERNS_7NetworkEENKUlRKT_E0_clIS7_EEDaSO_</a></td>
|
||||
|
||||
<td class="coverFnHi">686</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">_ZZN8bayesnet8Proposal27localDiscretizationProposalERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIiSaIiEESt4lessIS7_ESaISt4pairIKS7_SA_EEERNS_7NetworkEENKUlRKT_E_clIPNS_4NodeEEEDaSO_</a></td>
|
||||
|
||||
<td class="coverFnHi">1348</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,192 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryMed">88.9 %</td>
|
||||
<td class="headerCovTableEntry">9</td>
|
||||
<td class="headerCovTableEntry">8</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"> 212 : 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"> 100 : Proposal::~Proposal()</span></span>
|
||||
<span id="L13"><span class="lineNum"> 13</span> : {</span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 948 : for (auto& [key, value] : discretizers) {</span></span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 848 : delete value;</span></span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> : }</span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 100 : }</span></span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 114 : 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"> 114 : 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"> 114 : 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"> 114 : }</span></span>
|
||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 106 : 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"> 106 : auto order = model.topological_sort();</span></span>
|
||||
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 106 : auto& nodes = model.getNodes();</span></span>
|
||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 106 : map<std::string, std::vector<int>> states = oldStates;</span></span>
|
||||
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 106 : std::vector<int> indicesToReDiscretize;</span></span>
|
||||
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 106 : 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"> 888 : for (auto feature : order) {</span></span>
|
||||
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 782 : auto nodeParents = nodes[feature]->getParents();</span></span>
|
||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 782 : if (nodeParents.size() < 2) continue; // Only has class as parent</span></span>
|
||||
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 662 : upgrade = true;</span></span>
|
||||
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 662 : int index = find(pFeatures.begin(), pFeatures.end(), feature) - pFeatures.begin();</span></span>
|
||||
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 662 : indicesToReDiscretize.push_back(index); // We need to re-discretize this feature</span></span>
|
||||
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 662 : std::vector<std::string> parents;</span></span>
|
||||
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 2010 : 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"> 662 : 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"> 662 : std::vector<int> indices;</span></span>
|
||||
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 662 : indices.push_back(-1); // Add class index</span></span>
|
||||
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 1348 : 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"> 662 : std::vector<std::string> yJoinParents(Xf.size(1));</span></span>
|
||||
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 2010 : for (auto idx : indices) {</span></span>
|
||||
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 479320 : for (int i = 0; i < Xf.size(1); ++i) {</span></span>
|
||||
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 1433916 : 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"> 662 : auto arff = ArffFiles();</span></span>
|
||||
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 662 : auto yxv = arff.factorize(yJoinParents);</span></span>
|
||||
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 1324 : auto xvf_ptr = Xf.index({ index }).data_ptr<float>();</span></span>
|
||||
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 662 : 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"> 662 : discretizers[feature]->fit(xvf, yxv);</span></span>
|
||||
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 902 : }</span></span>
|
||||
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 106 : 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"> 768 : for (auto index : indicesToReDiscretize) {</span></span>
|
||||
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 1324 : auto Xt_ptr = Xf.index({ index }).data_ptr<float>();</span></span>
|
||||
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 662 : 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"> 2648 : pDataset.index_put_({ index, "..." }, torch::tensor(discretizers[pFeatures[index]]->transform(Xt)));</span></span>
|
||||
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 662 : auto xStates = std::vector<int>(discretizers[pFeatures[index]]->getCutPoints().size() + 1);</span></span>
|
||||
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 662 : 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"> 662 : states[pFeatures[index]] = xStates;</span></span>
|
||||
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 662 : }</span></span>
|
||||
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 106 : 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"> 106 : model.fit(pDataset, weights, pFeatures, pClassName, states);</span></span>
|
||||
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 106 : }</span></span>
|
||||
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 212 : return states;</span></span>
|
||||
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 480064 : }</span></span>
|
||||
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 116 : 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"> 116 : int m = Xf.size(1);</span></span>
|
||||
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 116 : int n = Xf.size(0);</span></span>
|
||||
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 116 : map<std::string, std::vector<int>> states;</span></span>
|
||||
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 116 : pDataset = torch::zeros({ n + 1, m }, torch::kInt32);</span></span>
|
||||
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 116 : 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"> 972 : for (auto i = 0; i < pFeatures.size(); ++i) {</span></span>
|
||||
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 856 : auto* discretizer = new mdlp::CPPFImdlp();</span></span>
|
||||
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 1712 : auto Xt_ptr = Xf.index({ i }).data_ptr<float>();</span></span>
|
||||
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 856 : 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"> 856 : discretizer->fit(Xt, yv);</span></span>
|
||||
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 3424 : pDataset.index_put_({ i, "..." }, torch::tensor(discretizer->transform(Xt)));</span></span>
|
||||
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 856 : auto xStates = std::vector<int>(discretizer->getCutPoints().size() + 1);</span></span>
|
||||
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 856 : iota(xStates.begin(), xStates.end(), 0);</span></span>
|
||||
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 856 : states[pFeatures[i]] = xStates;</span></span>
|
||||
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 856 : discretizers[pFeatures[i]] = discretizer;</span></span>
|
||||
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 856 : }</span></span>
|
||||
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 116 : int n_classes = torch::max(y).item<int>() + 1;</span></span>
|
||||
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 116 : auto yStates = std::vector<int>(n_classes);</span></span>
|
||||
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 116 : iota(yStates.begin(), yStates.end(), 0);</span></span>
|
||||
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 116 : states[pClassName] = yStates;</span></span>
|
||||
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 348 : pDataset.index_put_({ n, "..." }, y);</span></span>
|
||||
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 232 : return states;</span></span>
|
||||
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 1944 : }</span></span>
|
||||
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 84 : 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"> 84 : auto Xtd = torch::zeros_like(X, torch::kInt32);</span></span>
|
||||
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 688 : for (int i = 0; i < X.size(0); ++i) {</span></span>
|
||||
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 604 : 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"> 604 : auto Xd = discretizers[pFeatures[i]]->transform(Xt);</span></span>
|
||||
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 1812 : Xtd.index_put_({ i }, torch::tensor(Xd, torch::kInt32));</span></span>
|
||||
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 604 : }</span></span>
|
||||
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 84 : return Xtd;</span></span>
|
||||
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 604 : }</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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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">_ZNK8bayesnet5SPODE5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">34</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">_ZN8bayesnet5SPODE10buildModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">508</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">_ZN8bayesnet5SPODEC2Ei</a></td>
|
||||
|
||||
<td class="coverFnHi">562</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,96 +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 - coverage.info - BayesNet/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">top level</a> - <a href="index.html">BayesNet/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">coverage.info</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-04-30 13:17:26</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><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#L11">_ZN8bayesnet5SPODE10buildModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">508</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">_ZN8bayesnet5SPODEC2Ei</a></td>
|
||||
|
||||
<td class="coverFnHi">562</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">_ZNK8bayesnet5SPODE5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">34</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,107 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODE.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODE.cc<span style="font-size: 80%;"> (source / <a href="SPODE.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">coverage.info</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-04-30 13:17:26</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><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 "SPODE.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>
|
||||
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 562 : SPODE::SPODE(int root) : Classifier(Network()), root(root) {}</span></span>
|
||||
<span id="L12"><span class="lineNum"> 12</span> : </span>
|
||||
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 508 : void SPODE::buildModel(const torch::Tensor& weights)</span></span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> : {</span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> : // 0. Add all nodes to the model</span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 508 : addNodes();</span></span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> : // 1. Add edges from the class node to all other nodes</span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> : // 2. Add edges from the root node to all other nodes</span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 12840 : for (int i = 0; i < static_cast<int>(features.size()); ++i) {</span></span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 12332 : model.addEdge(className, features[i]);</span></span>
|
||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 12332 : if (i != root) {</span></span>
|
||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 11824 : model.addEdge(features[root], features[i]);</span></span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> : }</span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> : }</span>
|
||||
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 508 : }</span></span>
|
||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 34 : std::vector<std::string> SPODE::graph(const std::string& name) const</span></span>
|
||||
<span id="L27"><span class="lineNum"> 27</span> : {</span>
|
||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 34 : return model.graph(name);</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> : }</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,96 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODE.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODE.h<span style="font-size: 80%;"> (<a href="SPODE.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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.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="SPODE.h.gcov.html#L17">_ZN8bayesnet5SPODED0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">918</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODE.h.gcov.html#L17">_ZN8bayesnet5SPODED0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">418</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODE.h.gcov.html#L17">_ZN8bayesnet5SPODED2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">500</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,96 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODE.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODE.h<span style="font-size: 80%;"> (<a href="SPODE.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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.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="SPODE.h.gcov.html#L17">_ZN8bayesnet5SPODED0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">918</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODE.h.gcov.html#L17">_ZN8bayesnet5SPODED0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">418</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODE.h.gcov.html#L17">_ZN8bayesnet5SPODED2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">500</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,99 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODE.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODE.h<span style="font-size: 80%;"> (source / <a href="SPODE.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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 SPODE_H</span>
|
||||
<span id="L8"><span class="lineNum"> 8</span> : #define SPODE_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> : class SPODE : public Classifier {</span>
|
||||
<span id="L13"><span class="lineNum"> 13</span> : private:</span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> : int root;</span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> : protected:</span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> : void buildModel(const torch::Tensor& weights) override;</span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> : public:</span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> : explicit SPODE(int root);</span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC tlaBgGNC"> 918 : virtual ~SPODE() = default;</span></span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> : std::vector<std::string> graph(const std::string& name = "SPODE") const override;</span>
|
||||
<span id="L21"><span class="lineNum"> 21</span> : };</span>
|
||||
<span id="L22"><span class="lineNum"> 22</span> : }</span>
|
||||
<span id="L23"><span class="lineNum"> 23</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,117 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODELd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODELd.cc<span style="font-size: 80%;"> (<a href="SPODELd.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">coverage.info</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Lines:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">26</td>
|
||||
<td class="headerCovTableEntry">26</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="headerItem">Test Date:</td>
|
||||
<td class="headerValue">2024-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">6</td>
|
||||
<td class="headerCovTableEntry">6</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="SPODELd.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="SPODELd.cc.gcov.html#L17">_ZN8bayesnet7SPODELd3fitERN2at6TensorERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L44">_ZNK8bayesnet7SPODELd5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">18</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L39">_ZN8bayesnet7SPODELd7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">68</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L9">_ZN8bayesnet7SPODELd3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">84</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L27">_ZN8bayesnet7SPODELd9commonFitERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EERKS7_RSt3mapIS7_S1_IiSaIiEESt4lessIS7_ESaISt4pairISC_SG_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">86</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L8">_ZN8bayesnet7SPODELdC2Ei</a></td>
|
||||
|
||||
<td class="coverFnHi">110</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,117 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODELd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODELd.cc<span style="font-size: 80%;"> (<a href="SPODELd.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">coverage.info</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Lines:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">26</td>
|
||||
<td class="headerCovTableEntry">26</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="headerItem">Test Date:</td>
|
||||
<td class="headerValue">2024-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">6</td>
|
||||
<td class="headerCovTableEntry">6</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="SPODELd.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="SPODELd.cc.gcov.html#L17">_ZN8bayesnet7SPODELd3fitERN2at6TensorERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L9">_ZN8bayesnet7SPODELd3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">84</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L39">_ZN8bayesnet7SPODELd7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">68</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L27">_ZN8bayesnet7SPODELd9commonFitERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EERKS7_RSt3mapIS7_S1_IiSaIiEESt4lessIS7_ESaISt4pairISC_SG_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">86</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L8">_ZN8bayesnet7SPODELdC2Ei</a></td>
|
||||
|
||||
<td class="coverFnHi">110</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L44">_ZNK8bayesnet7SPODELd5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">18</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,126 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODELd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODELd.cc<span style="font-size: 80%;"> (source / <a href="SPODELd.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">coverage.info</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Lines:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">26</td>
|
||||
<td class="headerCovTableEntry">26</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="headerItem">Test Date:</td>
|
||||
<td class="headerValue">2024-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">6</td>
|
||||
<td class="headerCovTableEntry">6</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 "SPODELd.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"> 110 : SPODELd::SPODELd(int root) : SPODE(root), Proposal(dataset, features, className) {}</span></span>
|
||||
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 84 : 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_)</span></span>
|
||||
<span id="L12"><span class="lineNum"> 12</span> : {</span>
|
||||
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 84 : checkInput(X_, y_);</span></span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 84 : Xf = X_;</span></span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 84 : y = y_;</span></span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 84 : return commonFit(features_, className_, states_);</span></span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> : }</span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> : </span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 4 : SPODELd& SPODELd::fit(torch::Tensor& dataset, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)</span></span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> : {</span>
|
||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 4 : if (!torch::is_floating_point(dataset)) {</span></span>
|
||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 2 : throw std::runtime_error("Dataset must be a floating point tensor");</span></span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> : }</span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 8 : Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();</span></span>
|
||||
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 6 : y = dataset.index({ -1, "..." }).clone().to(torch::kInt32);</span></span>
|
||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 2 : return commonFit(features_, className_, states_);</span></span>
|
||||
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 6 : }</span></span>
|
||||
<span id="L28"><span class="lineNum"> 28</span> : </span>
|
||||
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 86 : SPODELd& SPODELd::commonFit(const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)</span></span>
|
||||
<span id="L30"><span class="lineNum"> 30</span> : {</span>
|
||||
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 86 : features = features_;</span></span>
|
||||
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 86 : className = className_;</span></span>
|
||||
<span id="L33"><span class="lineNum"> 33</span> : // Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y</span>
|
||||
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 86 : states = fit_local_discretization(y);</span></span>
|
||||
<span id="L35"><span class="lineNum"> 35</span> : // We have discretized the input data</span>
|
||||
<span id="L36"><span class="lineNum"> 36</span> : // 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network</span>
|
||||
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 86 : SPODE::fit(dataset, features, className, states);</span></span>
|
||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 86 : states = localDiscretizationProposal(states, model);</span></span>
|
||||
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 86 : return *this;</span></span>
|
||||
<span id="L40"><span class="lineNum"> 40</span> : }</span>
|
||||
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 68 : torch::Tensor SPODELd::predict(torch::Tensor& X)</span></span>
|
||||
<span id="L42"><span class="lineNum"> 42</span> : {</span>
|
||||
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 68 : auto Xt = prepareX(X);</span></span>
|
||||
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 136 : return SPODE::predict(Xt);</span></span>
|
||||
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 68 : }</span></span>
|
||||
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 18 : std::vector<std::string> SPODELd::graph(const std::string& name) const</span></span>
|
||||
<span id="L47"><span class="lineNum"> 47</span> : {</span>
|
||||
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 18 : return SPODE::graph(name);</span></span>
|
||||
<span id="L49"><span class="lineNum"> 49</span> : }</span>
|
||||
<span id="L50"><span class="lineNum"> 50</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,96 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODELd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODELd.h<span style="font-size: 80%;"> (<a href="SPODELd.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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="SPODELd.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="SPODELd.h.gcov.html#L14">_ZN8bayesnet7SPODELdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">160</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODELd.h.gcov.html#L14">_ZN8bayesnet7SPODELdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">78</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODELd.h.gcov.html#L14">_ZN8bayesnet7SPODELdD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">82</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,96 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODELd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODELd.h<span style="font-size: 80%;"> (<a href="SPODELd.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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="SPODELd.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="SPODELd.h.gcov.html#L14">_ZN8bayesnet7SPODELdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">160</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODELd.h.gcov.html#L14">_ZN8bayesnet7SPODELdD0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">78</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="SPODELd.h.gcov.html#L14">_ZN8bayesnet7SPODELdD2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">82</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,101 +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 - coverage.info - BayesNet/bayesnet/classifiers/SPODELd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - SPODELd.h<span style="font-size: 80%;"> (source / <a href="SPODELd.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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 SPODELD_H</span>
|
||||
<span id="L8"><span class="lineNum"> 8</span> : #define SPODELD_H</span>
|
||||
<span id="L9"><span class="lineNum"> 9</span> : #include "SPODE.h"</span>
|
||||
<span id="L10"><span class="lineNum"> 10</span> : #include "Proposal.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 SPODELd : public SPODE, public Proposal {</span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> : explicit SPODELd(int root);</span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC tlaBgGNC"> 160 : virtual ~SPODELd() = default;</span></span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> : 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;</span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> : SPODELd& fit(torch::Tensor& dataset, 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> : SPODELd& commonFit(const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states);</span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> : std::vector<std::string> graph(const std::string& name = "SPODE") const override;</span>
|
||||
<span id="L21"><span class="lineNum"> 21</span> : torch::Tensor predict(torch::Tensor& X) override;</span>
|
||||
<span id="L22"><span class="lineNum"> 22</span> : static inline std::string version() { return "0.0.1"; };</span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> : };</span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> : }</span>
|
||||
<span id="L25"><span class="lineNum"> 25</span> : #endif // !SPODELD_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,103 +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 - coverage.info - BayesNet/bayesnet/classifiers/TAN.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TAN.cc<span style="font-size: 80%;"> (<a href="TAN.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">coverage.info</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Lines:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">23</td>
|
||||
<td class="headerCovTableEntry">23</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="headerItem">Test Date:</td>
|
||||
<td class="headerValue">2024-04-30 13:17:26</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><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="TAN.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="TAN.cc.gcov.html#L39">_ZNK8bayesnet3TAN5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TAN.cc.gcov.html#L10">_ZN8bayesnet3TAN10buildModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">26</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TAN.cc.gcov.html#L8">_ZN8bayesnet3TANC2Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">94</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TAN.cc.gcov.html#L23">_ZZN8bayesnet3TAN10buildModelERKN2at6TensorEENKUlRKT_RKT0_E_clISt4pairIifESE_EEDaS7_SA_</a></td>
|
||||
|
||||
<td class="coverFnHi">324</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,103 +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 - coverage.info - BayesNet/bayesnet/classifiers/TAN.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TAN.cc<span style="font-size: 80%;"> (<a href="TAN.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">coverage.info</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Lines:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">23</td>
|
||||
<td class="headerCovTableEntry">23</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="headerItem">Test Date:</td>
|
||||
<td class="headerValue">2024-04-30 13:17:26</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><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="TAN.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="TAN.cc.gcov.html#L10">_ZN8bayesnet3TAN10buildModelERKN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">26</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TAN.cc.gcov.html#L8">_ZN8bayesnet3TANC2Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">94</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TAN.cc.gcov.html#L39">_ZNK8bayesnet3TAN5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">4</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TAN.cc.gcov.html#L23">_ZZN8bayesnet3TAN10buildModelERKN2at6TensorEENKUlRKT_RKT0_E_clISt4pairIifESE_EEDaS7_SA_</a></td>
|
||||
|
||||
<td class="coverFnHi">324</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,121 +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 - coverage.info - BayesNet/bayesnet/classifiers/TAN.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TAN.cc<span style="font-size: 80%;"> (source / <a href="TAN.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">coverage.info</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Lines:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">23</td>
|
||||
<td class="headerCovTableEntry">23</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="headerItem">Test Date:</td>
|
||||
<td class="headerValue">2024-04-30 13:17:26</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><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 "TAN.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"> 94 : TAN::TAN() : Classifier(Network()) {}</span></span>
|
||||
<span id="L11"><span class="lineNum"> 11</span> : </span>
|
||||
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 26 : void TAN::buildModel(const torch::Tensor& weights)</span></span>
|
||||
<span id="L13"><span class="lineNum"> 13</span> : {</span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> : // 0. Add all nodes to the model</span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 26 : addNodes();</span></span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> : // 1. Compute mutual information between each feature and the class and set the root node</span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> : // as the highest mutual information with the class</span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 26 : auto mi = std::vector <std::pair<int, float >>();</span></span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 78 : torch::Tensor class_dataset = dataset.index({ -1, "..." });</span></span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 178 : for (int i = 0; i < static_cast<int>(features.size()); ++i) {</span></span>
|
||||
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 456 : torch::Tensor feature_dataset = dataset.index({ i, "..." });</span></span>
|
||||
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 152 : auto mi_value = metrics.mutualInformation(class_dataset, feature_dataset, weights);</span></span>
|
||||
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 152 : mi.push_back({ i, mi_value });</span></span>
|
||||
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 152 : }</span></span>
|
||||
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 350 : sort(mi.begin(), mi.end(), [](const auto& left, const auto& right) {return left.second < right.second;});</span></span>
|
||||
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 26 : auto root = mi[mi.size() - 1].first;</span></span>
|
||||
<span id="L27"><span class="lineNum"> 27</span> : // 2. Compute mutual information between each feature and the class</span>
|
||||
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 26 : auto weights_matrix = metrics.conditionalEdge(weights);</span></span>
|
||||
<span id="L29"><span class="lineNum"> 29</span> : // 3. Compute the maximum spanning tree</span>
|
||||
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 26 : auto mst = metrics.maximumSpanningTree(features, weights_matrix, root);</span></span>
|
||||
<span id="L31"><span class="lineNum"> 31</span> : // 4. Add edges from the maximum spanning tree to the model</span>
|
||||
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 152 : for (auto i = 0; i < mst.size(); ++i) {</span></span>
|
||||
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 126 : auto [from, to] = mst[i];</span></span>
|
||||
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 126 : model.addEdge(features[from], features[to]);</span></span>
|
||||
<span id="L35"><span class="lineNum"> 35</span> : }</span>
|
||||
<span id="L36"><span class="lineNum"> 36</span> : // 5. Add edges from the class to all features</span>
|
||||
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 178 : for (auto feature : features) {</span></span>
|
||||
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 152 : model.addEdge(className, feature);</span></span>
|
||||
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 152 : }</span></span>
|
||||
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 204 : }</span></span>
|
||||
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 4 : std::vector<std::string> TAN::graph(const std::string& title) const</span></span>
|
||||
<span id="L42"><span class="lineNum"> 42</span> : {</span>
|
||||
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 4 : return model.graph(title);</span></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,96 +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 - coverage.info - BayesNet/bayesnet/classifiers/TAN.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TAN.h<span style="font-size: 80%;"> (<a href="TAN.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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="TAN.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="TAN.h.gcov.html#L15">_ZN8bayesnet3TAND0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">38</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="TAN.h.gcov.html#L15">_ZN8bayesnet3TAND0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">6</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="TAN.h.gcov.html#L15">_ZN8bayesnet3TAND2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">32</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,96 +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 - coverage.info - BayesNet/bayesnet/classifiers/TAN.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TAN.h<span style="font-size: 80%;"> (<a href="TAN.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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="TAN.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="TAN.h.gcov.html#L15">_ZN8bayesnet3TAND0Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">38</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="TAN.h.gcov.html#L15">_ZN8bayesnet3TAND0Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">6</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFnAlias"><a href="TAN.h.gcov.html#L15">_ZN8bayesnet3TAND2Ev</a></td>
|
||||
|
||||
<td class="coverFnAliasHi">32</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,97 +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 - coverage.info - BayesNet/bayesnet/classifiers/TAN.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TAN.h<span style="font-size: 80%;"> (source / <a href="TAN.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">coverage.info</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-04-30 13:17:26</td>
|
||||
<td></td>
|
||||
<td class="headerItem">Functions:</td>
|
||||
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||
<td class="headerCovTableEntry">2</td>
|
||||
<td class="headerCovTableEntry">2</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 TAN_H</span>
|
||||
<span id="L8"><span class="lineNum"> 8</span> : #define TAN_H</span>
|
||||
<span id="L9"><span class="lineNum"> 9</span> : #include "Classifier.h"</span>
|
||||
<span id="L10"><span class="lineNum"> 10</span> : namespace bayesnet {</span>
|
||||
<span id="L11"><span class="lineNum"> 11</span> : class TAN : public Classifier {</span>
|
||||
<span id="L12"><span class="lineNum"> 12</span> : private:</span>
|
||||
<span id="L13"><span class="lineNum"> 13</span> : protected:</span>
|
||||
<span id="L14"><span class="lineNum"> 14</span> : void buildModel(const torch::Tensor& weights) override;</span>
|
||||
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
|
||||
<span id="L16"><span class="lineNum"> 16</span> : TAN();</span>
|
||||
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 38 : virtual ~TAN() = default;</span></span>
|
||||
<span id="L18"><span class="lineNum"> 18</span> : std::vector<std::string> graph(const std::string& name = "TAN") const override;</span>
|
||||
<span id="L19"><span class="lineNum"> 19</span> : };</span>
|
||||
<span id="L20"><span class="lineNum"> 20</span> : }</span>
|
||||
<span id="L21"><span class="lineNum"> 21</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,103 +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 - coverage.info - BayesNet/bayesnet/classifiers/TANLd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TANLd.cc<span style="font-size: 80%;"> (<a href="TANLd.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">coverage.info</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-04-30 13:17:26</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><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="TANLd.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="TANLd.cc.gcov.html#L30">_ZNK8bayesnet5TANLd5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">2</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TANLd.cc.gcov.html#L25">_ZN8bayesnet5TANLd7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TANLd.cc.gcov.html#L9">_ZN8bayesnet5TANLd3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">10</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TANLd.cc.gcov.html#L8">_ZN8bayesnet5TANLdC2Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">34</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,103 +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 - coverage.info - BayesNet/bayesnet/classifiers/TANLd.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">top level</a> - <a href="index.html">BayesNet/bayesnet/classifiers</a> - TANLd.cc<span style="font-size: 80%;"> (<a href="TANLd.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">coverage.info</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-04-30 13:17:26</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><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="TANLd.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="TANLd.cc.gcov.html#L9">_ZN8bayesnet5TANLd3fitERN2at6TensorES3_RKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKSA_RSt3mapISA_S4_IiSaIiEESt4lessISA_ESaISt4pairISF_SJ_EEE</a></td>
|
||||
|
||||
<td class="coverFnHi">10</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TANLd.cc.gcov.html#L25">_ZN8bayesnet5TANLd7predictERN2at6TensorE</a></td>
|
||||
|
||||
<td class="coverFnHi">8</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TANLd.cc.gcov.html#L8">_ZN8bayesnet5TANLdC2Ev</a></td>
|
||||
|
||||
<td class="coverFnHi">34</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="coverFn"><a href="TANLd.cc.gcov.html#L30">_ZNK8bayesnet5TANLd5graphERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE</a></td>
|
||||
|
||||
<td class="coverFnHi">2</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>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user