Compare commits
102 Commits
baode_prob
...
AnDE
Author | SHA1 | Date | |
---|---|---|---|
0e24135d46
|
|||
521bfd2a8e
|
|||
e2e0fb0c40
|
|||
56b62a67cc
|
|||
c0fc107abb
|
|||
d8c44b3b7c
|
|||
6ab7cd2cbd
|
|||
b578ea8a2d
|
|||
9a752d15dc
|
|||
4992685e94
|
|||
346b693c79
|
|||
164c8bd90c
|
|||
ced29a2c2e
|
|||
0ec53f405f
|
|||
f806015b29
|
|||
8115f25c06
|
|||
618a1e539c
|
|||
7aeffba740
|
|||
e79ea63afb | |||
3c7382a93a
|
|||
b4a222b100
|
|||
23ef0cc5f7
|
|||
793b2d3cd5
|
|||
ae469b8146
|
|||
f014928411
|
|||
c4b563a339
|
|||
49bb0582e6
|
|||
b4c5261e01 | |||
b956aa3873
|
|||
1f06631f69
|
|||
6dd589bd61
|
|||
6475f10825
|
|||
7d906b24d1 | |||
464fe029ea
|
|||
09a1369122
|
|||
503ad687dc
|
|||
8eeaa1beee
|
|||
a2de1c9522
|
|||
cf9b5716ac
|
|||
1326891d6a
|
|||
da2a969686
|
|||
f9553a38d7
|
|||
8b6121eaf2
|
|||
fbbed8ad68
|
|||
a1178554ff
|
|||
d12a779bd9 | |||
a8fc29e2b2
|
|||
50543e7929
|
|||
9014649a0d
|
|||
0d6a081d01
|
|||
46cb8d30eb
|
|||
cb26ef2562
|
|||
df45fddd45
|
|||
a1f9086780
|
|||
e55365c41c
|
|||
de23303801
|
|||
56b5158ff3
|
|||
a5a29eb66f
|
|||
d5eba5710a
|
|||
8c61840d81
|
|||
bc0b938cfc
|
|||
58d5a35a35
|
|||
45c048f635
|
|||
6e854dfda3
|
|||
5826702fc7
|
|||
42e2be3263
|
|||
827b0dd893
|
|||
882d905a28
|
|||
422129802a
|
|||
eb97a5a14b
|
|||
eb72f13bf0
|
|||
5db168d87b
|
|||
8f3bb47cfd
|
|||
1986d05c34
|
|||
7c98ba9bea
|
|||
538af0253b
|
|||
0b65e34772
|
|||
635ef22520
|
|||
1231f4522a | |||
cc34f79b91
|
|||
6899033806
|
|||
8e2d05e663
|
|||
eba2095718
|
|||
199ffc95d2
|
|||
cbe15e317d
|
|||
debd890519
|
|||
46e929ff4d | |||
d858e26e4b
|
|||
0ee3eaed53
|
|||
093c197f0a
|
|||
78d7ea7c4d
|
|||
d6af1ffe8e
|
|||
20669dd161
|
|||
272dbad4f3
|
|||
8bccc3e4bc
|
|||
903b143338
|
|||
f10d0daf2e
|
|||
d39a17089e
|
|||
2e325cd114 | |||
fc3d63b7db
|
|||
43dc79a345
|
|||
b8589bcd0a |
@@ -5,11 +5,12 @@ Checks: '-*,
|
|||||||
cppcoreguidelines-*,
|
cppcoreguidelines-*,
|
||||||
modernize-*,
|
modernize-*,
|
||||||
performance-*,
|
performance-*,
|
||||||
|
-modernize-use-nodiscard,
|
||||||
-cppcoreguidelines-pro-type-vararg,
|
-cppcoreguidelines-pro-type-vararg,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-bugprone-exception-escape'
|
-bugprone-exception-escape'
|
||||||
|
|
||||||
HeaderFilterRegex: 'src/*'
|
HeaderFilterRegex: 'bayesnet/*'
|
||||||
AnalyzeTemporaryDtors: false
|
AnalyzeTemporaryDtors: false
|
||||||
WarningsAsErrors: ''
|
WarningsAsErrors: ''
|
||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
|
39
.clang-uml
Normal file
39
.clang-uml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
compilation_database_dir: build_debug
|
||||||
|
output_directory: diagrams
|
||||||
|
diagrams:
|
||||||
|
BayesNet:
|
||||||
|
type: class
|
||||||
|
glob:
|
||||||
|
- bayesnet/*.h
|
||||||
|
- bayesnet/classifiers/*.h
|
||||||
|
- bayesnet/classifiers/*.cc
|
||||||
|
- bayesnet/ensembles/*.h
|
||||||
|
- bayesnet/ensembles/*.cc
|
||||||
|
- bayesnet/feature_selection/*.h
|
||||||
|
- bayesnet/feature_selection/*.cc
|
||||||
|
- bayesnet/network/*.h
|
||||||
|
- bayesnet/network/*.cc
|
||||||
|
- bayesnet/utils/*.h
|
||||||
|
- bayesnet/utils/*.cc
|
||||||
|
include:
|
||||||
|
# Only include entities from the following namespaces
|
||||||
|
namespaces:
|
||||||
|
- bayesnet
|
||||||
|
exclude:
|
||||||
|
access:
|
||||||
|
- private
|
||||||
|
plantuml:
|
||||||
|
style:
|
||||||
|
# Apply this style to all classes in the diagram
|
||||||
|
class: "#aliceblue;line:blue;line.dotted;text:blue"
|
||||||
|
# Apply this style to all packages in the diagram
|
||||||
|
package: "#back:grey"
|
||||||
|
# Make all template instantiation relations point upwards and draw them
|
||||||
|
# as green and dotted lines
|
||||||
|
instantiation: "up[#green,dotted]"
|
||||||
|
cmd: "/usr/bin/plantuml -tsvg \"diagrams/{}.puml\""
|
||||||
|
before:
|
||||||
|
- 'title clang-uml class diagram model'
|
||||||
|
mermaid:
|
||||||
|
before:
|
||||||
|
- 'classDiagram'
|
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.22.2"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -38,3 +38,6 @@ cmake-build*/**
|
|||||||
.idea
|
.idea
|
||||||
puml/**
|
puml/**
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
sample/build
|
||||||
|
**/.DS_Store
|
||||||
|
|
||||||
|
10
.gitmodules
vendored
10
.gitmodules
vendored
@@ -3,11 +3,6 @@
|
|||||||
url = https://github.com/rmontanana/mdlp
|
url = https://github.com/rmontanana/mdlp
|
||||||
main = main
|
main = main
|
||||||
update = merge
|
update = merge
|
||||||
[submodule "lib/catch2"]
|
|
||||||
path = lib/catch2
|
|
||||||
main = v2.x
|
|
||||||
update = merge
|
|
||||||
url = https://github.com/catchorg/Catch2.git
|
|
||||||
[submodule "lib/json"]
|
[submodule "lib/json"]
|
||||||
path = lib/json
|
path = lib/json
|
||||||
url = https://github.com/nlohmann/json.git
|
url = https://github.com/nlohmann/json.git
|
||||||
@@ -18,3 +13,8 @@
|
|||||||
url = https://github.com/rmontanana/folding
|
url = https://github.com/rmontanana/folding
|
||||||
main = main
|
main = main
|
||||||
update = merge
|
update = merge
|
||||||
|
[submodule "tests/lib/catch2"]
|
||||||
|
path = tests/lib/catch2
|
||||||
|
url = https://github.com/catchorg/Catch2.git
|
||||||
|
main = main
|
||||||
|
update = merge
|
||||||
|
4
.sonarlint/connectedMode.json
Normal file
4
.sonarlint/connectedMode.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"sonarCloudOrganization": "rmontanana",
|
||||||
|
"projectKey": "rmontanana_BayesNet"
|
||||||
|
}
|
38
.vscode/c_cpp_properties.json
vendored
38
.vscode/c_cpp_properties.json
vendored
@@ -3,15 +3,47 @@
|
|||||||
{
|
{
|
||||||
"name": "Mac",
|
"name": "Mac",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/**"
|
"/Users/rmontanana/Code/BayesNet/**"
|
||||||
],
|
],
|
||||||
"defines": [],
|
"defines": [],
|
||||||
"macFrameworkPath": [
|
"macFrameworkPath": [
|
||||||
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
|
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||||
],
|
],
|
||||||
"cStandard": "c17",
|
"cStandard": "c17",
|
||||||
"cppStandard": "c++17",
|
"cppStandard": "c++17",
|
||||||
"compileCommands": "${workspaceFolder}/cmake-build-release/compile_commands.json"
|
"compileCommands": "",
|
||||||
|
"intelliSenseMode": "macos-clang-arm64",
|
||||||
|
"mergeConfigurations": false,
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"/Users/rmontanana/Code/BayesNet/**",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true
|
||||||
|
},
|
||||||
|
"configurationProvider": "ms-vscode.cmake-tools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"/home/rmontanana/Code/BayesNet/**",
|
||||||
|
"/home/rmontanana/Code/libtorch/include/torch/csrc/api/include/",
|
||||||
|
"/home/rmontanana/Code/BayesNet/lib/"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64",
|
||||||
|
"mergeConfigurations": false,
|
||||||
|
"compilerPath": "/usr/bin/g++",
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"/home/rmontanana/Code/BayesNet/**",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true
|
||||||
|
},
|
||||||
|
"configurationProvider": "ms-vscode.cmake-tools"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
126
.vscode/launch.json
vendored
126
.vscode/launch.json
vendored
@@ -5,126 +5,44 @@
|
|||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "sample",
|
"name": "sample",
|
||||||
"program": "${workspaceFolder}/build_debug/sample/BayesNetSample",
|
"program": "${workspaceFolder}/build_release/sample/bayesnet_sample",
|
||||||
"args": [
|
"args": [
|
||||||
"-d",
|
"${workspaceFolder}/tests/data/glass.arff"
|
||||||
"iris",
|
]
|
||||||
"-m",
|
|
||||||
"TANLd",
|
|
||||||
"-s",
|
|
||||||
"271",
|
|
||||||
"-p",
|
|
||||||
"/Users/rmontanana/Code/discretizbench/datasets/",
|
|
||||||
],
|
|
||||||
//"cwd": "${workspaceFolder}/build/sample/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "experimentPy",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/Platform/b_main",
|
|
||||||
"args": [
|
|
||||||
"-m",
|
|
||||||
"STree",
|
|
||||||
"--stratified",
|
|
||||||
"-d",
|
|
||||||
"iris",
|
|
||||||
//"--discretize"
|
|
||||||
// "--hyperparameters",
|
|
||||||
// "{\"repeatSparent\": true, \"maxModels\": 12}"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "gridsearch",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/Platform/b_grid",
|
|
||||||
"args": [
|
|
||||||
"-m",
|
|
||||||
"KDB",
|
|
||||||
"--discretize",
|
|
||||||
"--continue",
|
|
||||||
"glass",
|
|
||||||
"--only",
|
|
||||||
"--compute"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "experimentBayes",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/Platform/b_main",
|
|
||||||
"args": [
|
|
||||||
"-m",
|
|
||||||
"TAN",
|
|
||||||
"--stratified",
|
|
||||||
"--discretize",
|
|
||||||
"-d",
|
|
||||||
"iris",
|
|
||||||
"--hyperparameters",
|
|
||||||
"{\"repeatSparent\": true, \"maxModels\": 12}"
|
|
||||||
],
|
|
||||||
"cwd": "/home/rmontanana/Code/discretizbench",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "best",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/Platform/b_best",
|
|
||||||
"args": [
|
|
||||||
"-m",
|
|
||||||
"BoostAODE",
|
|
||||||
"-s",
|
|
||||||
"accuracy",
|
|
||||||
"--build",
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "manage",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/Platform/b_manage",
|
|
||||||
"args": [
|
|
||||||
"-n",
|
|
||||||
"20"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "list",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/Platform/b_list",
|
|
||||||
"args": [],
|
|
||||||
//"cwd": "/Users/rmontanana/Code/discretizbench",
|
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"program": "${workspaceFolder}/build_debug/tests/unit_tests_bayesnet",
|
"program": "${workspaceFolder}/build_debug/tests/TestBayesNet",
|
||||||
"args": [
|
"args": [
|
||||||
//"-c=\"Metrics Test\"",
|
"[Node]"
|
||||||
// "-s",
|
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceFolder}/build_debug/tests",
|
"cwd": "${workspaceFolder}/build_debug/tests"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Build & debug active file",
|
"name": "(gdb) Launch",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/build_debug/bayesnet",
|
"program": "enter program name, for example ${workspaceFolder}/a.out",
|
||||||
"args": [],
|
"args": [],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${fileDirname}",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"MIMode": "lldb",
|
"MIMode": "gdb",
|
||||||
"preLaunchTask": "CMake: build"
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
61
CHANGELOG.md
61
CHANGELOG.md
@@ -9,6 +9,67 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
- A2DE & SPnDE tests.
|
||||||
|
- Add tests to reach 99% of coverage.
|
||||||
|
- Add tests to check the correct version of the mdlp, folding and json libraries.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
|
||||||
|
## [1.0.5] 2024-04-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Install command and instructions in README.md
|
||||||
|
- Prefix to install command to install the package in the any location.
|
||||||
|
- The 'block_update' hyperparameter to the BoostAODE class, to control the way weights/significances are updated. Default value is false.
|
||||||
|
- Html report of coverage in the coverage folder. It is created with *make viewcoverage*
|
||||||
|
- Badges of coverage and code quality (codacy) in README.md. Coverage badge is updated with *make viewcoverage*
|
||||||
|
- Tests to reach 97% of coverage.
|
||||||
|
- Copyright header to source files.
|
||||||
|
- Diagrams to README.md: UML class diagram & dependency diagram
|
||||||
|
- Action to create diagrams to Makefile: *make diagrams*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Sample app now is a separate target in the Makefile and shows how to use the library with a sample dataset
|
||||||
|
- The worse model count in BoostAODE is reset to 0 every time a new model produces better accuracy, so the tolerance of the model is meant to be the number of **consecutive** models that produce worse accuracy.
|
||||||
|
- Default hyperparameter values in BoostAODE: bisection is true, maxTolerance is 3, convergence is true
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- The 'predict_single' hyperparameter from the BoostAODE class.
|
||||||
|
- The 'repeatSparent' hyperparameter from the BoostAODE class.
|
||||||
|
|
||||||
|
## [1.0.4] 2024-03-06
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Change *ascending* hyperparameter to *order* with these possible values *{"asc", "desc", "rand"}*, Default is *"desc"*.
|
||||||
|
- Add the *predict_single* hyperparameter to control if only the last model created is used to predict in boost training or the whole ensemble (all the models built so far). Default is true.
|
||||||
|
- sample app to show how to use the library (make sample)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Change the library structure adding folders for each group of classes (classifiers, ensembles, etc).
|
||||||
|
- The significances of the models generated under the feature selection algorithm are now computed after all the models have been generated and an α<sub>t</sub> value is computed and assigned to each model.
|
||||||
|
|
||||||
|
## [1.0.3] 2024-02-25
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
- Voting / probability aggregation in Ensemble classes
|
- Voting / probability aggregation in Ensemble classes
|
||||||
- predict_proba method in Classifier
|
- predict_proba method in Classifier
|
||||||
- predict_proba method in BoostAODE
|
- predict_proba method in BoostAODE
|
||||||
|
5
CMakeGraphVizOptions.cmake
Normal file
5
CMakeGraphVizOptions.cmake
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Set the default graph title
|
||||||
|
set(GRAPHVIZ_GRAPH_NAME "BayesNet dependency graph")
|
||||||
|
|
||||||
|
set(GRAPHVIZ_SHARED_LIBS OFF)
|
||||||
|
set(GRAPHVIZ_STATIC_LIBS ON)
|
@@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(BayesNet
|
project(BayesNet
|
||||||
VERSION 1.0.3
|
VERSION 1.0.5.1
|
||||||
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
||||||
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
@@ -25,22 +25,32 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors -fno-default-inline")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
# -------
|
# -------
|
||||||
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
||||||
option(ENABLE_TESTING "Unit testing build" OFF)
|
option(ENABLE_TESTING "Unit testing build" OFF)
|
||||||
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
||||||
|
option(INSTALL_GTEST "Enable installation of googletest." OFF)
|
||||||
|
|
||||||
# CMakes modules
|
# CMakes modules
|
||||||
# --------------
|
# --------------
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||||
include(AddGitSubmodule)
|
include(AddGitSubmodule)
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
MESSAGE("Debug mode")
|
||||||
|
set(ENABLE_TESTING ON)
|
||||||
|
set(CODE_COVERAGE ON)
|
||||||
|
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
|
||||||
|
|
||||||
if (CODE_COVERAGE)
|
if (CODE_COVERAGE)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
include(CodeCoverage)
|
include(CodeCoverage)
|
||||||
MESSAGE("Code coverage enabled")
|
MESSAGE("Code coverage enabled")
|
||||||
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O0 -g")
|
|
||||||
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||||
endif (CODE_COVERAGE)
|
endif (CODE_COVERAGE)
|
||||||
|
|
||||||
@@ -51,22 +61,29 @@ endif (ENABLE_CLANG_TIDY)
|
|||||||
# External libraries - dependencies of BayesNet
|
# External libraries - dependencies of BayesNet
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
# include(FetchContent)
|
# include(FetchContent)
|
||||||
add_git_submodule("lib/mdlp")
|
|
||||||
add_git_submodule("lib/json")
|
add_git_submodule("lib/json")
|
||||||
|
add_git_submodule("lib/mdlp")
|
||||||
|
add_subdirectory("lib/Files")
|
||||||
|
|
||||||
# Subdirectories
|
# Subdirectories
|
||||||
# --------------
|
# --------------
|
||||||
add_subdirectory(config)
|
add_subdirectory(config)
|
||||||
add_subdirectory(lib/Files)
|
add_subdirectory(bayesnet)
|
||||||
add_subdirectory(src)
|
|
||||||
|
|
||||||
file(GLOB BayesNet_SOURCES CONFIGURE_DEPENDS ${BayesNet_SOURCE_DIR}/src/*.cc)
|
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
# -------
|
# -------
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
MESSAGE("Testing enabled")
|
MESSAGE("Testing enabled")
|
||||||
add_git_submodule("lib/catch2")
|
add_subdirectory(tests/lib/catch2)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif (ENABLE_TESTING)
|
endif (ENABLE_TESTING)
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
# ------------
|
||||||
|
install(TARGETS BayesNet
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
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)
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2023 Ricardo Montañana Gómez
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
82
Makefile
82
Makefile
@@ -1,11 +1,17 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
.PHONY: coverage setup help buildr buildd test clean debug release
|
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge
|
||||||
|
|
||||||
f_release = build_release
|
f_release = build_Release
|
||||||
f_debug = build_debug
|
f_debug = build_Debug
|
||||||
|
f_diagrams = diagrams
|
||||||
app_targets = BayesNet
|
app_targets = BayesNet
|
||||||
test_targets = unit_tests_bayesnet
|
test_targets = TestBayesNet
|
||||||
|
clang-uml = clang-uml
|
||||||
|
plantuml = plantuml
|
||||||
|
lcov = lcov
|
||||||
|
genhtml = genhtml
|
||||||
|
dot = dot
|
||||||
n_procs = -j 16
|
n_procs = -j 16
|
||||||
|
|
||||||
define ClearTests
|
define ClearTests
|
||||||
@@ -29,12 +35,23 @@ setup: ## Install dependencies for tests and coverage
|
|||||||
fi
|
fi
|
||||||
@if [ "$(shell uname)" = "Linux" ]; then \
|
@if [ "$(shell uname)" = "Linux" ]; then \
|
||||||
pip install gcovr; \
|
pip install gcovr; \
|
||||||
|
sudo dnf install lcov;\
|
||||||
fi
|
fi
|
||||||
|
@echo "* You should install plantuml & graphviz for the diagrams"
|
||||||
|
|
||||||
dependency: ## Create a dependency graph diagram of the project (build/dependency.png)
|
diagrams: ## Create an UML class diagram & depnendency 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)
|
||||||
|
@export PLANTUML_LIMIT_SIZE=16384
|
||||||
|
@echo ">>> Creating UML class diagram of the project...";
|
||||||
|
@$(clang-uml) -p
|
||||||
|
@cd $(f_diagrams); \
|
||||||
|
$(plantuml) -tsvg BayesNet.puml
|
||||||
@echo ">>> Creating dependency graph diagram of the project...";
|
@echo ">>> Creating dependency graph diagram of the project...";
|
||||||
$(MAKE) debug
|
$(MAKE) debug
|
||||||
cd $(f_debug) && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png
|
cd $(f_debug) && cmake .. --graphviz=dependency.dot
|
||||||
|
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
|
||||||
|
|
||||||
buildd: ## Build the debug targets
|
buildd: ## Build the debug targets
|
||||||
cmake --build $(f_debug) -t $(app_targets) $(n_procs)
|
cmake --build $(f_debug) -t $(app_targets) $(n_procs)
|
||||||
@@ -47,6 +64,17 @@ clean: ## Clean the tests info
|
|||||||
$(call ClearTests)
|
$(call ClearTests)
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
uninstall: ## Uninstall library
|
||||||
|
@echo ">>> Uninstalling BayesNet...";
|
||||||
|
xargs rm < $(f_release)/install_manifest.txt
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
prefix = "/usr/local"
|
||||||
|
install: ## Install library
|
||||||
|
@echo ">>> Installing BayesNet...";
|
||||||
|
@cmake --install $(f_release) --prefix $(prefix)
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
debug: ## Build a debug version of the project
|
debug: ## Build a debug version of the project
|
||||||
@echo ">>> Building Debug BayesNet...";
|
@echo ">>> Building Debug BayesNet...";
|
||||||
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
||||||
@@ -61,25 +89,61 @@ release: ## Build a Release version of the project
|
|||||||
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
|
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
fname = "tests/data/iris.arff"
|
||||||
|
sample: ## Build sample
|
||||||
|
@echo ">>> Building Sample...";
|
||||||
|
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
||||||
|
@cd sample && cmake -B build -S . && cmake --build build -t bayesnet_sample
|
||||||
|
sample/build/bayesnet_sample $(fname)
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
opt = ""
|
opt = ""
|
||||||
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
||||||
@echo ">>> Running BayesNet & Platform tests...";
|
@echo ">>> Running BayesNet tests...";
|
||||||
@$(MAKE) clean
|
@$(MAKE) clean
|
||||||
@cmake --build $(f_debug) -t $(test_targets) $(n_procs)
|
@cmake --build $(f_debug) -t $(test_targets) $(n_procs)
|
||||||
@for t in $(test_targets); do \
|
@for t in $(test_targets); do \
|
||||||
|
echo ">>> Running $$t...";\
|
||||||
if [ -f $(f_debug)/tests/$$t ]; then \
|
if [ -f $(f_debug)/tests/$$t ]; then \
|
||||||
cd $(f_debug)/tests ; \
|
cd $(f_debug)/tests ; \
|
||||||
./$$t $(opt) ; \
|
./$$t $(opt) ; \
|
||||||
|
cd ../.. ; \
|
||||||
fi ; \
|
fi ; \
|
||||||
done
|
done
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
coverage: ## Run tests and generate coverage report (build/index.html)
|
coverage: ## Run tests and generate coverage report (build/index.html)
|
||||||
@echo ">>> Building tests with coverage..."
|
@echo ">>> Building tests with coverage..."
|
||||||
@$(MAKE) test
|
@which $(lcov) || (echo ">>> Please install lcov"; exit 1)
|
||||||
@gcovr $(f_debug)/tests
|
@if [ ! -f $(f_debug)/tests/coverage.info ] ; then $(MAKE) test ; fi
|
||||||
|
@echo ">>> Building report..."
|
||||||
|
@cd $(f_debug)/tests; \
|
||||||
|
$(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; \
|
||||||
|
$(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";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
viewcoverage: ## View the html coverage report
|
||||||
|
@which $(genhtml) || (echo ">>> Please install lcov (genhtml not found)"; exit 1)
|
||||||
|
@$(genhtml) $(f_debug)/tests/coverage.info --demangle-cpp --output-directory html --title "BayesNet Coverage Report" -s -k -f --legend >/dev/null 2>&1;
|
||||||
|
@xdg-open html/index.html || open html/index.html 2>/dev/null
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
updatebadge: ## Update the coverage badge in README.md
|
||||||
|
@which python || (echo ">>> Please install python"; exit 1)
|
||||||
|
@if [ ! -f $(f_debug)/tests/coverage.info ]; then \
|
||||||
|
echo ">>> No coverage.info file found. Run make coverage first!"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@echo ">>> Updating coverage badge..."
|
||||||
|
@env python update_coverage.py $(f_debug)/tests
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
help: ## Show help message
|
help: ## Show help message
|
||||||
@IFS=$$'\n' ; \
|
@IFS=$$'\n' ; \
|
||||||
|
82
README.md
82
README.md
@@ -1,14 +1,39 @@
|
|||||||
# BayesNet
|
# <img src="logo.png" alt="logo" width="50"/> BayesNet
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|

|
||||||
|
[](<https://opensource.org/licenses/MIT>)
|
||||||
|

|
||||||
|
[](https://app.codacy.com/gh/Doctorado-ML/BayesNet/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||||
|
[](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
|
||||||
|
[](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
|
||||||
|

|
||||||
|
[](html/index.html)
|
||||||
|
|
||||||
Bayesian Network Classifiers using libtorch from scratch
|
Bayesian Network Classifiers using libtorch from scratch
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
The only external dependency is [libtorch](https://pytorch.org/cppdocs/installing.html) which can be installed with the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
|
||||||
|
unzip libtorch-shared-with-deps-latest.zips
|
||||||
|
```
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
### Getting the code
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone --recurse-submodules https://github.com/doctorado-ml/bayesnet
|
||||||
|
```
|
||||||
|
|
||||||
### Release
|
### Release
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make release
|
make release
|
||||||
make buildr
|
make buildr
|
||||||
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debug & Tests
|
### Debug & Tests
|
||||||
@@ -16,7 +41,56 @@ make buildr
|
|||||||
```bash
|
```bash
|
||||||
make debug
|
make debug
|
||||||
make test
|
make test
|
||||||
make coverage
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 1. Introduction
|
### Coverage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make coverage
|
||||||
|
make viewcoverage
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sample app
|
||||||
|
|
||||||
|
After building and installing the release version, you can run the sample app with the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make sample
|
||||||
|
make sample fname=tests/data/glass.arff
|
||||||
|
```
|
||||||
|
|
||||||
|
## Models
|
||||||
|
|
||||||
|
#### - TAN
|
||||||
|
|
||||||
|
#### - KDB
|
||||||
|
|
||||||
|
#### - SPODE
|
||||||
|
|
||||||
|
#### - AODE
|
||||||
|
|
||||||
|
#### - [BoostAODE](docs/BoostAODE.md)
|
||||||
|
|
||||||
|
### With Local Discretization
|
||||||
|
|
||||||
|
#### - TANLd
|
||||||
|
|
||||||
|
#### - KDBLd
|
||||||
|
|
||||||
|
#### - SPODELd
|
||||||
|
|
||||||
|
#### - AODELd
|
||||||
|
|
||||||
|
## Diagrams
|
||||||
|
|
||||||
|
### UML Class Diagram
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Dependency Diagram
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Coverage report
|
||||||
|
|
||||||
|
### [Coverage report](docs/coverage.pdf)
|
||||||
|
@@ -1,8 +1,13 @@
|
|||||||
#ifndef BASE_H
|
// ***************************************************************
|
||||||
#define BASE_H
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <vector>
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
enum status_t { NORMAL, WARNING, ERROR };
|
enum status_t { NORMAL, WARNING, ERROR };
|
||||||
class BaseClassifier {
|
class BaseClassifier {
|
||||||
@@ -30,7 +35,7 @@ namespace bayesnet {
|
|||||||
virtual std::string getVersion() = 0;
|
virtual std::string getVersion() = 0;
|
||||||
std::vector<std::string> virtual topological_order() = 0;
|
std::vector<std::string> virtual topological_order() = 0;
|
||||||
std::vector<std::string> virtual getNotes() const = 0;
|
std::vector<std::string> virtual getNotes() const = 0;
|
||||||
void virtual dump_cpt()const = 0;
|
std::string virtual dump_cpt()const = 0;
|
||||||
virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;
|
virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;
|
||||||
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
|
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
|
||||||
protected:
|
protected:
|
||||||
@@ -38,4 +43,3 @@ namespace bayesnet {
|
|||||||
std::vector<std::string> validHyperparameters;
|
std::vector<std::string> validHyperparameters;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
|
13
bayesnet/CMakeLists.txt
Normal file
13
bayesnet/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
include_directories(
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/mdlp
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/Files
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/folding
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/json/include
|
||||||
|
${BayesNet_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE Sources "*.cc")
|
||||||
|
|
||||||
|
add_library(BayesNet ${Sources})
|
||||||
|
target_link_libraries(BayesNet mdlp "${TORCH_LIBRARIES}")
|
@@ -1,5 +1,12 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
#include "Classifier.h"
|
#include "Classifier.h"
|
||||||
#include "bayesnetUtils.h"
|
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}
|
Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}
|
||||||
@@ -10,7 +17,7 @@ namespace bayesnet {
|
|||||||
this->className = className;
|
this->className = className;
|
||||||
this->states = states;
|
this->states = states;
|
||||||
m = dataset.size(1);
|
m = dataset.size(1);
|
||||||
n = dataset.size(0) - 1;
|
n = features.size();
|
||||||
checkFitParameters();
|
checkFitParameters();
|
||||||
auto n_classes = states.at(className).size();
|
auto n_classes = states.at(className).size();
|
||||||
metrics = Metrics(dataset, features, className, n_classes);
|
metrics = Metrics(dataset, features, className, n_classes);
|
||||||
@@ -27,10 +34,11 @@ namespace bayesnet {
|
|||||||
dataset = torch::cat({ dataset, yresized }, 0);
|
dataset = torch::cat({ dataset, yresized }, 0);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::cerr << e.what() << '\n';
|
std::stringstream oss;
|
||||||
std::cout << "X dimensions: " << dataset.sizes() << "\n";
|
oss << "* Error in X and y dimensions *\n";
|
||||||
std::cout << "y dimensions: " << ytmp.sizes() << "\n";
|
oss << "X dimensions: " << dataset.sizes() << "\n";
|
||||||
exit(1);
|
oss << "y dimensions: " << ytmp.sizes();
|
||||||
|
throw std::runtime_error(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Classifier::trainModel(const torch::Tensor& weights)
|
void Classifier::trainModel(const torch::Tensor& weights)
|
||||||
@@ -73,11 +81,11 @@ namespace bayesnet {
|
|||||||
if (torch::is_floating_point(dataset)) {
|
if (torch::is_floating_point(dataset)) {
|
||||||
throw std::invalid_argument("dataset (X, y) must be of type Integer");
|
throw std::invalid_argument("dataset (X, y) must be of type Integer");
|
||||||
}
|
}
|
||||||
if (n != features.size()) {
|
if (dataset.size(0) - 1 != features.size()) {
|
||||||
throw std::invalid_argument("Classifier: X " + std::to_string(n) + " and features " + std::to_string(features.size()) + " must have the same number of features");
|
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");
|
||||||
}
|
}
|
||||||
if (states.find(className) == states.end()) {
|
if (states.find(className) == states.end()) {
|
||||||
throw std::invalid_argument("className not found in states");
|
throw std::invalid_argument("class name not found in states");
|
||||||
}
|
}
|
||||||
for (auto feature : features) {
|
for (auto feature : features) {
|
||||||
if (states.find(feature) == states.end()) {
|
if (states.find(feature) == states.end()) {
|
||||||
@@ -173,12 +181,14 @@ namespace bayesnet {
|
|||||||
{
|
{
|
||||||
return model.topological_sort();
|
return model.topological_sort();
|
||||||
}
|
}
|
||||||
void Classifier::dump_cpt() const
|
std::string Classifier::dump_cpt() const
|
||||||
{
|
{
|
||||||
model.dump_cpt();
|
return model.dump_cpt();
|
||||||
}
|
}
|
||||||
void Classifier::setHyperparameters(const nlohmann::json& hyperparameters)
|
void Classifier::setHyperparameters(const nlohmann::json& hyperparameters)
|
||||||
{
|
{
|
||||||
//For classifiers that don't have hyperparameters
|
if (!hyperparameters.empty()) {
|
||||||
|
throw std::invalid_argument("Invalid hyperparameters" + hyperparameters.dump());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,9 +1,15 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef CLASSIFIER_H
|
#ifndef CLASSIFIER_H
|
||||||
#define CLASSIFIER_H
|
#define CLASSIFIER_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include "BaseClassifier.h"
|
#include "bayesnet/utils/BayesMetrics.h"
|
||||||
#include "Network.h"
|
#include "bayesnet/network/Network.h"
|
||||||
#include "BayesMetrics.h"
|
#include "bayesnet/BaseClassifier.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class Classifier : public BaseClassifier {
|
class Classifier : public BaseClassifier {
|
||||||
@@ -30,7 +36,7 @@ namespace bayesnet {
|
|||||||
std::vector<std::string> show() const override;
|
std::vector<std::string> show() const override;
|
||||||
std::vector<std::string> topological_order() override;
|
std::vector<std::string> topological_order() override;
|
||||||
std::vector<std::string> getNotes() const override { return notes; }
|
std::vector<std::string> getNotes() const override { return notes; }
|
||||||
void dump_cpt() const override;
|
std::string dump_cpt() const override;
|
||||||
void setHyperparameters(const nlohmann::json& hyperparameters) override; //For classifiers that don't have hyperparameters
|
void setHyperparameters(const nlohmann::json& hyperparameters) override; //For classifiers that don't have hyperparameters
|
||||||
protected:
|
protected:
|
||||||
bool fitted;
|
bool fitted;
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "KDB.h"
|
#include "KDB.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
@@ -6,14 +12,18 @@ namespace bayesnet {
|
|||||||
validHyperparameters = { "k", "theta" };
|
validHyperparameters = { "k", "theta" };
|
||||||
|
|
||||||
}
|
}
|
||||||
void KDB::setHyperparameters(const nlohmann::json& hyperparameters)
|
void KDB::setHyperparameters(const nlohmann::json& hyperparameters_)
|
||||||
{
|
{
|
||||||
|
auto hyperparameters = hyperparameters_;
|
||||||
if (hyperparameters.contains("k")) {
|
if (hyperparameters.contains("k")) {
|
||||||
k = hyperparameters["k"];
|
k = hyperparameters["k"];
|
||||||
|
hyperparameters.erase("k");
|
||||||
}
|
}
|
||||||
if (hyperparameters.contains("theta")) {
|
if (hyperparameters.contains("theta")) {
|
||||||
theta = hyperparameters["theta"];
|
theta = hyperparameters["theta"];
|
||||||
|
hyperparameters.erase("theta");
|
||||||
}
|
}
|
||||||
|
Classifier::setHyperparameters(hyperparameters);
|
||||||
}
|
}
|
||||||
void KDB::buildModel(const torch::Tensor& weights)
|
void KDB::buildModel(const torch::Tensor& weights)
|
||||||
{
|
{
|
@@ -1,8 +1,14 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef KDB_H
|
#ifndef KDB_H
|
||||||
#define KDB_H
|
#define KDB_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
#include "Classifier.h"
|
#include "Classifier.h"
|
||||||
#include "bayesnetUtils.h"
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class KDB : public Classifier {
|
class KDB : public Classifier {
|
||||||
private:
|
private:
|
||||||
@@ -14,7 +20,7 @@ namespace bayesnet {
|
|||||||
public:
|
public:
|
||||||
explicit KDB(int k, float theta = 0.03);
|
explicit KDB(int k, float theta = 0.03);
|
||||||
virtual ~KDB() = default;
|
virtual ~KDB() = default;
|
||||||
void setHyperparameters(const nlohmann::json& hyperparameters) override;
|
void setHyperparameters(const nlohmann::json& hyperparameters_) override;
|
||||||
std::vector<std::string> graph(const std::string& name = "KDB") const override;
|
std::vector<std::string> graph(const std::string& name = "KDB") const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "KDBLd.h"
|
#include "KDBLd.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
@@ -1,7 +1,13 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef KDBLD_H
|
#ifndef KDBLD_H
|
||||||
#define KDBLD_H
|
#define KDBLD_H
|
||||||
#include "KDB.h"
|
|
||||||
#include "Proposal.h"
|
#include "Proposal.h"
|
||||||
|
#include "KDB.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class KDBLd : public KDB, public Proposal {
|
class KDBLd : public KDB, public Proposal {
|
@@ -1,5 +1,11 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include <ArffFiles.h>
|
||||||
#include "Proposal.h"
|
#include "Proposal.h"
|
||||||
#include "ArffFiles.h"
|
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
Proposal::Proposal(torch::Tensor& dataset_, std::vector<std::string>& features_, std::string& className_) : pDataset(dataset_), pFeatures(features_), pClassName(className_) {}
|
Proposal::Proposal(torch::Tensor& dataset_, std::vector<std::string>& features_, std::string& className_) : pDataset(dataset_), pFeatures(features_), pClassName(className_) {}
|
@@ -1,10 +1,16 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef PROPOSAL_H
|
#ifndef PROPOSAL_H
|
||||||
#define PROPOSAL_H
|
#define PROPOSAL_H
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include "Network.h"
|
#include <CPPFImdlp.h>
|
||||||
#include "CPPFImdlp.h"
|
#include "bayesnet/network/Network.h"
|
||||||
#include "Classifier.h"
|
#include "Classifier.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "SPODE.h"
|
#include "SPODE.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef SPODE_H
|
#ifndef SPODE_H
|
||||||
#define SPODE_H
|
#define SPODE_H
|
||||||
#include "Classifier.h"
|
#include "Classifier.h"
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "SPODELd.h"
|
#include "SPODELd.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
@@ -5,25 +11,23 @@ namespace bayesnet {
|
|||||||
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_)
|
||||||
{
|
{
|
||||||
checkInput(X_, y_);
|
checkInput(X_, y_);
|
||||||
features = features_;
|
|
||||||
className = className_;
|
|
||||||
Xf = X_;
|
Xf = X_;
|
||||||
y = y_;
|
y = y_;
|
||||||
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
|
return commonFit(features_, className_, states_);
|
||||||
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);
|
|
||||||
states = localDiscretizationProposal(states, model);
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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_)
|
||||||
{
|
{
|
||||||
if (!torch::is_floating_point(dataset)) {
|
if (!torch::is_floating_point(dataset)) {
|
||||||
throw std::runtime_error("Dataset must be a floating point tensor");
|
throw std::runtime_error("Dataset must be a floating point tensor");
|
||||||
}
|
}
|
||||||
Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();
|
Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();
|
||||||
y = dataset.index({ -1, "..." }).clone();
|
y = dataset.index({ -1, "..." }).clone().to(torch::kInt32);
|
||||||
|
return commonFit(features_, className_, states_);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPODELd& SPODELd::commonFit(const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
|
||||||
|
{
|
||||||
features = features_;
|
features = features_;
|
||||||
className = className_;
|
className = className_;
|
||||||
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
|
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||||
@@ -34,7 +38,6 @@ namespace bayesnet {
|
|||||||
states = localDiscretizationProposal(states, model);
|
states = localDiscretizationProposal(states, model);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
torch::Tensor SPODELd::predict(torch::Tensor& X)
|
torch::Tensor SPODELd::predict(torch::Tensor& X)
|
||||||
{
|
{
|
||||||
auto Xt = prepareX(X);
|
auto Xt = prepareX(X);
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef SPODELD_H
|
#ifndef SPODELD_H
|
||||||
#define SPODELD_H
|
#define SPODELD_H
|
||||||
#include "SPODE.h"
|
#include "SPODE.h"
|
||||||
@@ -10,6 +16,7 @@ namespace bayesnet {
|
|||||||
virtual ~SPODELd() = default;
|
virtual ~SPODELd() = default;
|
||||||
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
||||||
SPODELd& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
|
SPODELd& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) 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;
|
std::vector<std::string> graph(const std::string& name = "SPODE") const override;
|
||||||
torch::Tensor predict(torch::Tensor& X) override;
|
torch::Tensor predict(torch::Tensor& X) override;
|
||||||
static inline std::string version() { return "0.0.1"; };
|
static inline std::string version() { return "0.0.1"; };
|
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
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "TAN.h"
|
#include "TAN.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef TAN_H
|
#ifndef TAN_H
|
||||||
#define TAN_H
|
#define TAN_H
|
||||||
#include "Classifier.h"
|
#include "Classifier.h"
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "TANLd.h"
|
#include "TANLd.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef TANLD_H
|
#ifndef TANLD_H
|
||||||
#define TANLD_H
|
#define TANLD_H
|
||||||
#include "TAN.h"
|
#include "TAN.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
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "AODE.h"
|
#include "AODE.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
@@ -13,9 +19,7 @@ namespace bayesnet {
|
|||||||
predict_voting = hyperparameters["predict_voting"];
|
predict_voting = hyperparameters["predict_voting"];
|
||||||
hyperparameters.erase("predict_voting");
|
hyperparameters.erase("predict_voting");
|
||||||
}
|
}
|
||||||
if (!hyperparameters.empty()) {
|
Classifier::setHyperparameters(hyperparameters);
|
||||||
throw std::invalid_argument("Invalid hyperparameters" + hyperparameters.dump());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void AODE::buildModel(const torch::Tensor& weights)
|
void AODE::buildModel(const torch::Tensor& weights)
|
||||||
{
|
{
|
@@ -1,11 +1,17 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef AODE_H
|
#ifndef AODE_H
|
||||||
#define AODE_H
|
#define AODE_H
|
||||||
|
#include "bayesnet/classifiers/SPODE.h"
|
||||||
#include "Ensemble.h"
|
#include "Ensemble.h"
|
||||||
#include "SPODE.h"
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class AODE : public Ensemble {
|
class AODE : public Ensemble {
|
||||||
public:
|
public:
|
||||||
AODE(bool predict_voting = true);
|
AODE(bool predict_voting = false);
|
||||||
virtual ~AODE() {};
|
virtual ~AODE() {};
|
||||||
void setHyperparameters(const nlohmann::json& hyperparameters) override;
|
void setHyperparameters(const nlohmann::json& hyperparameters) override;
|
||||||
std::vector<std::string> graph(const std::string& title = "AODE") const override;
|
std::vector<std::string> graph(const std::string& title = "AODE") const override;
|
@@ -1,21 +1,14 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "AODELd.h"
|
#include "AODELd.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)
|
AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)
|
||||||
{
|
{
|
||||||
validHyperparameters = { "predict_voting" };
|
|
||||||
|
|
||||||
}
|
|
||||||
void AODELd::setHyperparameters(const nlohmann::json& hyperparameters_)
|
|
||||||
{
|
|
||||||
auto hyperparameters = hyperparameters_;
|
|
||||||
if (hyperparameters.contains("predict_voting")) {
|
|
||||||
predict_voting = hyperparameters["predict_voting"];
|
|
||||||
hyperparameters.erase("predict_voting");
|
|
||||||
}
|
|
||||||
if (!hyperparameters.empty()) {
|
|
||||||
throw std::invalid_argument("Invalid hyperparameters" + hyperparameters.dump());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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_)
|
||||||
{
|
{
|
@@ -1,8 +1,14 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef AODELD_H
|
#ifndef AODELD_H
|
||||||
#define AODELD_H
|
#define AODELD_H
|
||||||
|
#include "bayesnet/classifiers/Proposal.h"
|
||||||
|
#include "bayesnet/classifiers/SPODELd.h"
|
||||||
#include "Ensemble.h"
|
#include "Ensemble.h"
|
||||||
#include "Proposal.h"
|
|
||||||
#include "SPODELd.h"
|
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class AODELd : public Ensemble, public Proposal {
|
class AODELd : public Ensemble, public Proposal {
|
||||||
@@ -10,7 +16,6 @@ namespace bayesnet {
|
|||||||
AODELd(bool predict_voting = true);
|
AODELd(bool predict_voting = true);
|
||||||
virtual ~AODELd() = default;
|
virtual ~AODELd() = default;
|
||||||
AODELd& fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_) override;
|
AODELd& fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_) override;
|
||||||
void setHyperparameters(const nlohmann::json& hyperparameters) override;
|
|
||||||
std::vector<std::string> graph(const std::string& name = "AODELd") const override;
|
std::vector<std::string> graph(const std::string& name = "AODELd") const override;
|
||||||
protected:
|
protected:
|
||||||
void trainModel(const torch::Tensor& weights) override;
|
void trainModel(const torch::Tensor& weights) override;
|
396
bayesnet/ensembles/BoostAODE.cc
Normal file
396
bayesnet/ensembles/BoostAODE.cc
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// 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 "BoostAODE.h"
|
||||||
|
#include "lib/log/loguru.cpp"
|
||||||
|
|
||||||
|
namespace bayesnet {
|
||||||
|
|
||||||
|
BoostAODE::BoostAODE(bool predict_voting) : Ensemble(predict_voting)
|
||||||
|
{
|
||||||
|
validHyperparameters = {
|
||||||
|
"maxModels", "bisection", "order", "convergence", "convergence_best", "threshold",
|
||||||
|
"select_features", "maxTolerance", "predict_voting", "block_update"
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
void BoostAODE::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_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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::unique_ptr<Classifier> model = std::make_unique<SPODE>(feature);
|
||||||
|
model->fit(dataset, features, className, states, weights_);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
void BoostAODE::trainModel(const torch::Tensor& weights)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Logging setup
|
||||||
|
//
|
||||||
|
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)
|
||||||
|
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();
|
||||||
|
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 };
|
||||||
|
while (!finished) {
|
||||||
|
// Step 1: Build ranking with mutual information
|
||||||
|
auto featureSelection = metrics.SelectKBestWeighted(weights_, ascending, n); // Get all the features sorted
|
||||||
|
if (order_algorithm == Orders.RAND) {
|
||||||
|
std::shuffle(featureSelection.begin(), featureSelection.end(), g);
|
||||||
|
}
|
||||||
|
// Remove used features
|
||||||
|
featureSelection.erase(remove_if(begin(featureSelection), end(featureSelection), [&](auto x)
|
||||||
|
{ return std::find(begin(featuresUsed), end(featuresUsed), x) != end(featuresUsed);}),
|
||||||
|
end(featureSelection)
|
||||||
|
);
|
||||||
|
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 && 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_);
|
||||||
|
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++;
|
||||||
|
featuresUsed.push_back(feature);
|
||||||
|
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 || 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);
|
||||||
|
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 (featuresUsed.size() != features.size()) {
|
||||||
|
notes.push_back("Used features in train: " + std::to_string(featuresUsed.size()) + " of " + std::to_string(features.size()));
|
||||||
|
status = WARNING;
|
||||||
|
}
|
||||||
|
notes.push_back("Number of models: " + std::to_string(n_models));
|
||||||
|
}
|
||||||
|
std::vector<std::string> BoostAODE::graph(const std::string& title) const
|
||||||
|
{
|
||||||
|
return Ensemble::graph(title);
|
||||||
|
}
|
||||||
|
}
|
50
bayesnet/ensembles/BoostAODE.h
Normal file
50
bayesnet/ensembles/BoostAODE.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#ifndef BOOSTAODE_H
|
||||||
|
#define BOOSTAODE_H
|
||||||
|
#include <map>
|
||||||
|
#include "bayesnet/classifiers/SPODE.h"
|
||||||
|
#include "bayesnet/feature_selection/FeatureSelect.h"
|
||||||
|
#include "Ensemble.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 {
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "Ensemble.h"
|
#include "Ensemble.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
@@ -1,9 +1,15 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef ENSEMBLE_H
|
#ifndef ENSEMBLE_H
|
||||||
#define ENSEMBLE_H
|
#define ENSEMBLE_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include "Classifier.h"
|
#include "bayesnet/utils/BayesMetrics.h"
|
||||||
#include "BayesMetrics.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
#include "bayesnetUtils.h"
|
#include "bayesnet/classifiers/Classifier.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class Ensemble : public Classifier {
|
class Ensemble : public Classifier {
|
||||||
@@ -25,8 +31,9 @@ namespace bayesnet {
|
|||||||
{
|
{
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
void dump_cpt() const override
|
std::string dump_cpt() const override
|
||||||
{
|
{
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
torch::Tensor predict_average_voting(torch::Tensor& X);
|
torch::Tensor predict_average_voting(torch::Tensor& X);
|
@@ -1,6 +1,12 @@
|
|||||||
#include "CFS.h"
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "bayesnetUtils.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
|
#include "CFS.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
void CFS::fit()
|
void CFS::fit()
|
||||||
{
|
{
|
||||||
@@ -11,7 +17,7 @@ namespace bayesnet {
|
|||||||
auto feature = featureOrder[0];
|
auto feature = featureOrder[0];
|
||||||
selectedFeatures.push_back(feature);
|
selectedFeatures.push_back(feature);
|
||||||
selectedScores.push_back(suLabels[feature]);
|
selectedScores.push_back(suLabels[feature]);
|
||||||
selectedFeatures.erase(selectedFeatures.begin());
|
featureOrder.erase(featureOrder.begin());
|
||||||
while (continueCondition) {
|
while (continueCondition) {
|
||||||
double merit = std::numeric_limits<double>::lowest();
|
double merit = std::numeric_limits<double>::lowest();
|
||||||
int bestFeature = -1;
|
int bestFeature = -1;
|
@@ -1,8 +1,14 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef CFS_H
|
#ifndef CFS_H
|
||||||
#define CFS_H
|
#define CFS_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "FeatureSelect.h"
|
#include "bayesnet/feature_selection/FeatureSelect.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class CFS : public FeatureSelect {
|
class CFS : public FeatureSelect {
|
||||||
public:
|
public:
|
@@ -1,4 +1,10 @@
|
|||||||
#include "bayesnetUtils.h"
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
#include "FCBF.h"
|
#include "FCBF.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
|
|
@@ -1,8 +1,14 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef FCBF_H
|
#ifndef FCBF_H
|
||||||
#define FCBF_H
|
#define FCBF_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "FeatureSelect.h"
|
#include "bayesnet/feature_selection/FeatureSelect.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class FCBF : public FeatureSelect {
|
class FCBF : public FeatureSelect {
|
||||||
public:
|
public:
|
@@ -1,6 +1,12 @@
|
|||||||
#include "FeatureSelect.h"
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "bayesnetUtils.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
|
#include "FeatureSelect.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
FeatureSelect::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) :
|
FeatureSelect::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) :
|
||||||
Metrics(samples, features, className, classNumStates), maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures), weights(weights)
|
Metrics(samples, features, className, classNumStates), maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures), weights(weights)
|
||||||
@@ -50,7 +56,6 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
double FeatureSelect::computeMeritCFS()
|
double FeatureSelect::computeMeritCFS()
|
||||||
{
|
{
|
||||||
double result;
|
|
||||||
double rcf = 0;
|
double rcf = 0;
|
||||||
for (auto feature : selectedFeatures) {
|
for (auto feature : selectedFeatures) {
|
||||||
rcf += suLabels[feature];
|
rcf += suLabels[feature];
|
@@ -1,8 +1,14 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef FEATURE_SELECT_H
|
#ifndef FEATURE_SELECT_H
|
||||||
#define FEATURE_SELECT_H
|
#define FEATURE_SELECT_H
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "BayesMetrics.h"
|
#include "bayesnet/utils/BayesMetrics.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class FeatureSelect : public Metrics {
|
class FeatureSelect : public Metrics {
|
||||||
public:
|
public:
|
@@ -1,6 +1,12 @@
|
|||||||
#include "IWSS.h"
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "bayesnetUtils.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
|
#include "IWSS.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
IWSS::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) :
|
IWSS::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) :
|
||||||
FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights), threshold(threshold)
|
FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights), threshold(threshold)
|
||||||
@@ -28,7 +34,7 @@ namespace bayesnet {
|
|||||||
selectedFeatures.push_back(feature);
|
selectedFeatures.push_back(feature);
|
||||||
// Compute merit with selectedFeatures
|
// Compute merit with selectedFeatures
|
||||||
auto meritNew = computeMeritCFS();
|
auto meritNew = computeMeritCFS();
|
||||||
double delta = merit != 0.0 ? abs(merit - meritNew) / merit : 0.0;
|
double delta = merit != 0.0 ? std::abs(merit - meritNew) / merit : 0.0;
|
||||||
if (meritNew > merit || delta < threshold) {
|
if (meritNew > merit || delta < threshold) {
|
||||||
if (meritNew > merit) {
|
if (meritNew > merit) {
|
||||||
merit = meritNew;
|
merit = meritNew;
|
@@ -1,7 +1,13 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef IWSS_H
|
#ifndef IWSS_H
|
||||||
#define IWSS_H
|
#define IWSS_H
|
||||||
#include <torch/torch.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <torch/torch.h>
|
||||||
#include "FeatureSelect.h"
|
#include "FeatureSelect.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class IWSS : public FeatureSelect {
|
class IWSS : public FeatureSelect {
|
@@ -1,27 +1,41 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <sstream>
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "bayesnetUtils.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
Network::Network() : features(std::vector<std::string>()), className(""), classNumStates(0), fitted(false), laplaceSmoothing(0) {}
|
Network::Network() : fitted{ false }, maxThreads{ 0.95 }, classNumStates{ 0 }, laplaceSmoothing{ 0 }
|
||||||
Network::Network(float maxT) : features(std::vector<std::string>()), className(""), classNumStates(0), maxThreads(maxT), fitted(false), laplaceSmoothing(0) {}
|
|
||||||
Network::Network(Network& other) : laplaceSmoothing(other.laplaceSmoothing), features(other.features), className(other.className), classNumStates(other.getClassNumStates()), maxThreads(other.
|
|
||||||
getmaxThreads()), fitted(other.fitted)
|
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (samples.defined())
|
||||||
|
samples = samples.clone();
|
||||||
for (const auto& node : other.nodes) {
|
for (const auto& node : other.nodes) {
|
||||||
nodes[node.first] = std::make_unique<Node>(*node.second);
|
nodes[node.first] = std::make_unique<Node>(*node.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Network::initialize()
|
void Network::initialize()
|
||||||
{
|
{
|
||||||
features = std::vector<std::string>();
|
features.clear();
|
||||||
className = "";
|
className = "";
|
||||||
classNumStates = 0;
|
classNumStates = 0;
|
||||||
fitted = false;
|
fitted = false;
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
samples = torch::Tensor();
|
samples = torch::Tensor();
|
||||||
}
|
}
|
||||||
float Network::getmaxThreads()
|
float Network::getMaxThreads() const
|
||||||
{
|
{
|
||||||
return maxThreads;
|
return maxThreads;
|
||||||
}
|
}
|
||||||
@@ -71,7 +85,7 @@ namespace bayesnet {
|
|||||||
for (Node* child : nodes[nodeId]->getChildren()) {
|
for (Node* child : nodes[nodeId]->getChildren()) {
|
||||||
if (visited.find(child->getName()) == visited.end() && isCyclic(child->getName(), visited, recStack))
|
if (visited.find(child->getName()) == visited.end() && isCyclic(child->getName(), visited, recStack))
|
||||||
return true;
|
return true;
|
||||||
else if (recStack.find(child->getName()) != recStack.end())
|
if (recStack.find(child->getName()) != recStack.end())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,11 +128,14 @@ namespace bayesnet {
|
|||||||
if (n_features != featureNames.size()) {
|
if (n_features != featureNames.size()) {
|
||||||
throw std::invalid_argument("X and features must have the same number of features in Network::fit (" + std::to_string(n_features) + " != " + std::to_string(featureNames.size()) + ")");
|
throw std::invalid_argument("X and features must have the same number of features in Network::fit (" + std::to_string(n_features) + " != " + std::to_string(featureNames.size()) + ")");
|
||||||
}
|
}
|
||||||
|
if (features.size() == 0) {
|
||||||
|
throw std::invalid_argument("The network has not been initialized. You must call addNode() before calling fit()");
|
||||||
|
}
|
||||||
if (n_features != features.size() - 1) {
|
if (n_features != features.size() - 1) {
|
||||||
throw std::invalid_argument("X and local features must have the same number of features in Network::fit (" + std::to_string(n_features) + " != " + std::to_string(features.size() - 1) + ")");
|
throw std::invalid_argument("X and local features must have the same number of features in Network::fit (" + std::to_string(n_features) + " != " + std::to_string(features.size() - 1) + ")");
|
||||||
}
|
}
|
||||||
if (find(features.begin(), features.end(), className) == features.end()) {
|
if (find(features.begin(), features.end(), className) == features.end()) {
|
||||||
throw std::invalid_argument("className not found in Network::features");
|
throw std::invalid_argument("Class Name not found in Network::features");
|
||||||
}
|
}
|
||||||
for (auto& feature : featureNames) {
|
for (auto& feature : featureNames) {
|
||||||
if (find(features.begin(), features.end(), feature) == features.end()) {
|
if (find(features.begin(), features.end(), feature) == features.end()) {
|
||||||
@@ -393,22 +410,20 @@ namespace bayesnet {
|
|||||||
result.insert(it2, fatherName);
|
result.insert(it2, fatherName);
|
||||||
ending = false;
|
ending = false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw std::logic_error("Error in topological sort because of node " + feature + " is not in result");
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw std::logic_error("Error in topological sort because of node father " + fatherName + " is not in result");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void Network::dump_cpt() const
|
std::string Network::dump_cpt() const
|
||||||
{
|
{
|
||||||
|
std::stringstream oss;
|
||||||
for (auto& node : nodes) {
|
for (auto& node : nodes) {
|
||||||
std::cout << "* " << node.first << ": (" << node.second->getNumStates() << ") : " << node.second->getCPT().sizes() << std::endl;
|
oss << "* " << node.first << ": (" << node.second->getNumStates() << ") : " << node.second->getCPT().sizes() << std::endl;
|
||||||
std::cout << node.second->getCPT() << std::endl;
|
oss << node.second->getCPT() << std::endl;
|
||||||
}
|
}
|
||||||
|
return oss.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,19 +1,25 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef NETWORK_H
|
#ifndef NETWORK_H
|
||||||
#define NETWORK_H
|
#define NETWORK_H
|
||||||
#include "Node.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "config.h"
|
#include "bayesnet/config.h"
|
||||||
|
#include "Node.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class Network {
|
class Network {
|
||||||
public:
|
public:
|
||||||
Network();
|
Network();
|
||||||
explicit Network(float);
|
explicit Network(float);
|
||||||
explicit Network(Network&);
|
explicit Network(const Network&);
|
||||||
~Network() = default;
|
~Network() = default;
|
||||||
torch::Tensor& getSamples();
|
torch::Tensor& getSamples();
|
||||||
float getmaxThreads();
|
float getMaxThreads() const;
|
||||||
void addNode(const std::string&);
|
void addNode(const std::string&);
|
||||||
void addEdge(const std::string&, const std::string&);
|
void addEdge(const std::string&, const std::string&);
|
||||||
std::map<std::string, std::unique_ptr<Node>>& getNodes();
|
std::map<std::string, std::unique_ptr<Node>>& getNodes();
|
||||||
@@ -39,7 +45,7 @@ namespace bayesnet {
|
|||||||
std::vector<std::string> show() const;
|
std::vector<std::string> show() const;
|
||||||
std::vector<std::string> graph(const std::string& title) const; // Returns a std::vector of std::strings representing the graph in graphviz format
|
std::vector<std::string> graph(const std::string& title) const; // Returns a std::vector of std::strings representing the graph in graphviz format
|
||||||
void initialize();
|
void initialize();
|
||||||
void dump_cpt() const;
|
std::string dump_cpt() const;
|
||||||
inline std::string version() { return { project_version.begin(), project_version.end() }; }
|
inline std::string version() { return { project_version.begin(), project_version.end() }; }
|
||||||
private:
|
private:
|
||||||
std::map<std::string, std::unique_ptr<Node>> nodes;
|
std::map<std::string, std::unique_ptr<Node>> nodes;
|
||||||
@@ -49,7 +55,7 @@ namespace bayesnet {
|
|||||||
std::vector<std::string> features; // Including classname
|
std::vector<std::string> features; // Including classname
|
||||||
std::string className;
|
std::string className;
|
||||||
double laplaceSmoothing;
|
double laplaceSmoothing;
|
||||||
torch::Tensor samples; // nxm tensor used to fit the model
|
torch::Tensor samples; // n+1xm tensor used to fit the model
|
||||||
bool isCyclic(const std::string&, std::unordered_set<std::string>&, std::unordered_set<std::string>&);
|
bool isCyclic(const std::string&, std::unordered_set<std::string>&, std::unordered_set<std::string>&);
|
||||||
std::vector<double> predict_sample(const std::vector<int>&);
|
std::vector<double> predict_sample(const std::vector<int>&);
|
||||||
std::vector<double> predict_sample(const torch::Tensor&);
|
std::vector<double> predict_sample(const torch::Tensor&);
|
@@ -1,9 +1,15 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
|
|
||||||
Node::Node(const std::string& name)
|
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()
|
void Node::clear()
|
||||||
@@ -90,7 +96,6 @@ namespace bayesnet {
|
|||||||
// Get dimensions of the CPT
|
// Get dimensions of the CPT
|
||||||
dimensions.push_back(numStates);
|
dimensions.push_back(numStates);
|
||||||
transform(parents.begin(), parents.end(), back_inserter(dimensions), [](const auto& parent) { return parent->getNumStates(); });
|
transform(parents.begin(), parents.end(), back_inserter(dimensions), [](const auto& parent) { return parent->getNumStates(); });
|
||||||
|
|
||||||
// Create a tensor of zeros with the dimensions of the CPT
|
// Create a tensor of zeros with the dimensions of the CPT
|
||||||
cpTable = torch::zeros(dimensions, torch::kFloat) + laplaceSmoothing;
|
cpTable = torch::zeros(dimensions, torch::kFloat) + laplaceSmoothing;
|
||||||
// Fill table with counts
|
// Fill table with counts
|
@@ -1,19 +1,17 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef NODE_H
|
#ifndef NODE_H
|
||||||
#define NODE_H
|
#define NODE_H
|
||||||
#include <torch/torch.h>
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <torch/torch.h>
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class Node {
|
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:
|
public:
|
||||||
explicit Node(const std::string&);
|
explicit Node(const std::string&);
|
||||||
void clear();
|
void clear();
|
||||||
@@ -31,6 +29,14 @@ namespace bayesnet {
|
|||||||
unsigned minFill();
|
unsigned minFill();
|
||||||
std::vector<std::string> graph(const std::string& clasName); // Returns a std::vector of std::strings representing the graph in graphviz format
|
std::vector<std::string> graph(const std::string& clasName); // Returns a std::vector of std::strings representing the graph in graphviz format
|
||||||
float getFactorValue(std::map<std::string, int>&);
|
float 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
|
#endif
|
@@ -1,20 +1,29 @@
|
|||||||
#include "BayesMetrics.h"
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <tuple>
|
||||||
#include "Mst.h"
|
#include "Mst.h"
|
||||||
|
#include "BayesMetrics.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
//samples is n+1xm tensor used to fit the model
|
//samples is n+1xm tensor used to fit the model
|
||||||
Metrics::Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates)
|
Metrics::Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates)
|
||||||
: samples(samples)
|
: samples(samples)
|
||||||
, features(features)
|
|
||||||
, className(className)
|
, className(className)
|
||||||
|
, features(features)
|
||||||
, classNumStates(classNumStates)
|
, classNumStates(classNumStates)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//samples is nxm std::vector used to fit the model
|
//samples is n+1xm std::vector used to fit the model
|
||||||
Metrics::Metrics(const std::vector<std::vector<int>>& vsamples, const std::vector<int>& labels, const std::vector<std::string>& features, const std::string& className, const int classNumStates)
|
Metrics::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)
|
||||||
: features(features)
|
: samples(torch::zeros({ static_cast<int>(vsamples.size() + 1), static_cast<int>(vsamples[0].size()) }, torch::kInt32))
|
||||||
, className(className)
|
, className(className)
|
||||||
|
, features(features)
|
||||||
, classNumStates(classNumStates)
|
, classNumStates(classNumStates)
|
||||||
, samples(torch::zeros({ static_cast<int>(vsamples[0].size()), static_cast<int>(vsamples.size() + 1) }, torch::kInt32))
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < vsamples.size(); ++i) {
|
for (int i = 0; i < vsamples.size(); ++i) {
|
||||||
samples.index_put_({ i, "..." }, torch::tensor(vsamples[i], torch::kInt32));
|
samples.index_put_({ i, "..." }, torch::tensor(vsamples[i], torch::kInt32));
|
||||||
@@ -24,7 +33,7 @@ namespace bayesnet {
|
|||||||
std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k)
|
std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k)
|
||||||
{
|
{
|
||||||
// Return the K Best features
|
// Return the K Best features
|
||||||
auto n = samples.size(0) - 1;
|
auto n = features.size();
|
||||||
if (k == 0) {
|
if (k == 0) {
|
||||||
k = n;
|
k = n;
|
||||||
}
|
}
|
||||||
@@ -99,14 +108,8 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
// To use in Python
|
// Measured in nats (natural logarithm (log) base e)
|
||||||
std::vector<float> Metrics::conditionalEdgeWeights(std::vector<float>& weights_)
|
// Elements of Information Theory, 2nd Edition, Thomas M. Cover, Joy A. Thomas p. 14
|
||||||
{
|
|
||||||
const torch::Tensor weights = torch::tensor(weights_);
|
|
||||||
auto matrix = conditionalEdge(weights);
|
|
||||||
std::vector<float> v(matrix.data_ptr<float>(), matrix.data_ptr<float>() + matrix.numel());
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
double Metrics::entropy(const torch::Tensor& feature, const torch::Tensor& weights)
|
double Metrics::entropy(const torch::Tensor& feature, const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
torch::Tensor counts = feature.bincount(weights);
|
torch::Tensor counts = feature.bincount(weights);
|
||||||
@@ -145,11 +148,64 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
return entropyValue;
|
return entropyValue;
|
||||||
}
|
}
|
||||||
|
// H(Y|X,C) = sum_{x in X, c in C} p(x,c) H(Y|X=x,C=c)
|
||||||
|
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) = H(Y) - H(Y|X)
|
||||||
double Metrics::mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights)
|
double Metrics::mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights)
|
||||||
{
|
{
|
||||||
return entropy(firstFeature, weights) - conditionalEntropy(firstFeature, secondFeature, weights);
|
return entropy(firstFeature, weights) - conditionalEntropy(firstFeature, secondFeature, weights);
|
||||||
}
|
}
|
||||||
|
// I(X;Y|C) = H(Y|C) - H(Y|X,C)
|
||||||
|
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
|
Compute the maximum spanning tree considering the weights as distances
|
||||||
and the indices of the weights as nodes of this square matrix using
|
and the indices of the weights as nodes of this square matrix using
|
@@ -1,19 +1,33 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef BAYESNET_METRICS_H
|
#ifndef BAYESNET_METRICS_H
|
||||||
#define BAYESNET_METRICS_H
|
#define BAYESNET_METRICS_H
|
||||||
#include <torch/torch.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <torch/torch.h>
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class Metrics {
|
class Metrics {
|
||||||
private:
|
public:
|
||||||
int classNumStates = 0;
|
Metrics() = default;
|
||||||
std::vector<double> scoresKBest;
|
Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
|
||||||
std::vector<int> featuresKBest; // sorted indices of the features
|
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);
|
||||||
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0);
|
||||||
|
std::vector<double> getScoresKBest() 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:
|
protected:
|
||||||
torch::Tensor samples; // n+1xm torch::Tensor used to fit the model where samples[-1] is the y std::vector
|
torch::Tensor samples; // n+1xm torch::Tensor used to fit the model where samples[-1] is the y std::vector
|
||||||
std::string className;
|
std::string className;
|
||||||
double entropy(const torch::Tensor& feature, const torch::Tensor& weights);
|
|
||||||
std::vector<std::string> features;
|
std::vector<std::string> features;
|
||||||
template <class T>
|
template <class T>
|
||||||
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
|
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
|
||||||
@@ -34,16 +48,11 @@ namespace bayesnet {
|
|||||||
v.erase(v.begin());
|
v.erase(v.begin());
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
public:
|
private:
|
||||||
Metrics() = default;
|
int classNumStates = 0;
|
||||||
Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
|
std::vector<double> scoresKBest;
|
||||||
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> featuresKBest; // sorted indices of the features
|
||||||
std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0);
|
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
||||||
std::vector<double> getScoresKBest() const;
|
|
||||||
double mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
|
|
||||||
std::vector<float> conditionalEdgeWeights(std::vector<float>& weights); // To use in Python
|
|
||||||
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);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@@ -1,6 +1,13 @@
|
|||||||
#include "Mst.h"
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "Mst.h"
|
||||||
/*
|
/*
|
||||||
Based on the code from https://www.softwaretestinghelp.com/minimum-spanning-tree-tutorial/
|
Based on the code from https://www.softwaretestinghelp.com/minimum-spanning-tree-tutorial/
|
||||||
|
|
||||||
@@ -45,15 +52,6 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Graph::display_mst()
|
|
||||||
{
|
|
||||||
std::cout << "Edge :" << " Weight" << std::endl;
|
|
||||||
for (int i = 0; i < T.size(); i++) {
|
|
||||||
std::cout << T[i].second.first << " - " << T[i].second.second << " : "
|
|
||||||
<< T[i].first;
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void insertElement(std::list<int>& variables, int variable)
|
void insertElement(std::list<int>& variables, int variable)
|
||||||
{
|
{
|
@@ -1,33 +1,38 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef MST_H
|
#ifndef MST_H
|
||||||
#define MST_H
|
#define MST_H
|
||||||
#include <torch/torch.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <torch/torch.h>
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
class MST {
|
class MST {
|
||||||
private:
|
|
||||||
torch::Tensor weights;
|
|
||||||
std::vector<std::string> features;
|
|
||||||
int root = 0;
|
|
||||||
public:
|
public:
|
||||||
MST() = default;
|
MST() = default;
|
||||||
MST(const std::vector<std::string>& features, const torch::Tensor& weights, const int root);
|
MST(const std::vector<std::string>& features, const torch::Tensor& weights, const int root);
|
||||||
std::vector<std::pair<int, int>> maximumSpanningTree();
|
std::vector<std::pair<int, int>> maximumSpanningTree();
|
||||||
|
private:
|
||||||
|
torch::Tensor weights;
|
||||||
|
std::vector<std::string> features;
|
||||||
|
int root = 0;
|
||||||
};
|
};
|
||||||
class Graph {
|
class Graph {
|
||||||
private:
|
|
||||||
int V; // number of nodes in graph
|
|
||||||
std::vector <std::pair<float, std::pair<int, int>>> G; // std::vector for graph
|
|
||||||
std::vector <std::pair<float, std::pair<int, int>>> T; // std::vector for mst
|
|
||||||
std::vector<int> parent;
|
|
||||||
public:
|
public:
|
||||||
explicit Graph(int V);
|
explicit Graph(int V);
|
||||||
void addEdge(int u, int v, float wt);
|
void addEdge(int u, int v, float wt);
|
||||||
int find_set(int i);
|
int find_set(int i);
|
||||||
void union_set(int u, int v);
|
void union_set(int u, int v);
|
||||||
void kruskal_algorithm();
|
void kruskal_algorithm();
|
||||||
void display_mst();
|
|
||||||
std::vector <std::pair<float, std::pair<int, int>>> get_mst() { return T; }
|
std::vector <std::pair<float, std::pair<int, int>>> get_mst() { return T; }
|
||||||
|
private:
|
||||||
|
int V; // number of nodes in graph
|
||||||
|
std::vector <std::pair<float, std::pair<int, int>>> G; // std::vector for graph
|
||||||
|
std::vector <std::pair<float, std::pair<int, int>>> T; // std::vector for mst
|
||||||
|
std::vector<int> parent;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@@ -1,3 +1,9 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
|
|
||||||
#include "bayesnetUtils.h"
|
#include "bayesnetUtils.h"
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
@@ -10,18 +16,6 @@ namespace bayesnet {
|
|||||||
sort(indices.begin(), indices.end(), [&nums](int i, int j) {return nums[i] > nums[j];});
|
sort(indices.begin(), indices.end(), [&nums](int i, int j) {return nums[i] > nums[j];});
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
std::vector<std::vector<int>> tensorToVector(torch::Tensor& dtensor)
|
|
||||||
{
|
|
||||||
// convert mxn tensor to nxm std::vector
|
|
||||||
std::vector<std::vector<int>> result;
|
|
||||||
// Iterate over cols
|
|
||||||
for (int i = 0; i < dtensor.size(1); ++i) {
|
|
||||||
auto col_tensor = dtensor.index({ "...", i });
|
|
||||||
auto col = std::vector<int>(col_tensor.data_ptr<int>(), col_tensor.data_ptr<int>() + dtensor.size(0));
|
|
||||||
result.push_back(col);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
std::vector<std::vector<double>> tensorToVectorDouble(torch::Tensor& dtensor)
|
std::vector<std::vector<double>> tensorToVectorDouble(torch::Tensor& dtensor)
|
||||||
{
|
{
|
||||||
// convert mxn tensor to mxn std::vector
|
// convert mxn tensor to mxn std::vector
|
@@ -1,10 +1,15 @@
|
|||||||
|
// ***************************************************************
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
|
// SPDX-FileType: SOURCE
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// ***************************************************************
|
||||||
|
|
||||||
#ifndef BAYESNET_UTILS_H
|
#ifndef BAYESNET_UTILS_H
|
||||||
#define BAYESNET_UTILS_H
|
#define BAYESNET_UTILS_H
|
||||||
#include <torch/torch.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <torch/torch.h>
|
||||||
namespace bayesnet {
|
namespace bayesnet {
|
||||||
std::vector<int> argsort(std::vector<double>& nums);
|
std::vector<int> argsort(std::vector<double>& nums);
|
||||||
std::vector<std::vector<int>> tensorToVector(torch::Tensor& dtensor);
|
|
||||||
std::vector<std::vector<double>> tensorToVectorDouble(torch::Tensor& dtensor);
|
std::vector<std::vector<double>> tensorToVectorDouble(torch::Tensor& dtensor);
|
||||||
torch::Tensor vectorToTensor(std::vector<std::vector<int>>& vector, bool transpose = true);
|
torch::Tensor vectorToTensor(std::vector<std::vector<int>>& vector, bool transpose = true);
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
configure_file(
|
configure_file(
|
||||||
"config.h.in"
|
"config.h.in"
|
||||||
"${CMAKE_BINARY_DIR}/configured_files/include/config.h" ESCAPE_QUOTES
|
"${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h" ESCAPE_QUOTES
|
||||||
)
|
)
|
||||||
|
Binary file not shown.
412
diagrams/BayesNet.puml
Normal file
412
diagrams/BayesNet.puml
Normal file
@@ -0,0 +1,412 @@
|
|||||||
|
@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 {
|
||||||
|
+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
|
||||||
|
+getCPT() : torch::Tensor &
|
||||||
|
+getChildren() : std::vector<Node *> &
|
||||||
|
+getFactorValue(std::map<std::string,int> &) : float
|
||||||
|
+getName() const : std::string
|
||||||
|
+getNumStates() const : int
|
||||||
|
+getParents() : std::vector<Node *> &
|
||||||
|
+graph(const std::string & clasName) : std::vector<std::string>
|
||||||
|
+minFill() : unsigned int
|
||||||
|
+removeChild(Node *) : void
|
||||||
|
+removeParent(Node *) : void
|
||||||
|
+setNumStates(int) : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::Network" as C_0001186707649890429575
|
||||||
|
class C_0001186707649890429575 #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
|
||||||
|
+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 &
|
||||||
|
+getStates() const : int
|
||||||
|
+graph(const std::string & title) const : std::vector<std::string>
|
||||||
|
+initialize() : void
|
||||||
|
+predict(const std::vector<std::vector<int>> &) : std::vector<int>
|
||||||
|
+predict(const torch::Tensor &) : torch::Tensor
|
||||||
|
+predict_proba(const std::vector<std::vector<int>> &) : std::vector<std::vector<double>>
|
||||||
|
+predict_proba(const torch::Tensor &) : torch::Tensor
|
||||||
|
+predict_tensor(const torch::Tensor & samples, const bool proba) : torch::Tensor
|
||||||
|
+score(const std::vector<std::vector<int>> &, const std::vector<int> &) : double
|
||||||
|
+show() const : std::vector<std::string>
|
||||||
|
+topological_sort() : std::vector<std::string>
|
||||||
|
+version() : std::string
|
||||||
|
__
|
||||||
|
}
|
||||||
|
enum "bayesnet::status_t" as C_0000738420730783851375
|
||||||
|
enum C_0000738420730783851375 {
|
||||||
|
NORMAL
|
||||||
|
WARNING
|
||||||
|
ERROR
|
||||||
|
}
|
||||||
|
abstract "bayesnet::BaseClassifier" as C_0000327135989451974539
|
||||||
|
abstract C_0000327135989451974539 #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} +getClassNumStates() const = 0 : int
|
||||||
|
{abstract} +getNotes() const = 0 : std::vector<std::string>
|
||||||
|
{abstract} +getNumberOfEdges() const = 0 : int
|
||||||
|
{abstract} +getNumberOfNodes() const = 0 : int
|
||||||
|
{abstract} +getNumberOfStates() const = 0 : int
|
||||||
|
{abstract} +getStatus() const = 0 : status_t
|
||||||
|
+getValidHyperparameters() : std::vector<std::string> &
|
||||||
|
{abstract} +getVersion() = 0 : std::string
|
||||||
|
{abstract} +graph(const std::string & title = "") const = 0 : std::vector<std::string>
|
||||||
|
{abstract} +predict(std::vector<std::vector<int>> & X) = 0 : std::vector<int>
|
||||||
|
{abstract} +predict(torch::Tensor & X) = 0 : torch::Tensor
|
||||||
|
{abstract} +predict_proba(std::vector<std::vector<int>> & X) = 0 : std::vector<std::vector<double>>
|
||||||
|
{abstract} +predict_proba(torch::Tensor & X) = 0 : torch::Tensor
|
||||||
|
{abstract} +score(std::vector<std::vector<int>> & X, std::vector<int> & y) = 0 : float
|
||||||
|
{abstract} +score(torch::Tensor & X, torch::Tensor & y) = 0 : float
|
||||||
|
{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
|
||||||
|
__
|
||||||
|
#validHyperparameters : std::vector<std::string>
|
||||||
|
}
|
||||||
|
abstract "bayesnet::Classifier" as C_0002043996622900301644
|
||||||
|
abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+Classifier(Network model) : void
|
||||||
|
+~Classifier() = default : void
|
||||||
|
..
|
||||||
|
+addNodes() : void
|
||||||
|
#buildDataset(torch::Tensor & y) : void
|
||||||
|
{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 &
|
||||||
|
+getClassNumStates() const : int
|
||||||
|
+getNotes() const : std::vector<std::string>
|
||||||
|
+getNumberOfEdges() const : int
|
||||||
|
+getNumberOfNodes() const : int
|
||||||
|
+getNumberOfStates() const : int
|
||||||
|
+getStatus() const : status_t
|
||||||
|
+getVersion() : std::string
|
||||||
|
+predict(std::vector<std::vector<int>> & X) : std::vector<int>
|
||||||
|
+predict(torch::Tensor & X) : torch::Tensor
|
||||||
|
+predict_proba(std::vector<std::vector<int>> & X) : std::vector<std::vector<double>>
|
||||||
|
+predict_proba(torch::Tensor & X) : torch::Tensor
|
||||||
|
+score(torch::Tensor & X, torch::Tensor & y) : float
|
||||||
|
+score(std::vector<std::vector<int>> & X, std::vector<int> & y) : float
|
||||||
|
+setHyperparameters(const nlohmann::json & hyperparameters) : void
|
||||||
|
+show() const : std::vector<std::string>
|
||||||
|
+topological_order() : std::vector<std::string>
|
||||||
|
#trainModel(const torch::Tensor & weights) : void
|
||||||
|
__
|
||||||
|
#className : std::string
|
||||||
|
#dataset : torch::Tensor
|
||||||
|
#features : std::vector<std::string>
|
||||||
|
#fitted : bool
|
||||||
|
#m : unsigned int
|
||||||
|
#metrics : Metrics
|
||||||
|
#model : Network
|
||||||
|
#n : unsigned int
|
||||||
|
#notes : std::vector<std::string>
|
||||||
|
#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 {
|
||||||
|
+KDB(int k, float theta = 0.03) : void
|
||||||
|
+~KDB() = default : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+graph(const std::string & name = "KDB") const : std::vector<std::string>
|
||||||
|
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::TAN" as C_0001760994424884323017
|
||||||
|
class C_0001760994424884323017 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+TAN() : void
|
||||||
|
+~TAN() = default : void
|
||||||
|
..
|
||||||
|
#buildModel(const torch::Tensor & weights) : void
|
||||||
|
+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 {
|
||||||
|
+Proposal(torch::Tensor & pDataset, std::vector<std::string> & features_, std::string & className_) : void
|
||||||
|
+~Proposal() : void
|
||||||
|
..
|
||||||
|
#checkInput(const torch::Tensor & X, const torch::Tensor & y) : void
|
||||||
|
#fit_local_discretization(const torch::Tensor & y) : std::map<std::string,std::vector<int>>
|
||||||
|
#localDiscretizationProposal(const std::map<std::string,std::vector<int>> & states, Network & model) : std::map<std::string,std::vector<int>>
|
||||||
|
#prepareX(torch::Tensor & X) : torch::Tensor
|
||||||
|
__
|
||||||
|
#Xf : torch::Tensor
|
||||||
|
#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
|
||||||
|
..
|
||||||
|
+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>
|
||||||
|
+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
|
||||||
|
..
|
||||||
|
#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
|
||||||
|
__
|
||||||
|
}
|
||||||
|
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
|
||||||
|
..
|
||||||
|
+fit() : void
|
||||||
|
__
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
+Ensemble(bool predict_voting = true) : void
|
||||||
|
+~Ensemble() = default : void
|
||||||
|
..
|
||||||
|
#compute_arg_max(std::vector<std::vector<double>> & X) : std::vector<int>
|
||||||
|
#compute_arg_max(torch::Tensor & X) : torch::Tensor
|
||||||
|
+dump_cpt() const : std::string
|
||||||
|
+getNumberOfEdges() const : int
|
||||||
|
+getNumberOfNodes() const : int
|
||||||
|
+getNumberOfStates() const : int
|
||||||
|
+graph(const std::string & title) const : std::vector<std::string>
|
||||||
|
+predict(std::vector<std::vector<int>> & X) : std::vector<int>
|
||||||
|
+predict(torch::Tensor & X) : torch::Tensor
|
||||||
|
#predict_average_proba(torch::Tensor & X) : torch::Tensor
|
||||||
|
#predict_average_proba(std::vector<std::vector<int>> & X) : std::vector<std::vector<double>>
|
||||||
|
#predict_average_voting(torch::Tensor & X) : torch::Tensor
|
||||||
|
#predict_average_voting(std::vector<std::vector<int>> & X) : std::vector<std::vector<double>>
|
||||||
|
+predict_proba(std::vector<std::vector<int>> & X) : std::vector<std::vector<double>>
|
||||||
|
+predict_proba(torch::Tensor & X) : torch::Tensor
|
||||||
|
+score(std::vector<std::vector<int>> & X, std::vector<int> & y) : float
|
||||||
|
+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
|
||||||
|
#voting(torch::Tensor & votes) : torch::Tensor
|
||||||
|
__
|
||||||
|
#models : std::vector<std::unique_ptr<Classifier>>
|
||||||
|
#n_models : unsigned int
|
||||||
|
#predict_voting : bool
|
||||||
|
#significanceModels : std::vector<double>
|
||||||
|
}
|
||||||
|
class "bayesnet::(anonymous_45089536)" as C_0001186398587753535158
|
||||||
|
class C_0001186398587753535158 #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 {
|
||||||
|
__
|
||||||
|
+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 {
|
||||||
|
+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
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::MST" as C_0000131858426172291700
|
||||||
|
class C_0000131858426172291700 #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
|
||||||
|
..
|
||||||
|
+maximumSpanningTree() : std::vector<std::pair<int,int>>
|
||||||
|
__
|
||||||
|
}
|
||||||
|
class "bayesnet::Graph" as C_0001197041682001898467
|
||||||
|
class C_0001197041682001898467 #aliceblue;line:blue;line.dotted;text:blue {
|
||||||
|
+Graph(int V) : void
|
||||||
|
..
|
||||||
|
+addEdge(int u, int v, float wt) : void
|
||||||
|
+find_set(int i) : int
|
||||||
|
+get_mst() : std::vector<std::pair<float,std::pair<int,int>>>
|
||||||
|
+kruskal_algorithm() : void
|
||||||
|
+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
|
||||||
|
|
||||||
|
'Generated with clang-uml, version 0.5.1
|
||||||
|
'LLVM version clang version 17.0.6 (Fedora 17.0.6-2.fc39)
|
||||||
|
@enduml
|
1
diagrams/BayesNet.svg
Normal file
1
diagrams/BayesNet.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 139 KiB |
128
diagrams/dependency.svg
Normal file
128
diagrams/dependency.svg
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?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)
|
||||||
|
-->
|
||||||
|
<!-- 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)">
|
||||||
|
<title>BayesNet</title>
|
||||||
|
<polygon fill="white" stroke="none" points="-4,4 -4,-283.8 1627.95,-283.8 1627.95,4 -4,4"/>
|
||||||
|
<!-- node1 -->
|
||||||
|
<g id="node1" 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>
|
||||||
|
</g>
|
||||||
|
<!-- node2 -->
|
||||||
|
<g id="node2" 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>
|
||||||
|
</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"/>
|
||||||
|
</g>
|
||||||
|
<!-- node3 -->
|
||||||
|
<g id="node3" 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>
|
||||||
|
</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"/>
|
||||||
|
</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>
|
||||||
|
</g>
|
||||||
|
<!-- node1->node9 -->
|
||||||
|
<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"/>
|
||||||
|
</g>
|
||||||
|
<!-- node5 -->
|
||||||
|
<g id="node7" 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>
|
||||||
|
</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"/>
|
||||||
|
</g>
|
||||||
|
<!-- node6 -->
|
||||||
|
<g id="node8" 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>
|
||||||
|
</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"/>
|
||||||
|
</g>
|
||||||
|
<!-- node7 -->
|
||||||
|
<g id="node9" 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>
|
||||||
|
</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"/>
|
||||||
|
</g>
|
||||||
|
<!-- node8 -->
|
||||||
|
<g id="node10" 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>
|
||||||
|
</g>
|
||||||
|
<!-- node5->node8 -->
|
||||||
|
<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"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
30
docs/BoostAODE.md
Normal file
30
docs/BoostAODE.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# BoostAODE Algorithm Operation
|
||||||
|
|
||||||
|
## Hyperparameters
|
||||||
|
|
||||||
|
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*.
|
||||||
|
- ***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"*.
|
||||||
|
|
||||||
|
- ***block_update*** (*boolean*): Sets whether the algorithm will update the weights of the models in blocks. If set to false, the algorithm will update the weights of the models one by one. Default value: *false*.
|
||||||
|
|
||||||
|
- ***convergence*** (*boolean*): Sets whether the convergence of the result will be used as a termination condition. If this hyperparameter is set to true, the training dataset passed to the model is divided into two sets, one serving as training data and the other as a test set (so the original test partition will become a validation partition in this case). The partition is made by taking the first partition generated by a process of generating a 5 fold partition with stratification using a predetermined seed. The exit condition used in this *convergence* is that the difference between the accuracy obtained by the current model and that obtained by the previous model is greater than *1e-4*; otherwise, one will be added to the number of models that worsen the result (see next hyperparameter). Default value: *true*.
|
||||||
|
|
||||||
|
- ***maxTolerance*** (*int*): Sets the maximum number of models that can worsen the result without constituting a termination condition. if ***bisection*** is set to *true*, the value of this hyperparameter will be exponent of base 2 to compute the number of models to insert at once. Default value: *3*
|
||||||
|
|
||||||
|
- ***select_features*** (*{"IWSS", "FCBF", "CFS", ""}*): Selects the variable selection method to be used to build initial models for the ensemble that will be included without considering any of the other exit conditions. Once the models of the selected variables are built, the algorithm will update the weights using the ensemble and set the significance of all the models built with the same α<sub>t</sub>. Default value: *""*.
|
||||||
|
|
||||||
|
- ***threshold*** (*double*): Sets the necessary value for the IWSS and FCBF algorithms to function. Accepted values are:
|
||||||
|
- IWSS: $threshold \in [0, 0.5]$
|
||||||
|
- FCBF: $threshold \in [10^{-7}, 1]$
|
||||||
|
|
||||||
|
Default value is *-1* so every time any of those algorithms are called, the threshold has to be set to the desired value.
|
||||||
|
|
||||||
|
- ***predict_voting*** (*boolean*): Sets whether the algorithm will use *model voting* to predict the result. If set to false, the weighted average of the probabilities of each model's prediction will be used. Default value: *false*.
|
||||||
|
|
||||||
|
## Operation
|
||||||
|
|
||||||
|
### [Algorithm](./algorithm.md)
|
BIN
docs/BoostAODE_train_predict.odp
Normal file
BIN
docs/BoostAODE_train_predict.odp
Normal file
Binary file not shown.
BIN
docs/BoostAODE_train_predict.pdf
Normal file
BIN
docs/BoostAODE_train_predict.pdf
Normal file
Binary file not shown.
117
docs/algorithm.md
Normal file
117
docs/algorithm.md
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
# Algorithm
|
||||||
|
|
||||||
|
- // notation
|
||||||
|
|
||||||
|
- $n$ features ${\cal{X}} = \{X_1, \dots, X_n\}$ and the class $Y$
|
||||||
|
|
||||||
|
- $m$ instances.
|
||||||
|
|
||||||
|
- $D = \{ (x_1^i, \dots, x_n^i, y^i) \}_{i=1}^{m}$
|
||||||
|
|
||||||
|
- $W$ a weights vector. $W_0$ are the initial weights.
|
||||||
|
|
||||||
|
- $D[W]$ dataset with weights $W$ for the instances.
|
||||||
|
|
||||||
|
1. // initialization
|
||||||
|
|
||||||
|
2. $W_0 \leftarrow (w_1, \dots, w_m) \leftarrow 1/m$
|
||||||
|
|
||||||
|
3. $W \leftarrow W_0$
|
||||||
|
|
||||||
|
4. $Vars \leftarrow {\cal{X}}$
|
||||||
|
|
||||||
|
5. $\delta \leftarrow 10^{-4}$
|
||||||
|
|
||||||
|
6. $convergence \leftarrow True$ // hyperparameter
|
||||||
|
|
||||||
|
7. $maxTolerancia \leftarrow 3$ // hyperparameter
|
||||||
|
|
||||||
|
8. $bisection \leftarrow False$ // hyperparameter
|
||||||
|
|
||||||
|
9. $finished \leftarrow False$
|
||||||
|
|
||||||
|
10. $AODE \leftarrow \emptyset$ // the ensemble
|
||||||
|
|
||||||
|
11. $tolerance \leftarrow 0$
|
||||||
|
|
||||||
|
12. $numModelsInPack \leftarrow 0$
|
||||||
|
|
||||||
|
13. $maxAccuracy \leftarrow -1$
|
||||||
|
|
||||||
|
14.
|
||||||
|
|
||||||
|
15. // main loop
|
||||||
|
|
||||||
|
16. While $(\lnot finished)$
|
||||||
|
|
||||||
|
1. $\pi \leftarrow SortFeatures(Vars, criterio, D[W])$
|
||||||
|
|
||||||
|
2. $k \leftarrow 2^{tolerance}$
|
||||||
|
|
||||||
|
3. if ($tolerance == 0$) $numItemsPack \leftarrow0$
|
||||||
|
|
||||||
|
4. $P \leftarrow Head(\pi,k)$ // first k features in order
|
||||||
|
|
||||||
|
5. $spodes \leftarrow \emptyset$
|
||||||
|
|
||||||
|
6. $i \leftarrow 0$
|
||||||
|
|
||||||
|
7. While ($i < size(P)$)
|
||||||
|
|
||||||
|
1. $X \leftarrow P[i]$
|
||||||
|
|
||||||
|
2. $i \leftarrow i + 1$
|
||||||
|
|
||||||
|
3. $numItemsPack \leftarrow numItemsPack + 1$
|
||||||
|
|
||||||
|
4. $Vars.remove(X)$
|
||||||
|
|
||||||
|
5. $spode \leftarrow BuildSpode(X, {\cal{X}}, D[W])$
|
||||||
|
|
||||||
|
6. $\hat{y}[] \leftarrow spode.Predict(D)$
|
||||||
|
|
||||||
|
7. $\epsilon \leftarrow error(\hat{y}[], y[])$
|
||||||
|
|
||||||
|
8. $\alpha \leftarrow \frac{1}{2} ln \left ( \frac{1-\epsilon}{\epsilon} \right )$
|
||||||
|
|
||||||
|
9. if ($\epsilon > 0.5$)
|
||||||
|
|
||||||
|
1. $finished \leftarrow True$
|
||||||
|
|
||||||
|
2. break
|
||||||
|
|
||||||
|
10. $spodes.add( (spode,\alpha_t) )$
|
||||||
|
|
||||||
|
11. $W \leftarrow UpdateWeights(W,\alpha,y[],\hat{y}[])$
|
||||||
|
|
||||||
|
8. $AODE.add( spodes )$
|
||||||
|
|
||||||
|
9. if ($convergence \land \lnot finished$)
|
||||||
|
|
||||||
|
1. $\hat{y}[] \leftarrow AODE.Predict(D)$
|
||||||
|
|
||||||
|
2. $actualAccuracy \leftarrow accuracy(\hat{y}[], y[])$
|
||||||
|
|
||||||
|
3. $if (maxAccuracy == -1)\; maxAccuracy \leftarrow actualAccuracy$
|
||||||
|
|
||||||
|
4. if $((accuracy - maxAccuracy) < \delta)$ // result doesn't
|
||||||
|
improve enough
|
||||||
|
|
||||||
|
1. $tolerance \leftarrow tolerance + 1$
|
||||||
|
|
||||||
|
5. else
|
||||||
|
|
||||||
|
1. $tolerance \leftarrow 0$
|
||||||
|
|
||||||
|
2. $numItemsPack \leftarrow 0$
|
||||||
|
|
||||||
|
10. If $(Vars == \emptyset \lor tolerance>maxTolerance) \; finished \leftarrow True$
|
||||||
|
|
||||||
|
11. $lastAccuracy \leftarrow max(lastAccuracy, actualAccuracy)$
|
||||||
|
|
||||||
|
17. if ($tolerance > maxTolerance$) // algorithm finished because of
|
||||||
|
lack of convergence
|
||||||
|
|
||||||
|
1. $removeModels(AODE, numItemsPack)$
|
||||||
|
|
||||||
|
18. Return $AODE$
|
80
docs/algorithm.tex
Normal file
80
docs/algorithm.tex
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
\section{Algorithm}
|
||||||
|
\begin{itemize}
|
||||||
|
\item[] // notation
|
||||||
|
\item $n$ features ${\cal{X}} = \{X_1, \dots, X_n\}$ and the class $Y$
|
||||||
|
\item $m$ instances.
|
||||||
|
\item $D = \{ (x_1^i, \dots, x_n^i, y^i) \}_{i=1}^{m}$
|
||||||
|
\item $W$ a weights vector. $W_0$ are the initial weights.
|
||||||
|
\item $D[W]$ dataset with weights $W$ for the instances.
|
||||||
|
\end{itemize}
|
||||||
|
\bigskip
|
||||||
|
|
||||||
|
|
||||||
|
\begin{enumerate}
|
||||||
|
\item[] // initialization
|
||||||
|
\item $W_0 \leftarrow (w_1, \dots, w_m) \leftarrow 1/m$
|
||||||
|
\item $W \leftarrow W_0$
|
||||||
|
\item $Vars \leftarrow {\cal{X}}$
|
||||||
|
\item $\delta \leftarrow 10^{-4}$
|
||||||
|
\item $convergence \leftarrow True$ // hyperparameter
|
||||||
|
\item $maxTolerancia \leftarrow 3$ // hyperparameter
|
||||||
|
\item $bisection \leftarrow False$ // hyperparameter
|
||||||
|
\item $finished \leftarrow False$
|
||||||
|
\item $AODE \leftarrow \emptyset$ \hspace*{2cm} // the ensemble
|
||||||
|
\item $tolerance \leftarrow 0$
|
||||||
|
\item $numModelsInPack \leftarrow 0$
|
||||||
|
\item $maxAccuracy \leftarrow -1$
|
||||||
|
\item[]
|
||||||
|
\newpage
|
||||||
|
\item[] // main loop
|
||||||
|
\item While $(\lnot finished)$
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $\pi \leftarrow SortFeatures(Vars, criterio, D[W])$
|
||||||
|
\item $k \leftarrow 2^{tolerance}$
|
||||||
|
\item if ($tolerance == 0$) $numItemsPack \leftarrow0$
|
||||||
|
\item $P \leftarrow Head(\pi,k)$ \hspace*{2cm} // first k features in order
|
||||||
|
\item $spodes \leftarrow \emptyset$
|
||||||
|
\item $i \leftarrow 0$
|
||||||
|
\item While ($ i < size(P)$)
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $X \leftarrow P[i]$
|
||||||
|
\item $i \leftarrow i + 1$
|
||||||
|
\item $numItemsPack \leftarrow numItemsPack + 1$
|
||||||
|
\item $Vars.remove(X)$
|
||||||
|
\item $spode \leftarrow BuildSpode(X, {\cal{X}}, D[W])$
|
||||||
|
\item $\hat{y}[] \leftarrow spode.Predict(D)$
|
||||||
|
\item $\epsilon \leftarrow error(\hat{y}[], y[])$
|
||||||
|
\item $\alpha \leftarrow \frac{1}{2} ln \left ( \frac{1-\epsilon}{\epsilon} \right )$
|
||||||
|
\item if ($\epsilon > 0.5$)
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $finished \leftarrow True$
|
||||||
|
\item break
|
||||||
|
\end{enumerate}
|
||||||
|
\item $spodes.add( (spode,\alpha_t) )$
|
||||||
|
\item $W \leftarrow UpdateWeights(W,\alpha,y[],\hat{y}[])$
|
||||||
|
\end{enumerate}
|
||||||
|
\item $AODE.add( spodes )$
|
||||||
|
\item if ($convergence \land \lnot finished$)
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $\hat{y}[] \leftarrow AODE.Predict(D)$
|
||||||
|
\item $actualAccuracy \leftarrow accuracy(\hat{y}[], y[])$
|
||||||
|
\item $if (maxAccuracy == -1)\; maxAccuracy \leftarrow actualAccuracy$
|
||||||
|
\item if $((accuracy - maxAccuracy) < \delta)$\hspace*{2cm} // result doesn't improve enough
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $tolerance \leftarrow tolerance + 1$
|
||||||
|
\end{enumerate}
|
||||||
|
\item else
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $tolerance \leftarrow 0$
|
||||||
|
\item $numItemsPack \leftarrow 0$
|
||||||
|
\end{enumerate}
|
||||||
|
\end{enumerate}
|
||||||
|
\item If $(Vars == \emptyset \lor tolerance>maxTolerance) \; finished \leftarrow True$
|
||||||
|
\item $lastAccuracy \leftarrow max(lastAccuracy, actualAccuracy)$
|
||||||
|
\end{enumerate}
|
||||||
|
\item if ($tolerance > maxTolerance$) \hspace*{1cm} // algorithm finished because of lack of convergence
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $removeModels(AODE, numItemsPack)$
|
||||||
|
\end{enumerate}
|
||||||
|
\item Return $AODE$
|
||||||
|
\end{enumerate}
|
BIN
docs/coverage.pdf
Normal file
BIN
docs/coverage.pdf
Normal file
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
filter = src/
|
|
||||||
exclude-directories = build_debug/lib/
|
|
||||||
print-summary = yes
|
|
||||||
sort-percentage = yes
|
|
BIN
html/amber.png
Normal file
BIN
html/amber.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 141 B |
90
html/bayesnet/BaseClassifier.h.func-c.html
Normal file
90
html/bayesnet/BaseClassifier.h.func-c.html
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet</a> - BaseClassifier.h<span style="font-size: 80%;"> (<a href="BaseClassifier.h.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="BaseClassifier.h.func.html"><img src="../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="BaseClassifier.h.gcov.html#L19">bayesnet::BaseClassifier::~BaseClassifier()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1680</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
90
html/bayesnet/BaseClassifier.h.func.html
Normal file
90
html/bayesnet/BaseClassifier.h.func.html
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet</a> - BaseClassifier.h<span style="font-size: 80%;"> (<a href="BaseClassifier.h.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="BaseClassifier.h.func-c.html"><img src="../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="BaseClassifier.h.gcov.html#L19">bayesnet::BaseClassifier::~BaseClassifier()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1680</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
19
html/bayesnet/BaseClassifier.h.gcov.frameset.html
Normal file
19
html/bayesnet/BaseClassifier.h.gcov.frameset.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<frameset cols="120,*">
|
||||||
|
<frame src="BaseClassifier.h.gcov.overview.html" name="overview">
|
||||||
|
<frame src="BaseClassifier.h.gcov.html" name="source">
|
||||||
|
<noframes>
|
||||||
|
<center>Frames not supported by your browser!<br></center>
|
||||||
|
</noframes>
|
||||||
|
</frameset>
|
||||||
|
|
||||||
|
</html>
|
129
html/bayesnet/BaseClassifier.h.gcov.html
Normal file
129
html/bayesnet/BaseClassifier.h.gcov.html
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet</a> - BaseClassifier.h<span style="font-size: 80%;"> (source / <a href="BaseClassifier.h.func-c.html">functions</a>)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
<td class="headerCovTableEntry">1</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table cellpadding=0 cellspacing=0 border=0>
|
||||||
|
<tr>
|
||||||
|
<td><br></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<pre class="sourceHeading"> Line data Source code</pre>
|
||||||
|
<pre class="source">
|
||||||
|
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
||||||
|
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
||||||
|
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
||||||
|
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
||||||
|
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
||||||
|
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
||||||
|
<span id="L7"><span class="lineNum"> 7</span> : #pragma once</span>
|
||||||
|
<span id="L8"><span class="lineNum"> 8</span> : #include <vector></span>
|
||||||
|
<span id="L9"><span class="lineNum"> 9</span> : #include <torch/torch.h></span>
|
||||||
|
<span id="L10"><span class="lineNum"> 10</span> : #include <nlohmann/json.hpp></span>
|
||||||
|
<span id="L11"><span class="lineNum"> 11</span> : namespace bayesnet {</span>
|
||||||
|
<span id="L12"><span class="lineNum"> 12</span> : enum status_t { NORMAL, WARNING, ERROR };</span>
|
||||||
|
<span id="L13"><span class="lineNum"> 13</span> : class BaseClassifier {</span>
|
||||||
|
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
|
||||||
|
<span id="L15"><span class="lineNum"> 15</span> : // X is nxm std::vector, y is nx1 std::vector</span>
|
||||||
|
<span id="L16"><span class="lineNum"> 16</span> : virtual BaseClassifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;</span>
|
||||||
|
<span id="L17"><span class="lineNum"> 17</span> : // X is nxm tensor, y is nx1 tensor</span>
|
||||||
|
<span id="L18"><span class="lineNum"> 18</span> : virtual BaseClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;</span>
|
||||||
|
<span id="L19"><span class="lineNum"> 19</span> : virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;</span>
|
||||||
|
<span id="L20"><span class="lineNum"> 20</span> : virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) = 0;</span>
|
||||||
|
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC tlaBgGNC"> 1680 : virtual ~BaseClassifier() = default;</span></span>
|
||||||
|
<span id="L22"><span class="lineNum"> 22</span> : torch::Tensor virtual predict(torch::Tensor& X) = 0;</span>
|
||||||
|
<span id="L23"><span class="lineNum"> 23</span> : std::vector<int> virtual predict(std::vector<std::vector<int >>& X) = 0;</span>
|
||||||
|
<span id="L24"><span class="lineNum"> 24</span> : torch::Tensor virtual predict_proba(torch::Tensor& X) = 0;</span>
|
||||||
|
<span id="L25"><span class="lineNum"> 25</span> : std::vector<std::vector<double>> virtual predict_proba(std::vector<std::vector<int >>& X) = 0;</span>
|
||||||
|
<span id="L26"><span class="lineNum"> 26</span> : status_t virtual getStatus() const = 0;</span>
|
||||||
|
<span id="L27"><span class="lineNum"> 27</span> : float virtual score(std::vector<std::vector<int>>& X, std::vector<int>& y) = 0;</span>
|
||||||
|
<span id="L28"><span class="lineNum"> 28</span> : float virtual score(torch::Tensor& X, torch::Tensor& y) = 0;</span>
|
||||||
|
<span id="L29"><span class="lineNum"> 29</span> : int virtual getNumberOfNodes()const = 0;</span>
|
||||||
|
<span id="L30"><span class="lineNum"> 30</span> : int virtual getNumberOfEdges()const = 0;</span>
|
||||||
|
<span id="L31"><span class="lineNum"> 31</span> : int virtual getNumberOfStates() const = 0;</span>
|
||||||
|
<span id="L32"><span class="lineNum"> 32</span> : int virtual getClassNumStates() const = 0;</span>
|
||||||
|
<span id="L33"><span class="lineNum"> 33</span> : std::vector<std::string> virtual show() const = 0;</span>
|
||||||
|
<span id="L34"><span class="lineNum"> 34</span> : std::vector<std::string> virtual graph(const std::string& title = "") const = 0;</span>
|
||||||
|
<span id="L35"><span class="lineNum"> 35</span> : virtual std::string getVersion() = 0;</span>
|
||||||
|
<span id="L36"><span class="lineNum"> 36</span> : std::vector<std::string> virtual topological_order() = 0;</span>
|
||||||
|
<span id="L37"><span class="lineNum"> 37</span> : std::vector<std::string> virtual getNotes() const = 0;</span>
|
||||||
|
<span id="L38"><span class="lineNum"> 38</span> : std::string virtual dump_cpt()const = 0;</span>
|
||||||
|
<span id="L39"><span class="lineNum"> 39</span> : virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;</span>
|
||||||
|
<span id="L40"><span class="lineNum"> 40</span> : std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }</span>
|
||||||
|
<span id="L41"><span class="lineNum"> 41</span> : protected:</span>
|
||||||
|
<span id="L42"><span class="lineNum"> 42</span> : virtual void trainModel(const torch::Tensor& weights) = 0;</span>
|
||||||
|
<span id="L43"><span class="lineNum"> 43</span> : std::vector<std::string> validHyperparameters;</span>
|
||||||
|
<span id="L44"><span class="lineNum"> 44</span> : };</span>
|
||||||
|
<span id="L45"><span class="lineNum"> 45</span> : }</span>
|
||||||
|
</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
32
html/bayesnet/BaseClassifier.h.gcov.overview.html
Normal file
32
html/bayesnet/BaseClassifier.h.gcov.overview.html
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/BaseClassifier.h</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<map name="overview">
|
||||||
|
<area shape="rect" coords="0,0,79,3" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,4,79,7" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,8,79,11" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,12,79,15" href="BaseClassifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,16,79,19" href="BaseClassifier.h.gcov.html#L5" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,20,79,23" href="BaseClassifier.h.gcov.html#L9" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,24,79,27" href="BaseClassifier.h.gcov.html#L13" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,28,79,31" href="BaseClassifier.h.gcov.html#L17" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,32,79,35" href="BaseClassifier.h.gcov.html#L21" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,36,79,39" href="BaseClassifier.h.gcov.html#L25" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,40,79,43" href="BaseClassifier.h.gcov.html#L29" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,44,79,47" href="BaseClassifier.h.gcov.html#L33" target="source" alt="overview">
|
||||||
|
</map>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<a href="BaseClassifier.h.gcov.html#top" target="source">Top</a><br><br>
|
||||||
|
<img src="BaseClassifier.h.gcov.png" width=80 height=44 alt="Overview" border=0 usemap="#overview">
|
||||||
|
</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
html/bayesnet/BaseClassifier.h.gcov.png
Normal file
BIN
html/bayesnet/BaseClassifier.h.gcov.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 372 B |
251
html/bayesnet/classifiers/Classifier.cc.func-c.html
Normal file
251
html/bayesnet/classifiers/Classifier.cc.func-c.html
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.cc<span style="font-size: 80%;"> (<a href="Classifier.cc.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">126</td>
|
||||||
|
<td class="headerCovTableEntry">126</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">24</td>
|
||||||
|
<td class="headerCovTableEntry">24</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="Classifier.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">bayesnet::Classifier::dump_cpt[abi:cxx11]() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">4</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">bayesnet::Classifier::topological_order[abi:cxx11]()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">4</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">16</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">16</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">bayesnet::Classifier::getNumberOfStates() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">24</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">bayesnet::Classifier::show[abi:cxx11]() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">24</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">bayesnet::Classifier::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">92</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&, at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">112</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&, at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">128</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">136</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">bayesnet::Classifier::getNumberOfEdges() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">332</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">bayesnet::Classifier::getNumberOfNodes() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">332</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">340</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">bayesnet::Classifier::getClassNumStates() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">348</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">bayesnet::Classifier::predict_proba(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">548</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">660</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">852</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">bayesnet::Classifier::predict_proba(at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1484</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">bayesnet::Classifier::addNodes()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1576</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">bayesnet::Classifier::trainModel(at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1576</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1760</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">bayesnet::Classifier::checkFitParameters()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1760</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">bayesnet::Classifier::predict(at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1844</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">bayesnet::Classifier::Classifier(bayesnet::Network)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">2240</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
251
html/bayesnet/classifiers/Classifier.cc.func.html
Normal file
251
html/bayesnet/classifiers/Classifier.cc.func.html
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.cc<span style="font-size: 80%;"> (<a href="Classifier.cc.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">126</td>
|
||||||
|
<td class="headerCovTableEntry">126</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">24</td>
|
||||||
|
<td class="headerCovTableEntry">24</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="Classifier.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">bayesnet::Classifier::Classifier(bayesnet::Network)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">2240</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">bayesnet::Classifier::addNodes()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1576</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1760</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">340</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">bayesnet::Classifier::checkFitParameters()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1760</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">bayesnet::Classifier::dump_cpt[abi:cxx11]() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">4</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&, at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">128</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">852</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&, at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">660</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<int, std::allocator<int> > > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">136</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">bayesnet::Classifier::getClassNumStates() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">348</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">bayesnet::Classifier::getNumberOfEdges() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">332</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">bayesnet::Classifier::getNumberOfNodes() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">332</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">bayesnet::Classifier::getNumberOfStates() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">24</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">bayesnet::Classifier::predict(at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1844</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">16</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">bayesnet::Classifier::predict_proba(at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1484</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">bayesnet::Classifier::predict_proba(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">548</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&, at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">112</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<int, std::allocator<int> >&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">16</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">bayesnet::Classifier::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">92</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">bayesnet::Classifier::show[abi:cxx11]() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">24</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">bayesnet::Classifier::topological_order[abi:cxx11]()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">4</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">bayesnet::Classifier::trainModel(at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1576</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
19
html/bayesnet/classifiers/Classifier.cc.gcov.frameset.html
Normal file
19
html/bayesnet/classifiers/Classifier.cc.gcov.frameset.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<frameset cols="120,*">
|
||||||
|
<frame src="Classifier.cc.gcov.overview.html" name="overview">
|
||||||
|
<frame src="Classifier.cc.gcov.html" name="source">
|
||||||
|
<noframes>
|
||||||
|
<center>Frames not supported by your browser!<br></center>
|
||||||
|
</noframes>
|
||||||
|
</frameset>
|
||||||
|
|
||||||
|
</html>
|
278
html/bayesnet/classifiers/Classifier.cc.gcov.html
Normal file
278
html/bayesnet/classifiers/Classifier.cc.gcov.html
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.cc<span style="font-size: 80%;"> (source / <a href="Classifier.cc.func-c.html">functions</a>)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">126</td>
|
||||||
|
<td class="headerCovTableEntry">126</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">24</td>
|
||||||
|
<td class="headerCovTableEntry">24</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table cellpadding=0 cellspacing=0 border=0>
|
||||||
|
<tr>
|
||||||
|
<td><br></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<pre class="sourceHeading"> Line data Source code</pre>
|
||||||
|
<pre class="source">
|
||||||
|
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
||||||
|
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
||||||
|
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
||||||
|
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
||||||
|
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
||||||
|
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
||||||
|
<span id="L7"><span class="lineNum"> 7</span> : #include <sstream></span>
|
||||||
|
<span id="L8"><span class="lineNum"> 8</span> : #include "bayesnet/utils/bayesnetUtils.h"</span>
|
||||||
|
<span id="L9"><span class="lineNum"> 9</span> : #include "Classifier.h"</span>
|
||||||
|
<span id="L10"><span class="lineNum"> 10</span> : </span>
|
||||||
|
<span id="L11"><span class="lineNum"> 11</span> : namespace bayesnet {</span>
|
||||||
|
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC tlaBgGNC"> 2240 : Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}</span></span>
|
||||||
|
<span id="L13"><span class="lineNum"> 13</span> : const std::string CLASSIFIER_NOT_FITTED = "Classifier has not been fitted";</span>
|
||||||
|
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 1760 : Classifier& Classifier::build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)</span></span>
|
||||||
|
<span id="L15"><span class="lineNum"> 15</span> : {</span>
|
||||||
|
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 1760 : this->features = features;</span></span>
|
||||||
|
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 1760 : this->className = className;</span></span>
|
||||||
|
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 1760 : this->states = states;</span></span>
|
||||||
|
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 1760 : m = dataset.size(1);</span></span>
|
||||||
|
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 1760 : n = features.size();</span></span>
|
||||||
|
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 1760 : checkFitParameters();</span></span>
|
||||||
|
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 1728 : auto n_classes = states.at(className).size();</span></span>
|
||||||
|
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 1728 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
|
||||||
|
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 1728 : model.initialize();</span></span>
|
||||||
|
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 1728 : buildModel(weights);</span></span>
|
||||||
|
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 1728 : trainModel(weights);</span></span>
|
||||||
|
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 1712 : fitted = true;</span></span>
|
||||||
|
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 1712 : return *this;</span></span>
|
||||||
|
<span id="L29"><span class="lineNum"> 29</span> : }</span>
|
||||||
|
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 340 : void Classifier::buildDataset(torch::Tensor& ytmp)</span></span>
|
||||||
|
<span id="L31"><span class="lineNum"> 31</span> : {</span>
|
||||||
|
<span id="L32"><span class="lineNum"> 32</span> : try {</span>
|
||||||
|
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 340 : auto yresized = torch::transpose(ytmp.view({ ytmp.size(0), 1 }), 0, 1);</span></span>
|
||||||
|
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 1052 : dataset = torch::cat({ dataset, yresized }, 0);</span></span>
|
||||||
|
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 340 : }</span></span>
|
||||||
|
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 16 : catch (const std::exception& e) {</span></span>
|
||||||
|
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 16 : std::stringstream oss;</span></span>
|
||||||
|
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 16 : oss << "* Error in X and y dimensions *\n";</span></span>
|
||||||
|
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 16 : oss << "X dimensions: " << dataset.sizes() << "\n";</span></span>
|
||||||
|
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 16 : oss << "y dimensions: " << ytmp.sizes();</span></span>
|
||||||
|
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 16 : throw std::runtime_error(oss.str());</span></span>
|
||||||
|
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 32 : }</span></span>
|
||||||
|
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 680 : }</span></span>
|
||||||
|
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 1576 : void Classifier::trainModel(const torch::Tensor& weights)</span></span>
|
||||||
|
<span id="L45"><span class="lineNum"> 45</span> : {</span>
|
||||||
|
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 1576 : model.fit(dataset, weights, features, className, states);</span></span>
|
||||||
|
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 1576 : }</span></span>
|
||||||
|
<span id="L48"><span class="lineNum"> 48</span> : // X is nxm where n is the number of features and m the number of samples</span>
|
||||||
|
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 128 : Classifier& Classifier::fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)</span></span>
|
||||||
|
<span id="L50"><span class="lineNum"> 50</span> : {</span>
|
||||||
|
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 128 : dataset = X;</span></span>
|
||||||
|
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 128 : buildDataset(y);</span></span>
|
||||||
|
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 120 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
|
||||||
|
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 208 : return build(features, className, states, weights);</span></span>
|
||||||
|
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 120 : }</span></span>
|
||||||
|
<span id="L56"><span class="lineNum"> 56</span> : // X is nxm where n is the number of features and m the number of samples</span>
|
||||||
|
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 136 : Classifier& Classifier::fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)</span></span>
|
||||||
|
<span id="L58"><span class="lineNum"> 58</span> : {</span>
|
||||||
|
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 136 : dataset = torch::zeros({ static_cast<int>(X.size()), static_cast<int>(X[0].size()) }, torch::kInt32);</span></span>
|
||||||
|
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 976 : for (int i = 0; i < X.size(); ++i) {</span></span>
|
||||||
|
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 3360 : dataset.index_put_({ i, "..." }, torch::tensor(X[i], torch::kInt32));</span></span>
|
||||||
|
<span id="L62"><span class="lineNum"> 62</span> : }</span>
|
||||||
|
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 136 : auto ytmp = torch::tensor(y, torch::kInt32);</span></span>
|
||||||
|
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 136 : buildDataset(ytmp);</span></span>
|
||||||
|
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 128 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
|
||||||
|
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 240 : return build(features, className, states, weights);</span></span>
|
||||||
|
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 992 : }</span></span>
|
||||||
|
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 852 : Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)</span></span>
|
||||||
|
<span id="L69"><span class="lineNum"> 69</span> : {</span>
|
||||||
|
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 852 : this->dataset = dataset;</span></span>
|
||||||
|
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 852 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
|
||||||
|
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 1704 : return build(features, className, states, weights);</span></span>
|
||||||
|
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 852 : }</span></span>
|
||||||
|
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 660 : Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)</span></span>
|
||||||
|
<span id="L75"><span class="lineNum"> 75</span> : {</span>
|
||||||
|
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 660 : this->dataset = dataset;</span></span>
|
||||||
|
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 660 : return build(features, className, states, weights);</span></span>
|
||||||
|
<span id="L78"><span class="lineNum"> 78</span> : }</span>
|
||||||
|
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 1760 : void Classifier::checkFitParameters()</span></span>
|
||||||
|
<span id="L80"><span class="lineNum"> 80</span> : {</span>
|
||||||
|
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 1760 : if (torch::is_floating_point(dataset)) {</span></span>
|
||||||
|
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("dataset (X, y) must be of type Integer");</span></span>
|
||||||
|
<span id="L83"><span class="lineNum"> 83</span> : }</span>
|
||||||
|
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 1752 : if (dataset.size(0) - 1 != features.size()) {</span></span>
|
||||||
|
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("Classifier: X " + std::to_string(dataset.size(0) - 1) + " and features " + std::to_string(features.size()) + " must have the same number of features");</span></span>
|
||||||
|
<span id="L86"><span class="lineNum"> 86</span> : }</span>
|
||||||
|
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 1744 : if (states.find(className) == states.end()) {</span></span>
|
||||||
|
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("class name not found in states");</span></span>
|
||||||
|
<span id="L89"><span class="lineNum"> 89</span> : }</span>
|
||||||
|
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 32996 : for (auto feature : features) {</span></span>
|
||||||
|
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 31268 : if (states.find(feature) == states.end()) {</span></span>
|
||||||
|
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("feature [" + feature + "] not found in states");</span></span>
|
||||||
|
<span id="L93"><span class="lineNum"> 93</span> : }</span>
|
||||||
|
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 31268 : }</span></span>
|
||||||
|
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 1728 : }</span></span>
|
||||||
|
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 1844 : torch::Tensor Classifier::predict(torch::Tensor& X)</span></span>
|
||||||
|
<span id="L97"><span class="lineNum"> 97</span> : {</span>
|
||||||
|
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 1844 : if (!fitted) {</span></span>
|
||||||
|
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 16 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
||||||
|
<span id="L100"><span class="lineNum"> 100</span> : }</span>
|
||||||
|
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 1828 : return model.predict(X);</span></span>
|
||||||
|
<span id="L102"><span class="lineNum"> 102</span> : }</span>
|
||||||
|
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 16 : std::vector<int> Classifier::predict(std::vector<std::vector<int>>& X)</span></span>
|
||||||
|
<span id="L104"><span class="lineNum"> 104</span> : {</span>
|
||||||
|
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 16 : if (!fitted) {</span></span>
|
||||||
|
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
||||||
|
<span id="L107"><span class="lineNum"> 107</span> : }</span>
|
||||||
|
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 8 : auto m_ = X[0].size();</span></span>
|
||||||
|
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 8 : auto n_ = X.size();</span></span>
|
||||||
|
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 8 : std::vector<std::vector<int>> Xd(n_, std::vector<int>(m_, 0));</span></span>
|
||||||
|
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 40 : for (auto i = 0; i < n_; i++) {</span></span>
|
||||||
|
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 64 : Xd[i] = std::vector<int>(X[i].begin(), X[i].end());</span></span>
|
||||||
|
<span id="L113"><span class="lineNum"> 113</span> : }</span>
|
||||||
|
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 8 : auto yp = model.predict(Xd);</span></span>
|
||||||
|
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 16 : return yp;</span></span>
|
||||||
|
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 8 : }</span></span>
|
||||||
|
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 1484 : torch::Tensor Classifier::predict_proba(torch::Tensor& X)</span></span>
|
||||||
|
<span id="L118"><span class="lineNum"> 118</span> : {</span>
|
||||||
|
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 1484 : if (!fitted) {</span></span>
|
||||||
|
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
||||||
|
<span id="L121"><span class="lineNum"> 121</span> : }</span>
|
||||||
|
<span id="L122"><span class="lineNum"> 122</span> <span class="tlaGNC"> 1476 : return model.predict_proba(X);</span></span>
|
||||||
|
<span id="L123"><span class="lineNum"> 123</span> : }</span>
|
||||||
|
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 548 : std::vector<std::vector<double>> Classifier::predict_proba(std::vector<std::vector<int>>& X)</span></span>
|
||||||
|
<span id="L125"><span class="lineNum"> 125</span> : {</span>
|
||||||
|
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 548 : if (!fitted) {</span></span>
|
||||||
|
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
||||||
|
<span id="L128"><span class="lineNum"> 128</span> : }</span>
|
||||||
|
<span id="L129"><span class="lineNum"> 129</span> <span class="tlaGNC"> 540 : auto m_ = X[0].size();</span></span>
|
||||||
|
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 540 : auto n_ = X.size();</span></span>
|
||||||
|
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 540 : std::vector<std::vector<int>> Xd(n_, std::vector<int>(m_, 0));</span></span>
|
||||||
|
<span id="L132"><span class="lineNum"> 132</span> : // Convert to nxm vector</span>
|
||||||
|
<span id="L133"><span class="lineNum"> 133</span> <span class="tlaGNC"> 5040 : for (auto i = 0; i < n_; i++) {</span></span>
|
||||||
|
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 9000 : Xd[i] = std::vector<int>(X[i].begin(), X[i].end());</span></span>
|
||||||
|
<span id="L135"><span class="lineNum"> 135</span> : }</span>
|
||||||
|
<span id="L136"><span class="lineNum"> 136</span> <span class="tlaGNC"> 540 : auto yp = model.predict_proba(Xd);</span></span>
|
||||||
|
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 1080 : return yp;</span></span>
|
||||||
|
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 540 : }</span></span>
|
||||||
|
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 112 : float Classifier::score(torch::Tensor& X, torch::Tensor& y)</span></span>
|
||||||
|
<span id="L140"><span class="lineNum"> 140</span> : {</span>
|
||||||
|
<span id="L141"><span class="lineNum"> 141</span> <span class="tlaGNC"> 112 : torch::Tensor y_pred = predict(X);</span></span>
|
||||||
|
<span id="L142"><span class="lineNum"> 142</span> <span class="tlaGNC"> 208 : return (y_pred == y).sum().item<float>() / y.size(0);</span></span>
|
||||||
|
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 104 : }</span></span>
|
||||||
|
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 16 : float Classifier::score(std::vector<std::vector<int>>& X, std::vector<int>& y)</span></span>
|
||||||
|
<span id="L145"><span class="lineNum"> 145</span> : {</span>
|
||||||
|
<span id="L146"><span class="lineNum"> 146</span> <span class="tlaGNC"> 16 : if (!fitted) {</span></span>
|
||||||
|
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
|
||||||
|
<span id="L148"><span class="lineNum"> 148</span> : }</span>
|
||||||
|
<span id="L149"><span class="lineNum"> 149</span> <span class="tlaGNC"> 8 : return model.score(X, y);</span></span>
|
||||||
|
<span id="L150"><span class="lineNum"> 150</span> : }</span>
|
||||||
|
<span id="L151"><span class="lineNum"> 151</span> <span class="tlaGNC"> 24 : std::vector<std::string> Classifier::show() const</span></span>
|
||||||
|
<span id="L152"><span class="lineNum"> 152</span> : {</span>
|
||||||
|
<span id="L153"><span class="lineNum"> 153</span> <span class="tlaGNC"> 24 : return model.show();</span></span>
|
||||||
|
<span id="L154"><span class="lineNum"> 154</span> : }</span>
|
||||||
|
<span id="L155"><span class="lineNum"> 155</span> <span class="tlaGNC"> 1576 : void Classifier::addNodes()</span></span>
|
||||||
|
<span id="L156"><span class="lineNum"> 156</span> : {</span>
|
||||||
|
<span id="L157"><span class="lineNum"> 157</span> : // Add all nodes to the network</span>
|
||||||
|
<span id="L158"><span class="lineNum"> 158</span> <span class="tlaGNC"> 30872 : for (const auto& feature : features) {</span></span>
|
||||||
|
<span id="L159"><span class="lineNum"> 159</span> <span class="tlaGNC"> 29296 : model.addNode(feature);</span></span>
|
||||||
|
<span id="L160"><span class="lineNum"> 160</span> : }</span>
|
||||||
|
<span id="L161"><span class="lineNum"> 161</span> <span class="tlaGNC"> 1576 : model.addNode(className);</span></span>
|
||||||
|
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 1576 : }</span></span>
|
||||||
|
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 332 : int Classifier::getNumberOfNodes() const</span></span>
|
||||||
|
<span id="L164"><span class="lineNum"> 164</span> : {</span>
|
||||||
|
<span id="L165"><span class="lineNum"> 165</span> : // Features does not include class</span>
|
||||||
|
<span id="L166"><span class="lineNum"> 166</span> <span class="tlaGNC"> 332 : return fitted ? model.getFeatures().size() : 0;</span></span>
|
||||||
|
<span id="L167"><span class="lineNum"> 167</span> : }</span>
|
||||||
|
<span id="L168"><span class="lineNum"> 168</span> <span class="tlaGNC"> 332 : int Classifier::getNumberOfEdges() const</span></span>
|
||||||
|
<span id="L169"><span class="lineNum"> 169</span> : {</span>
|
||||||
|
<span id="L170"><span class="lineNum"> 170</span> <span class="tlaGNC"> 332 : return fitted ? model.getNumEdges() : 0;</span></span>
|
||||||
|
<span id="L171"><span class="lineNum"> 171</span> : }</span>
|
||||||
|
<span id="L172"><span class="lineNum"> 172</span> <span class="tlaGNC"> 24 : int Classifier::getNumberOfStates() const</span></span>
|
||||||
|
<span id="L173"><span class="lineNum"> 173</span> : {</span>
|
||||||
|
<span id="L174"><span class="lineNum"> 174</span> <span class="tlaGNC"> 24 : return fitted ? model.getStates() : 0;</span></span>
|
||||||
|
<span id="L175"><span class="lineNum"> 175</span> : }</span>
|
||||||
|
<span id="L176"><span class="lineNum"> 176</span> <span class="tlaGNC"> 348 : int Classifier::getClassNumStates() const</span></span>
|
||||||
|
<span id="L177"><span class="lineNum"> 177</span> : {</span>
|
||||||
|
<span id="L178"><span class="lineNum"> 178</span> <span class="tlaGNC"> 348 : return fitted ? model.getClassNumStates() : 0;</span></span>
|
||||||
|
<span id="L179"><span class="lineNum"> 179</span> : }</span>
|
||||||
|
<span id="L180"><span class="lineNum"> 180</span> <span class="tlaGNC"> 4 : std::vector<std::string> Classifier::topological_order()</span></span>
|
||||||
|
<span id="L181"><span class="lineNum"> 181</span> : {</span>
|
||||||
|
<span id="L182"><span class="lineNum"> 182</span> <span class="tlaGNC"> 4 : return model.topological_sort();</span></span>
|
||||||
|
<span id="L183"><span class="lineNum"> 183</span> : }</span>
|
||||||
|
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 4 : std::string Classifier::dump_cpt() const</span></span>
|
||||||
|
<span id="L185"><span class="lineNum"> 185</span> : {</span>
|
||||||
|
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 4 : return model.dump_cpt();</span></span>
|
||||||
|
<span id="L187"><span class="lineNum"> 187</span> : }</span>
|
||||||
|
<span id="L188"><span class="lineNum"> 188</span> <span class="tlaGNC"> 92 : void Classifier::setHyperparameters(const nlohmann::json& hyperparameters)</span></span>
|
||||||
|
<span id="L189"><span class="lineNum"> 189</span> : {</span>
|
||||||
|
<span id="L190"><span class="lineNum"> 190</span> <span class="tlaGNC"> 92 : if (!hyperparameters.empty()) {</span></span>
|
||||||
|
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 8 : throw std::invalid_argument("Invalid hyperparameters" + hyperparameters.dump());</span></span>
|
||||||
|
<span id="L192"><span class="lineNum"> 192</span> : }</span>
|
||||||
|
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 84 : }</span></span>
|
||||||
|
<span id="L194"><span class="lineNum"> 194</span> : }</span>
|
||||||
|
</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
69
html/bayesnet/classifiers/Classifier.cc.gcov.overview.html
Normal file
69
html/bayesnet/classifiers/Classifier.cc.gcov.overview.html
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.cc</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<map name="overview">
|
||||||
|
<area shape="rect" coords="0,0,79,3" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,4,79,7" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,8,79,11" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,12,79,15" href="Classifier.cc.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,16,79,19" href="Classifier.cc.gcov.html#L5" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,20,79,23" href="Classifier.cc.gcov.html#L9" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,24,79,27" href="Classifier.cc.gcov.html#L13" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,28,79,31" href="Classifier.cc.gcov.html#L17" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,32,79,35" href="Classifier.cc.gcov.html#L21" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,36,79,39" href="Classifier.cc.gcov.html#L25" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,40,79,43" href="Classifier.cc.gcov.html#L29" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,44,79,47" href="Classifier.cc.gcov.html#L33" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,48,79,51" href="Classifier.cc.gcov.html#L37" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,52,79,55" href="Classifier.cc.gcov.html#L41" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,56,79,59" href="Classifier.cc.gcov.html#L45" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,60,79,63" href="Classifier.cc.gcov.html#L49" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,64,79,67" href="Classifier.cc.gcov.html#L53" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,68,79,71" href="Classifier.cc.gcov.html#L57" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,72,79,75" href="Classifier.cc.gcov.html#L61" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,76,79,79" href="Classifier.cc.gcov.html#L65" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,80,79,83" href="Classifier.cc.gcov.html#L69" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,84,79,87" href="Classifier.cc.gcov.html#L73" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,88,79,91" href="Classifier.cc.gcov.html#L77" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,92,79,95" href="Classifier.cc.gcov.html#L81" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,96,79,99" href="Classifier.cc.gcov.html#L85" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,100,79,103" href="Classifier.cc.gcov.html#L89" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,104,79,107" href="Classifier.cc.gcov.html#L93" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,108,79,111" href="Classifier.cc.gcov.html#L97" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,112,79,115" href="Classifier.cc.gcov.html#L101" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,116,79,119" href="Classifier.cc.gcov.html#L105" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,120,79,123" href="Classifier.cc.gcov.html#L109" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,124,79,127" href="Classifier.cc.gcov.html#L113" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,128,79,131" href="Classifier.cc.gcov.html#L117" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,132,79,135" href="Classifier.cc.gcov.html#L121" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,136,79,139" href="Classifier.cc.gcov.html#L125" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,140,79,143" href="Classifier.cc.gcov.html#L129" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,144,79,147" href="Classifier.cc.gcov.html#L133" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,148,79,151" href="Classifier.cc.gcov.html#L137" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,152,79,155" href="Classifier.cc.gcov.html#L141" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,156,79,159" href="Classifier.cc.gcov.html#L145" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,160,79,163" href="Classifier.cc.gcov.html#L149" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,164,79,167" href="Classifier.cc.gcov.html#L153" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,168,79,171" href="Classifier.cc.gcov.html#L157" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,172,79,175" href="Classifier.cc.gcov.html#L161" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,176,79,179" href="Classifier.cc.gcov.html#L165" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,180,79,183" href="Classifier.cc.gcov.html#L169" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,184,79,187" href="Classifier.cc.gcov.html#L173" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,188,79,191" href="Classifier.cc.gcov.html#L177" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,192,79,195" href="Classifier.cc.gcov.html#L181" target="source" alt="overview">
|
||||||
|
</map>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<a href="Classifier.cc.gcov.html#top" target="source">Top</a><br><br>
|
||||||
|
<img src="Classifier.cc.gcov.png" width=80 height=193 alt="Overview" border=0 usemap="#overview">
|
||||||
|
</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
html/bayesnet/classifiers/Classifier.cc.gcov.png
Normal file
BIN
html/bayesnet/classifiers/Classifier.cc.gcov.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 852 B |
111
html/bayesnet/classifiers/Classifier.h.func-c.html
Normal file
111
html/bayesnet/classifiers/Classifier.h.func-c.html
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.h<span style="font-size: 80%;"> (<a href="Classifier.h.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="Classifier.h.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L31">bayesnet::Classifier::getVersion[abi:cxx11]()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">32</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">bayesnet::Classifier::getNotes[abi:cxx11]() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">80</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">bayesnet::Classifier::getStatus() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">128</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">bayesnet::Classifier::~Classifier()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1680</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
111
html/bayesnet/classifiers/Classifier.h.func.html
Normal file
111
html/bayesnet/classifiers/Classifier.h.func.html
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.h<span style="font-size: 80%;"> (<a href="Classifier.h.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="Classifier.h.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">bayesnet::Classifier::getNotes[abi:cxx11]() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">80</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">bayesnet::Classifier::getStatus() const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">128</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L31">bayesnet::Classifier::getVersion[abi:cxx11]()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">32</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">bayesnet::Classifier::~Classifier()</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">1680</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
19
html/bayesnet/classifiers/Classifier.h.gcov.frameset.html
Normal file
19
html/bayesnet/classifiers/Classifier.h.gcov.frameset.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<frameset cols="120,*">
|
||||||
|
<frame src="Classifier.h.gcov.overview.html" name="overview">
|
||||||
|
<frame src="Classifier.h.gcov.html" name="source">
|
||||||
|
<noframes>
|
||||||
|
<center>Frames not supported by your browser!<br></center>
|
||||||
|
</noframes>
|
||||||
|
</frameset>
|
||||||
|
|
||||||
|
</html>
|
149
html/bayesnet/classifiers/Classifier.h.gcov.html
Normal file
149
html/bayesnet/classifiers/Classifier.h.gcov.html
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Classifier.h<span style="font-size: 80%;"> (source / <a href="Classifier.h.func-c.html">functions</a>)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
<td class="headerCovTableEntry">4</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table cellpadding=0 cellspacing=0 border=0>
|
||||||
|
<tr>
|
||||||
|
<td><br></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<pre class="sourceHeading"> Line data Source code</pre>
|
||||||
|
<pre class="source">
|
||||||
|
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
|
||||||
|
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
|
||||||
|
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
|
||||||
|
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
|
||||||
|
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
|
||||||
|
<span id="L6"><span class="lineNum"> 6</span> : </span>
|
||||||
|
<span id="L7"><span class="lineNum"> 7</span> : #ifndef CLASSIFIER_H</span>
|
||||||
|
<span id="L8"><span class="lineNum"> 8</span> : #define CLASSIFIER_H</span>
|
||||||
|
<span id="L9"><span class="lineNum"> 9</span> : #include <torch/torch.h></span>
|
||||||
|
<span id="L10"><span class="lineNum"> 10</span> : #include "bayesnet/utils/BayesMetrics.h"</span>
|
||||||
|
<span id="L11"><span class="lineNum"> 11</span> : #include "bayesnet/network/Network.h"</span>
|
||||||
|
<span id="L12"><span class="lineNum"> 12</span> : #include "bayesnet/BaseClassifier.h"</span>
|
||||||
|
<span id="L13"><span class="lineNum"> 13</span> : </span>
|
||||||
|
<span id="L14"><span class="lineNum"> 14</span> : namespace bayesnet {</span>
|
||||||
|
<span id="L15"><span class="lineNum"> 15</span> : class Classifier : public BaseClassifier {</span>
|
||||||
|
<span id="L16"><span class="lineNum"> 16</span> : public:</span>
|
||||||
|
<span id="L17"><span class="lineNum"> 17</span> : Classifier(Network model);</span>
|
||||||
|
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC tlaBgGNC"> 1680 : virtual ~Classifier() = default;</span></span>
|
||||||
|
<span id="L19"><span class="lineNum"> 19</span> : Classifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;</span>
|
||||||
|
<span id="L20"><span class="lineNum"> 20</span> : Classifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;</span>
|
||||||
|
<span id="L21"><span class="lineNum"> 21</span> : Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;</span>
|
||||||
|
<span id="L22"><span class="lineNum"> 22</span> : Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) override;</span>
|
||||||
|
<span id="L23"><span class="lineNum"> 23</span> : void addNodes();</span>
|
||||||
|
<span id="L24"><span class="lineNum"> 24</span> : int getNumberOfNodes() const override;</span>
|
||||||
|
<span id="L25"><span class="lineNum"> 25</span> : int getNumberOfEdges() const override;</span>
|
||||||
|
<span id="L26"><span class="lineNum"> 26</span> : int getNumberOfStates() const override;</span>
|
||||||
|
<span id="L27"><span class="lineNum"> 27</span> : int getClassNumStates() const override;</span>
|
||||||
|
<span id="L28"><span class="lineNum"> 28</span> : torch::Tensor predict(torch::Tensor& X) override;</span>
|
||||||
|
<span id="L29"><span class="lineNum"> 29</span> : std::vector<int> predict(std::vector<std::vector<int>>& X) override;</span>
|
||||||
|
<span id="L30"><span class="lineNum"> 30</span> : torch::Tensor predict_proba(torch::Tensor& X) override;</span>
|
||||||
|
<span id="L31"><span class="lineNum"> 31</span> : std::vector<std::vector<double>> predict_proba(std::vector<std::vector<int>>& X) override;</span>
|
||||||
|
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 128 : status_t getStatus() const override { return status; }</span></span>
|
||||||
|
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 96 : std::string getVersion() override { return { project_version.begin(), project_version.end() }; };</span></span>
|
||||||
|
<span id="L34"><span class="lineNum"> 34</span> : float score(torch::Tensor& X, torch::Tensor& y) override;</span>
|
||||||
|
<span id="L35"><span class="lineNum"> 35</span> : float score(std::vector<std::vector<int>>& X, std::vector<int>& y) override;</span>
|
||||||
|
<span id="L36"><span class="lineNum"> 36</span> : std::vector<std::string> show() const override;</span>
|
||||||
|
<span id="L37"><span class="lineNum"> 37</span> : std::vector<std::string> topological_order() override;</span>
|
||||||
|
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 80 : std::vector<std::string> getNotes() const override { return notes; }</span></span>
|
||||||
|
<span id="L39"><span class="lineNum"> 39</span> : std::string dump_cpt() const override;</span>
|
||||||
|
<span id="L40"><span class="lineNum"> 40</span> : void setHyperparameters(const nlohmann::json& hyperparameters) override; //For classifiers that don't have hyperparameters</span>
|
||||||
|
<span id="L41"><span class="lineNum"> 41</span> : protected:</span>
|
||||||
|
<span id="L42"><span class="lineNum"> 42</span> : bool fitted;</span>
|
||||||
|
<span id="L43"><span class="lineNum"> 43</span> : unsigned int m, n; // m: number of samples, n: number of features</span>
|
||||||
|
<span id="L44"><span class="lineNum"> 44</span> : Network model;</span>
|
||||||
|
<span id="L45"><span class="lineNum"> 45</span> : Metrics metrics;</span>
|
||||||
|
<span id="L46"><span class="lineNum"> 46</span> : std::vector<std::string> features;</span>
|
||||||
|
<span id="L47"><span class="lineNum"> 47</span> : std::string className;</span>
|
||||||
|
<span id="L48"><span class="lineNum"> 48</span> : std::map<std::string, std::vector<int>> states;</span>
|
||||||
|
<span id="L49"><span class="lineNum"> 49</span> : torch::Tensor dataset; // (n+1)xm tensor</span>
|
||||||
|
<span id="L50"><span class="lineNum"> 50</span> : status_t status = NORMAL;</span>
|
||||||
|
<span id="L51"><span class="lineNum"> 51</span> : std::vector<std::string> notes; // Used to store messages occurred during the fit process</span>
|
||||||
|
<span id="L52"><span class="lineNum"> 52</span> : void checkFitParameters();</span>
|
||||||
|
<span id="L53"><span class="lineNum"> 53</span> : virtual void buildModel(const torch::Tensor& weights) = 0;</span>
|
||||||
|
<span id="L54"><span class="lineNum"> 54</span> : void trainModel(const torch::Tensor& weights) override;</span>
|
||||||
|
<span id="L55"><span class="lineNum"> 55</span> : void buildDataset(torch::Tensor& y);</span>
|
||||||
|
<span id="L56"><span class="lineNum"> 56</span> : private:</span>
|
||||||
|
<span id="L57"><span class="lineNum"> 57</span> : Classifier& build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);</span>
|
||||||
|
<span id="L58"><span class="lineNum"> 58</span> : };</span>
|
||||||
|
<span id="L59"><span class="lineNum"> 59</span> : }</span>
|
||||||
|
<span id="L60"><span class="lineNum"> 60</span> : #endif</span>
|
||||||
|
<span id="L61"><span class="lineNum"> 61</span> : </span>
|
||||||
|
<span id="L62"><span class="lineNum"> 62</span> : </span>
|
||||||
|
<span id="L63"><span class="lineNum"> 63</span> : </span>
|
||||||
|
<span id="L64"><span class="lineNum"> 64</span> : </span>
|
||||||
|
<span id="L65"><span class="lineNum"> 65</span> : </span>
|
||||||
|
</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
37
html/bayesnet/classifiers/Classifier.h.gcov.overview.html
Normal file
37
html/bayesnet/classifiers/Classifier.h.gcov.overview.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Classifier.h</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<map name="overview">
|
||||||
|
<area shape="rect" coords="0,0,79,3" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,4,79,7" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,8,79,11" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,12,79,15" href="Classifier.h.gcov.html#L1" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,16,79,19" href="Classifier.h.gcov.html#L5" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,20,79,23" href="Classifier.h.gcov.html#L9" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,24,79,27" href="Classifier.h.gcov.html#L13" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,28,79,31" href="Classifier.h.gcov.html#L17" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,32,79,35" href="Classifier.h.gcov.html#L21" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,36,79,39" href="Classifier.h.gcov.html#L25" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,40,79,43" href="Classifier.h.gcov.html#L29" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,44,79,47" href="Classifier.h.gcov.html#L33" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,48,79,51" href="Classifier.h.gcov.html#L37" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,52,79,55" href="Classifier.h.gcov.html#L41" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,56,79,59" href="Classifier.h.gcov.html#L45" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,60,79,63" href="Classifier.h.gcov.html#L49" target="source" alt="overview">
|
||||||
|
<area shape="rect" coords="0,64,79,67" href="Classifier.h.gcov.html#L53" target="source" alt="overview">
|
||||||
|
</map>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<a href="Classifier.h.gcov.html#top" target="source">Top</a><br><br>
|
||||||
|
<img src="Classifier.h.gcov.png" width=80 height=64 alt="Overview" border=0 usemap="#overview">
|
||||||
|
</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
html/bayesnet/classifiers/Classifier.h.gcov.png
Normal file
BIN
html/bayesnet/classifiers/Classifier.h.gcov.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 453 B |
118
html/bayesnet/classifiers/KDB.cc.func-c.html
Normal file
118
html/bayesnet/classifiers/KDB.cc.func-c.html
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.cc<span style="font-size: 80%;"> (<a href="KDB.cc.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">96.3 %</td>
|
||||||
|
<td class="headerCovTableEntry">54</td>
|
||||||
|
<td class="headerCovTableEntry">52</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">5</td>
|
||||||
|
<td class="headerCovTableEntry">5</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDB.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">bayesnet::KDB::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">8</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">bayesnet::KDB::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">12</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">bayesnet::KDB::buildModel(at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">52</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">bayesnet::KDB::KDB(int, float)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">148</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">bayesnet::KDB::add_m_edges(int, std::vector<int, std::allocator<int> >&, at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">344</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
118
html/bayesnet/classifiers/KDB.cc.func.html
Normal file
118
html/bayesnet/classifiers/KDB.cc.func.html
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc - functions</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td width="100%">
|
||||||
|
<table cellpadding=1 border=0 width="100%">
|
||||||
|
<tr>
|
||||||
|
<td width="10%" class="headerItem">Current view:</td>
|
||||||
|
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.cc<span style="font-size: 80%;"> (<a href="KDB.cc.gcov.html">source</a> / functions)</span></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%"></td>
|
||||||
|
<td width="5%" class="headerCovTableHead">Coverage</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
|
||||||
|
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test:</td>
|
||||||
|
<td class="headerValue">BayesNet Coverage Report</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Lines:</td>
|
||||||
|
<td class="headerCovTableEntryHi">96.3 %</td>
|
||||||
|
<td class="headerCovTableEntry">54</td>
|
||||||
|
<td class="headerCovTableEntry">52</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Test Date:</td>
|
||||||
|
<td class="headerValue">2024-05-06 17:54:04</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Functions:</td>
|
||||||
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
||||||
|
<td class="headerCovTableEntry">5</td>
|
||||||
|
<td class="headerCovTableEntry">5</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="headerItem">Legend:</td>
|
||||||
|
<td class="headerValueLeg"> Lines:
|
||||||
|
<span class="coverLegendCov">hit</span>
|
||||||
|
<span class="coverLegendNoCov">not hit</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<table cellpadding=1 cellspacing=1 border=0>
|
||||||
|
<tr><td><br></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
|
||||||
|
|
||||||
|
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDB.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">bayesnet::KDB::KDB(int, float)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">148</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">bayesnet::KDB::add_m_edges(int, std::vector<int, std::allocator<int> >&, at::Tensor&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">344</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">bayesnet::KDB::buildModel(at::Tensor const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">52</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">bayesnet::KDB::graph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">8</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">bayesnet::KDB::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&)</a></td>
|
||||||
|
|
||||||
|
<td class="coverFnHi">12</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</center>
|
||||||
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
||||||
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
|
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
19
html/bayesnet/classifiers/KDB.cc.gcov.frameset.html
Normal file
19
html/bayesnet/classifiers/KDB.cc.gcov.frameset.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<frameset cols="120,*">
|
||||||
|
<frame src="KDB.cc.gcov.overview.html" name="overview">
|
||||||
|
<frame src="KDB.cc.gcov.html" name="source">
|
||||||
|
<noframes>
|
||||||
|
<center>Frames not supported by your browser!<br></center>
|
||||||
|
</noframes>
|
||||||
|
</frameset>
|
||||||
|
|
||||||
|
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user