Compare commits

..

No commits in common. "main" and "AnDE" have entirely different histories.
main ... AnDE

394 changed files with 30462 additions and 10137 deletions

View File

@ -1,4 +1,4 @@
compilation_database_dir: build_Debug
compilation_database_dir: build_debug
output_directory: diagrams
diagrams:
BayesNet:

View File

@ -1,6 +1,6 @@
FROM mcr.microsoft.com/devcontainers/cpp:ubuntu22.04
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.29.3"
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"
# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/
@ -23,7 +23,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get update
# Install GCC 13.1
RUN apt-get install -y gcc-13 g++-13 doxygen
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 && \

4
.gitignore vendored
View File

@ -40,8 +40,4 @@ puml/**
.vscode/settings.json
sample/build
**/.DS_Store
docs/manual
docs/man3
docs/man
docs/Doxyfile

11
.gitmodules vendored
View File

@ -1,3 +1,8 @@
[submodule "lib/mdlp"]
path = lib/mdlp
url = https://github.com/rmontanana/mdlp
main = main
update = merge
[submodule "lib/json"]
path = lib/json
url = https://github.com/nlohmann/json.git
@ -13,9 +18,3 @@
url = https://github.com/catchorg/Catch2.git
main = main
update = merge
[submodule "tests/lib/Files"]
path = tests/lib/Files
url = https://github.com/rmontanana/ArffFiles
[submodule "lib/mdlp"]
path = lib/mdlp
url = https://github.com/rmontanana/mdlp

6
.vscode/launch.json vendored
View File

@ -14,11 +14,11 @@
"type": "lldb",
"request": "launch",
"name": "test",
"program": "${workspaceFolder}/build_Debug/tests/TestBayesNet",
"program": "${workspaceFolder}/build_debug/tests/TestBayesNet",
"args": [
"No features selected"
"[Node]"
],
"cwd": "${workspaceFolder}/build_Debug/tests"
"cwd": "${workspaceFolder}/build_debug/tests"
},
{
"name": "(gdb) Launch",

View File

@ -7,15 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.0.6] 2024-11-23
### Fixed
- Prevent existing edges to be added to the network in the `add_edge` method.
- Don't allow to add nodes or edges on already fiited networks.
- Number of threads spawned
- Network class tests
### Added
- Library logo generated with <https://openart.ai> to README.md
@ -23,21 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- *convergence_best* hyperparameter to the BoostAODE class, to control the way the prior accuracy is computed if convergence is set. Default value is *false*.
- SPnDE model.
- A2DE model.
- BoostA2DE model.
- A2DE & SPnDE tests.
- Add tests to reach 99% of coverage.
- Add tests to check the correct version of the mdlp, folding and json libraries.
- Library documentation generated with Doxygen.
- Link to documentation in the README.md.
- Three types of smoothing the Bayesian Network ORIGINAL, LAPLACE and CESTNIK.
### Internal
- Fixed doxygen optional dependency
- Add env parallel variable to Makefile
- Add CountingSemaphore class to manage the number of threads spawned.
- Ignore CUDA language in CMake CodeCoverage module.
- Update mdlp library as a git submodule.
- Create library ShuffleArffFile to limit the number of samples with a parameter and shuffle them.
- Refactor catch2 library location to test/lib
- Refactor loadDataset function in tests.
@ -45,15 +27,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactor Coverage Report generation.
- Add devcontainer to work on apple silicon.
- Change build cmake folder names to Debug & Release.
- Add a Makefile target (doc) to generate the documentation.
- Add a Makefile target (doc-install) to install the documentation.
### Libraries versions
- mdlp: 2.0.1
- Folding: 1.1.0
- json: 3.11
- ArffFiles: 1.1.0
## [1.0.5] 2024-04-20

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20)
project(BayesNet
VERSION 1.0.6
VERSION 1.0.5.1
DESCRIPTION "Bayesian Network and basic classifiers Library."
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
LANGUAGES CXX
@ -25,11 +25,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
endif()
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
# -------
@ -49,12 +46,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CODE_COVERAGE ON)
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
message(STATUS "Languages=${LANGUAGES}")
if (CODE_COVERAGE)
enable_testing()
include(CodeCoverage)
MESSAGE(STATUS "Code coverage enabled")
MESSAGE("Code coverage enabled")
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
endif (CODE_COVERAGE)
@ -64,10 +60,10 @@ endif (ENABLE_CLANG_TIDY)
# External libraries - dependencies of BayesNet
# ---------------------------------------------
# include(FetchContent)
add_git_submodule("lib/json")
add_git_submodule("lib/mdlp")
add_subdirectory("lib/Files")
# Subdirectories
# --------------
@ -77,7 +73,7 @@ add_subdirectory(bayesnet)
# Testing
# -------
if (ENABLE_TESTING)
MESSAGE(STATUS "Testing enabled")
MESSAGE("Testing enabled")
add_subdirectory(tests/lib/catch2)
include(CTest)
add_subdirectory(tests)
@ -90,19 +86,4 @@ install(TARGETS BayesNet
LIBRARY DESTINATION lib
CONFIGURATIONS Release)
install(DIRECTORY bayesnet/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)
# Documentation
# -------------
find_package(Doxygen)
if (Doxygen_FOUND)
set(DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
set(doxyfile_in ${DOC_DIR}/Doxyfile.in)
set(doxyfile ${DOC_DIR}/Doxyfile)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
doxygen_add_docs(doxygen
WORKING_DIRECTORY ${DOC_DIR}
CONFIG_FILE ${doxyfile})
else (Doxygen_FOUND)
MESSAGE("* Doxygen not found")
endif (Doxygen_FOUND)
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)

View File

@ -1,6 +1,6 @@
SHELL := /bin/bash
.DEFAULT_GOAL := help
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge doc doc-install
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge
f_release = build_Release
f_debug = build_Debug
@ -12,11 +12,7 @@ plantuml = plantuml
lcov = lcov
genhtml = genhtml
dot = dot
docsrcdir = docs/manual
mansrcdir = docs/man3
mandestdir = /usr/local/share/man
sed_command_link = 's/e">LCOV -/e"><a href="https:\/\/rmontanana.github.io\/bayesnet">Back to manual<\/a> LCOV -/g'
sed_command_diagram = 's/Diagram"/Diagram" width="100%" height="100%" /g'
n_procs = -j 16
define ClearTests
@for t in $(test_targets); do \
@ -43,7 +39,7 @@ setup: ## Install dependencies for tests and coverage
fi
@echo "* You should install plantuml & graphviz for the diagrams"
diagrams: ## Create an UML class diagram & dependency of the project (diagrams/BayesNet.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)
@ -58,10 +54,10 @@ diagrams: ## Create an UML class diagram & dependency of the project (diagrams/B
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
buildd: ## Build the debug targets
cmake --build $(f_debug) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
cmake --build $(f_debug) -t $(app_targets) $(n_procs)
buildr: ## Build the release targets
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
cmake --build $(f_release) -t $(app_targets) $(n_procs)
clean: ## Clean the tests info
@echo ">>> Cleaning Debug BayesNet tests...";
@ -105,7 +101,7 @@ opt = ""
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
@echo ">>> Running BayesNet tests...";
@$(MAKE) clean
@cmake --build $(f_debug) -t $(test_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
@cmake --build $(f_debug) -t $(test_targets) $(n_procs)
@for t in $(test_targets); do \
echo ">>> Running $$t...";\
if [ -f $(f_debug)/tests/$$t ]; then \
@ -118,7 +114,7 @@ test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximu
coverage: ## Run tests and generate coverage report (build/index.html)
@echo ">>> Building tests with coverage..."
@which $(lcov) || (echo ">>ease install lcov"; exit 1)
@which $(lcov) || (echo ">>> Please install lcov"; exit 1)
@if [ ! -f $(f_debug)/tests/coverage.info ] ; then $(MAKE) test ; fi
@echo ">>> Building report..."
@cd $(f_debug)/tests; \
@ -134,14 +130,9 @@ coverage: ## Run tests and generate coverage report (build/index.html)
@echo ">>> Done";
viewcoverage: ## View the html coverage report
@which $(genhtml) >/dev/null || (echo ">>> Please install lcov (genhtml not found)"; exit 1)
@if [ ! -d $(docsrcdir)/coverage ]; then mkdir -p $(docsrcdir)/coverage; fi
@if [ ! -f $(f_debug)/tests/coverage.info ]; then \
echo ">>> No coverage.info file found. Run make coverage first!"; \
exit 1; \
fi
@$(genhtml) $(f_debug)/tests/coverage.info --demangle-cpp --output-directory $(docsrcdir)/coverage --title "BayesNet Coverage Report" -s -k -f --legend >/dev/null 2>&1;
@xdg-open $(docsrcdir)/coverage/index.html || open $(docsrcdir)/coverage/index.html 2>/dev/null
@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
@ -154,34 +145,6 @@ updatebadge: ## Update the coverage badge in README.md
@env python update_coverage.py $(f_debug)/tests
@echo ">>> Done";
doc: ## Generate documentation
@echo ">>> Generating documentation..."
@cmake --build $(f_release) -t doxygen
@cp -rp diagrams $(docsrcdir)
@
@if [ "$(shell uname)" = "Darwin" ]; then \
sed -i "" $(sed_command_link) $(docsrcdir)/coverage/index.html ; \
sed -i "" $(sed_command_diagram) $(docsrcdir)/index.html ; \
else \
sed -i $(sed_command_link) $(docsrcdir)/coverage/index.html ; \
sed -i $(sed_command_diagram) $(docsrcdir)/index.html ; \
fi
@echo ">>> Done";
docdir = ""
doc-install: ## Install documentation
@echo ">>> Installing documentation..."
@if [ "$(docdir)" = "" ]; then \
echo "docdir parameter has to be set when calling doc-install, i.e. docdir=../bayesnet_help"; \
exit 1; \
fi
@if [ ! -d $(docdir) ]; then \
@$(MAKE) doc; \
fi
@cp -rp $(docsrcdir)/* $(docdir)
@sudo cp -rp $(mansrcdir) $(mandestdir)
@echo ">>> Done";
help: ## Show help message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \

View File

@ -7,10 +7,9 @@
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_BayesNet&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_BayesNet&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_BayesNet)
![Gitea Last Commit](https://img.shields.io/gitea/last-commit/rmontanana/bayesnet?gitea_url=https://gitea.rmontanana.es:3000&logo=gitea)
[![Coverage Badge](https://img.shields.io/badge/Coverage-99,1%25-green)](html/index.html)
[![DOI](https://zenodo.org/badge/667782806.svg)](https://doi.org/10.5281/zenodo.14210344)
[![Coverage Badge](https://img.shields.io/badge/Coverage-99,0%25-green)](html/index.html)
Bayesian Network Classifiers library
Bayesian Network Classifiers using libtorch from scratch
## Dependencies
@ -68,16 +67,10 @@ make sample fname=tests/data/glass.arff
#### - SPODE
#### - SPnDE
#### - AODE
#### - A2DE
#### - [BoostAODE](docs/BoostAODE.md)
#### - BoostA2DE
### With Local Discretization
#### - TANLd
@ -88,12 +81,6 @@ make sample fname=tests/data/glass.arff
#### - AODELd
## Documentation
### [Manual](https://rmontanana.github.io/bayesnet/)
### [Coverage report](https://rmontanana.github.io/bayesnet/coverage/index.html)
## Diagrams
### UML Class Diagram
@ -103,3 +90,7 @@ make sample fname=tests/data/glass.arff
### Dependency Diagram
![BayesNet Dependency Diagram](diagrams/dependency.svg)
## Coverage report
### [Coverage report](docs/coverage.pdf)

View File

@ -8,18 +8,16 @@
#include <vector>
#include <torch/torch.h>
#include <nlohmann/json.hpp>
#include "bayesnet/network/Network.h"
namespace bayesnet {
enum status_t { NORMAL, WARNING, ERROR };
class BaseClassifier {
public:
// X is nxm std::vector, y is nx1 std::vector
virtual BaseClassifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) = 0;
virtual BaseClassifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;
// X is nxm tensor, y is nx1 tensor
virtual BaseClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) = 0;
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) = 0;
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing) = 0;
virtual BaseClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) = 0;
virtual BaseClassifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) = 0;
virtual ~BaseClassifier() = default;
torch::Tensor virtual predict(torch::Tensor& X) = 0;
std::vector<int> virtual predict(std::vector<std::vector<int >>& X) = 0;
@ -41,7 +39,7 @@ namespace bayesnet {
virtual void setHyperparameters(const nlohmann::json& hyperparameters) = 0;
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
protected:
virtual void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) = 0;
virtual void trainModel(const torch::Tensor& weights) = 0;
std::vector<std::string> validHyperparameters;
};
}

View File

@ -1,5 +1,6 @@
include_directories(
${BayesNet_SOURCE_DIR}/lib/mdlp/src
${BayesNet_SOURCE_DIR}/lib/mdlp
${BayesNet_SOURCE_DIR}/lib/Files
${BayesNet_SOURCE_DIR}/lib/folding
${BayesNet_SOURCE_DIR}/lib/json/include
${BayesNet_SOURCE_DIR}
@ -9,4 +10,4 @@ include_directories(
file(GLOB_RECURSE Sources "*.cc")
add_library(BayesNet ${Sources})
target_link_libraries(BayesNet fimdlp "${TORCH_LIBRARIES}")
target_link_libraries(BayesNet mdlp "${TORCH_LIBRARIES}")

View File

@ -11,7 +11,7 @@
namespace bayesnet {
Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}
const std::string CLASSIFIER_NOT_FITTED = "Classifier has not been fitted";
Classifier& Classifier::build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing)
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)
{
this->features = features;
this->className = className;
@ -23,7 +23,7 @@ namespace bayesnet {
metrics = Metrics(dataset, features, className, n_classes);
model.initialize();
buildModel(weights);
trainModel(weights, smoothing);
trainModel(weights);
fitted = true;
return *this;
}
@ -41,20 +41,20 @@ namespace bayesnet {
throw std::runtime_error(oss.str());
}
}
void Classifier::trainModel(const torch::Tensor& weights, Smoothing_t smoothing)
void Classifier::trainModel(const torch::Tensor& weights)
{
model.fit(dataset, weights, features, className, states, smoothing);
model.fit(dataset, weights, features, className, states);
}
// X is nxm where n is the number of features and m the number of samples
Classifier& Classifier::fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
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)
{
dataset = X;
buildDataset(y);
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
return build(features, className, states, weights, smoothing);
return build(features, className, states, weights);
}
// X is nxm where n is the number of features and m the number of samples
Classifier& Classifier::fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
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)
{
dataset = torch::zeros({ static_cast<int>(X.size()), static_cast<int>(X[0].size()) }, torch::kInt32);
for (int i = 0; i < X.size(); ++i) {
@ -63,18 +63,18 @@ namespace bayesnet {
auto ytmp = torch::tensor(y, torch::kInt32);
buildDataset(ytmp);
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
return build(features, className, states, weights, smoothing);
return build(features, className, states, weights);
}
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states)
{
this->dataset = dataset;
const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);
return build(features, className, states, weights, smoothing);
return build(features, className, states, weights);
}
Classifier& Classifier::fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing)
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)
{
this->dataset = dataset;
return build(features, className, states, weights, smoothing);
return build(features, className, states, weights);
}
void Classifier::checkFitParameters()
{

View File

@ -8,6 +8,7 @@
#define CLASSIFIER_H
#include <torch/torch.h>
#include "bayesnet/utils/BayesMetrics.h"
#include "bayesnet/network/Network.h"
#include "bayesnet/BaseClassifier.h"
namespace bayesnet {
@ -15,10 +16,10 @@ namespace bayesnet {
public:
Classifier(Network model);
virtual ~Classifier() = default;
Classifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
Classifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing) override;
Classifier& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
Classifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
Classifier& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights) override;
void addNodes();
int getNumberOfNodes() const override;
int getNumberOfEdges() const override;
@ -50,10 +51,10 @@ namespace bayesnet {
std::vector<std::string> notes; // Used to store messages occurred during the fit process
void checkFitParameters();
virtual void buildModel(const torch::Tensor& weights) = 0;
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
void trainModel(const torch::Tensor& weights) override;
void buildDataset(torch::Tensor& y);
private:
Classifier& build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing);
Classifier& build(const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
};
}
#endif

View File

@ -8,7 +8,7 @@
namespace bayesnet {
KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}
KDBLd& KDBLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
KDBLd& KDBLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
{
checkInput(X_, y_);
features = features_;
@ -19,7 +19,7 @@ namespace bayesnet {
states = fit_local_discretization(y);
// We have discretized the input data
// 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network
KDB::fit(dataset, features, className, states, smoothing);
KDB::fit(dataset, features, className, states);
states = localDiscretizationProposal(states, model);
return *this;
}

View File

@ -15,7 +15,7 @@ namespace bayesnet {
public:
explicit KDBLd(int k);
virtual ~KDBLd() = default;
KDBLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
KDBLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
std::vector<std::string> graph(const std::string& name = "KDB") const override;
torch::Tensor predict(torch::Tensor& X) override;
static inline std::string version() { return "0.0.1"; };

View File

@ -4,6 +4,7 @@
// SPDX-License-Identifier: MIT
// ***************************************************************
#include <ArffFiles.h>
#include "Proposal.h"
namespace bayesnet {
@ -53,7 +54,8 @@ namespace bayesnet {
yJoinParents[i] += to_string(pDataset.index({ idx, i }).item<int>());
}
}
auto yxv = factorize(yJoinParents);
auto arff = ArffFiles();
auto yxv = arff.factorize(yJoinParents);
auto xvf_ptr = Xf.index({ index }).data_ptr<float>();
auto xvf = std::vector<mdlp::precision_t>(xvf_ptr, xvf_ptr + Xf.size(1));
discretizers[feature]->fit(xvf, yxv);
@ -70,7 +72,7 @@ namespace bayesnet {
states[pFeatures[index]] = xStates;
}
const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);
model.fit(pDataset, weights, pFeatures, pClassName, states, Smoothing_t::ORIGINAL);
model.fit(pDataset, weights, pFeatures, pClassName, states);
}
return states;
}
@ -111,19 +113,4 @@ namespace bayesnet {
}
return Xtd;
}
std::vector<int> Proposal::factorize(const std::vector<std::string>& labels_t)
{
std::vector<int> yy;
yy.reserve(labels_t.size());
std::map<std::string, int> labelMap;
int i = 0;
for (const std::string& label : labels_t) {
if (labelMap.find(label) == labelMap.end()) {
labelMap[label] = i++;
bool allDigits = std::all_of(label.begin(), label.end(), ::isdigit);
}
yy.push_back(labelMap[label]);
}
return yy;
}
}

View File

@ -27,7 +27,6 @@ namespace bayesnet {
torch::Tensor y; // y discrete nx1 tensor
map<std::string, mdlp::CPPFImdlp*> discretizers;
private:
std::vector<int> factorize(const std::vector<std::string>& labels_t);
torch::Tensor& pDataset; // (n+1)xm tensor
std::vector<std::string>& pFeatures;
std::string& pClassName;

View File

@ -8,25 +8,25 @@
namespace bayesnet {
SPODELd::SPODELd(int root) : SPODE(root), Proposal(dataset, features, className) {}
SPODELd& SPODELd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
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_);
Xf = X_;
y = y_;
return commonFit(features_, className_, states_, smoothing);
return commonFit(features_, className_, states_);
}
SPODELd& SPODELd::fit(torch::Tensor& dataset, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
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)) {
throw std::runtime_error("Dataset must be a floating point tensor");
}
Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." }).clone();
y = dataset.index({ -1, "..." }).clone().to(torch::kInt32);
return commonFit(features_, className_, states_, smoothing);
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_, const Smoothing_t smoothing)
SPODELd& SPODELd::commonFit(const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
{
features = features_;
className = className_;
@ -34,7 +34,7 @@ namespace bayesnet {
states = fit_local_discretization(y);
// We have discretized the input data
// 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network
SPODE::fit(dataset, features, className, states, smoothing);
SPODE::fit(dataset, features, className, states);
states = localDiscretizationProposal(states, model);
return *this;
}

View File

@ -14,10 +14,10 @@ namespace bayesnet {
public:
explicit SPODELd(int root);
virtual ~SPODELd() = default;
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
SPODELd& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
SPODELd& commonFit(const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
std::vector<std::string> graph(const std::string& name = "SPODELd") const override;
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
SPODELd& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
SPODELd& commonFit(const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states);
std::vector<std::string> graph(const std::string& name = "SPODE") const override;
torch::Tensor predict(torch::Tensor& X) override;
static inline std::string version() { return "0.0.1"; };
};

View File

@ -8,7 +8,7 @@
namespace bayesnet {
TANLd::TANLd() : TAN(), Proposal(dataset, features, className) {}
TANLd& TANLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
TANLd& TANLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
{
checkInput(X_, y_);
features = features_;
@ -19,7 +19,7 @@ namespace bayesnet {
states = fit_local_discretization(y);
// We have discretized the input data
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
TAN::fit(dataset, features, className, states, smoothing);
TAN::fit(dataset, features, className, states);
states = localDiscretizationProposal(states, model);
return *this;

View File

@ -15,9 +15,10 @@ namespace bayesnet {
public:
TANLd();
virtual ~TANLd() = default;
TANLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states, const Smoothing_t smoothing) override;
std::vector<std::string> graph(const std::string& name = "TANLd") const override;
TANLd& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, map<std::string, std::vector<int>>& states) override;
std::vector<std::string> graph(const std::string& name = "TAN") const override;
torch::Tensor predict(torch::Tensor& X) override;
static inline std::string version() { return "0.0.1"; };
};
}
#endif // !TANLD_H

View File

@ -10,7 +10,7 @@ namespace bayesnet {
AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)
{
}
AODELd& AODELd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing)
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_)
{
checkInput(X_, y_);
features = features_;
@ -20,9 +20,8 @@ namespace bayesnet {
// Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
states = fit_local_discretization(y);
// We have discretized the input data
// 1st we need to fit the model to build the normal AODE structure, Ensemble::fit
// calls buildModel to initialize the base models
Ensemble::fit(dataset, features, className, states, smoothing);
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
Ensemble::fit(dataset, features, className, states);
return *this;
}
@ -35,10 +34,10 @@ namespace bayesnet {
n_models = models.size();
significanceModels = std::vector<double>(n_models, 1.0);
}
void AODELd::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
void AODELd::trainModel(const torch::Tensor& weights)
{
for (const auto& model : models) {
model->fit(Xf, y, features, className, states, smoothing);
model->fit(Xf, y, features, className, states);
}
}
std::vector<std::string> AODELd::graph(const std::string& name) const

View File

@ -15,10 +15,10 @@ namespace bayesnet {
public:
AODELd(bool predict_voting = true);
virtual ~AODELd() = default;
AODELd& fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_, const Smoothing_t smoothing) 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;
std::vector<std::string> graph(const std::string& name = "AODELd") const override;
protected:
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
void trainModel(const torch::Tensor& weights) override;
void buildModel(const torch::Tensor& weights) override;
};
}

View File

@ -1,246 +0,0 @@
// ***************************************************************
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
// SPDX-FileType: SOURCE
// SPDX-License-Identifier: MIT
// ***************************************************************
#include <folding.hpp>
#include "bayesnet/feature_selection/CFS.h"
#include "bayesnet/feature_selection/FCBF.h"
#include "bayesnet/feature_selection/IWSS.h"
#include "Boost.h"
namespace bayesnet {
Boost::Boost(bool predict_voting) : Ensemble(predict_voting)
{
validHyperparameters = { "order", "convergence", "convergence_best", "bisection", "threshold", "maxTolerance",
"predict_voting", "select_features", "block_update" };
}
void Boost::setHyperparameters(const nlohmann::json& hyperparameters_)
{
auto hyperparameters = hyperparameters_;
if (hyperparameters.contains("order")) {
std::vector<std::string> algos = { Orders.ASC, Orders.DESC, Orders.RAND };
order_algorithm = hyperparameters["order"];
if (std::find(algos.begin(), algos.end(), order_algorithm) == algos.end()) {
throw std::invalid_argument("Invalid order algorithm, valid values [" + Orders.ASC + ", " + Orders.DESC + ", " + Orders.RAND + "]");
}
hyperparameters.erase("order");
}
if (hyperparameters.contains("convergence")) {
convergence = hyperparameters["convergence"];
hyperparameters.erase("convergence");
}
if (hyperparameters.contains("convergence_best")) {
convergence_best = hyperparameters["convergence_best"];
hyperparameters.erase("convergence_best");
}
if (hyperparameters.contains("bisection")) {
bisection = hyperparameters["bisection"];
hyperparameters.erase("bisection");
}
if (hyperparameters.contains("threshold")) {
threshold = hyperparameters["threshold"];
hyperparameters.erase("threshold");
}
if (hyperparameters.contains("maxTolerance")) {
maxTolerance = hyperparameters["maxTolerance"];
if (maxTolerance < 1 || maxTolerance > 4)
throw std::invalid_argument("Invalid maxTolerance value, must be greater in [1, 4]");
hyperparameters.erase("maxTolerance");
}
if (hyperparameters.contains("predict_voting")) {
predict_voting = hyperparameters["predict_voting"];
hyperparameters.erase("predict_voting");
}
if (hyperparameters.contains("select_features")) {
auto selectedAlgorithm = hyperparameters["select_features"];
std::vector<std::string> algos = { SelectFeatures.IWSS, SelectFeatures.CFS, SelectFeatures.FCBF };
selectFeatures = true;
select_features_algorithm = selectedAlgorithm;
if (std::find(algos.begin(), algos.end(), selectedAlgorithm) == algos.end()) {
throw std::invalid_argument("Invalid selectFeatures value, valid values [" + SelectFeatures.IWSS + ", " + SelectFeatures.CFS + ", " + SelectFeatures.FCBF + "]");
}
hyperparameters.erase("select_features");
}
if (hyperparameters.contains("block_update")) {
block_update = hyperparameters["block_update"];
hyperparameters.erase("block_update");
}
Classifier::setHyperparameters(hyperparameters);
}
void Boost::buildModel(const torch::Tensor& weights)
{
// Models shall be built in trainModel
models.clear();
significanceModels.clear();
n_models = 0;
// Prepare the validation dataset
auto y_ = dataset.index({ -1, "..." });
if (convergence) {
// Prepare train & validation sets from train data
auto fold = folding::StratifiedKFold(5, y_, 271);
auto [train, test] = fold.getFold(0);
auto train_t = torch::tensor(train);
auto test_t = torch::tensor(test);
// Get train and validation sets
X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), train_t });
y_train = dataset.index({ -1, train_t });
X_test = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), test_t });
y_test = dataset.index({ -1, test_t });
dataset = X_train;
m = X_train.size(1);
auto n_classes = states.at(className).size();
// Build dataset with train data
buildDataset(y_train);
metrics = Metrics(dataset, features, className, n_classes);
} else {
// Use all data to train
X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), "..." });
y_train = y_;
}
}
std::vector<int> Boost::featureSelection(torch::Tensor& weights_)
{
int maxFeatures = 0;
if (select_features_algorithm == SelectFeatures.CFS) {
featureSelector = new CFS(dataset, features, className, maxFeatures, states.at(className).size(), weights_);
} else if (select_features_algorithm == SelectFeatures.IWSS) {
if (threshold < 0 || threshold >0.5) {
throw std::invalid_argument("Invalid threshold value for " + SelectFeatures.IWSS + " [0, 0.5]");
}
featureSelector = new IWSS(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);
} else if (select_features_algorithm == SelectFeatures.FCBF) {
if (threshold < 1e-7 || threshold > 1) {
throw std::invalid_argument("Invalid threshold value for " + SelectFeatures.FCBF + " [1e-7, 1]");
}
featureSelector = new FCBF(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);
}
featureSelector->fit();
auto featuresUsed = featureSelector->getFeatures();
delete featureSelector;
return featuresUsed;
}
std::tuple<torch::Tensor&, double, bool> Boost::update_weights(torch::Tensor& ytrain, torch::Tensor& ypred, torch::Tensor& weights)
{
bool terminate = false;
double alpha_t = 0;
auto mask_wrong = ypred != ytrain;
auto mask_right = ypred == ytrain;
auto masked_weights = weights * mask_wrong.to(weights.dtype());
double epsilon_t = masked_weights.sum().item<double>();
if (epsilon_t > 0.5) {
// Inverse the weights policy (plot ln(wt))
// "In each round of AdaBoost, there is a sanity check to ensure that the current base
// learner is better than random guess" (Zhi-Hua Zhou, 2012)
terminate = true;
} else {
double wt = (1 - epsilon_t) / epsilon_t;
alpha_t = epsilon_t == 0 ? 1 : 0.5 * log(wt);
// Step 3.2: Update weights for next classifier
// Step 3.2.1: Update weights of wrong samples
weights += mask_wrong.to(weights.dtype()) * exp(alpha_t) * weights;
// Step 3.2.2: Update weights of right samples
weights += mask_right.to(weights.dtype()) * exp(-alpha_t) * weights;
// Step 3.3: Normalise the weights
double totalWeights = torch::sum(weights).item<double>();
weights = weights / totalWeights;
}
return { weights, alpha_t, terminate };
}
std::tuple<torch::Tensor&, double, bool> Boost::update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights)
{
/* Update Block algorithm
k = # of models in block
n_models = # of models in ensemble to make predictions
n_models_bak = # models saved
models = vector of models to make predictions
models_bak = models not used to make predictions
significances_bak = backup of significances vector
Case list
A) k = 1, n_models = 1 => n = 0 , n_models = n + k
B) k = 1, n_models = n + 1 => n_models = n + k
C) k > 1, n_models = k + 1 => n= 1, n_models = n + k
D) k > 1, n_models = k => n = 0, n_models = n + k
E) k > 1, n_models = k + n => n_models = n + k
A, D) n=0, k > 0, n_models == k
1. n_models_bak <- n_models
2. significances_bak <- significances
3. significances = vector(k, 1)
4. Dont move any classifiers out of models
5. n_models <- k
6. Make prediction, compute alpha, update weights
7. Dont 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 };
}
}

View File

@ -1,52 +0,0 @@
// ***************************************************************
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
// SPDX-FileType: SOURCE
// SPDX-License-Identifier: MIT
// ***************************************************************
#ifndef BOOST_H
#define BOOST_H
#include <string>
#include <tuple>
#include <vector>
#include <nlohmann/json.hpp>
#include <torch/torch.h>
#include "Ensemble.h"
#include "bayesnet/feature_selection/FeatureSelect.h"
namespace bayesnet {
const struct {
std::string CFS = "CFS";
std::string FCBF = "FCBF";
std::string IWSS = "IWSS";
}SelectFeatures;
const struct {
std::string ASC = "asc";
std::string DESC = "desc";
std::string RAND = "rand";
}Orders;
class Boost : public Ensemble {
public:
explicit Boost(bool predict_voting = false);
virtual ~Boost() = default;
void setHyperparameters(const nlohmann::json& hyperparameters_) override;
protected:
std::vector<int> featureSelection(torch::Tensor& weights_);
void buildModel(const torch::Tensor& weights) override;
std::tuple<torch::Tensor&, double, bool> update_weights(torch::Tensor& ytrain, torch::Tensor& ypred, torch::Tensor& weights);
std::tuple<torch::Tensor&, double, bool> update_weights_block(int k, torch::Tensor& ytrain, torch::Tensor& weights);
torch::Tensor X_train, y_train, X_test, y_test;
// Hyperparameters
bool bisection = true; // if true, use bisection stratety to add k models at once to the ensemble
int maxTolerance = 3;
std::string order_algorithm; // order to process the KBest features asc, desc, rand
bool convergence = true; //if true, stop when the model does not improve
bool convergence_best = false; // wether to keep the best accuracy to the moment or the last accuracy as prior accuracy
bool selectFeatures = false; // if true, use feature selection
std::string select_features_algorithm = Orders.DESC; // Selected feature selection algorithm
FeatureSelect* featureSelector = nullptr;
double threshold = -1;
bool block_update = false;
};
}
#endif

View File

@ -1,170 +0,0 @@
// ***************************************************************
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
// SPDX-FileType: SOURCE
// SPDX-License-Identifier: MIT
// ***************************************************************
#include <set>
#include <functional>
#include <limits.h>
#include <tuple>
#include <folding.hpp>
#include "bayesnet/feature_selection/CFS.h"
#include "bayesnet/feature_selection/FCBF.h"
#include "bayesnet/feature_selection/IWSS.h"
#include "BoostA2DE.h"
namespace bayesnet {
BoostA2DE::BoostA2DE(bool predict_voting) : Boost(predict_voting)
{
}
std::vector<int> BoostA2DE::initializeModels(const Smoothing_t smoothing)
{
torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
std::vector<int> featuresSelected = featureSelection(weights_);
if (featuresSelected.size() < 2) {
notes.push_back("No features selected in initialization");
status = ERROR;
return std::vector<int>();
}
for (int i = 0; i < featuresSelected.size() - 1; i++) {
for (int j = i + 1; j < featuresSelected.size(); j++) {
auto parents = { featuresSelected[i], featuresSelected[j] };
std::unique_ptr<Classifier> model = std::make_unique<SPnDE>(parents);
model->fit(dataset, features, className, states, weights_, smoothing);
models.push_back(std::move(model));
significanceModels.push_back(1.0); // They will be updated later in trainModel
n_models++;
}
}
notes.push_back("Used features in initialization: " + std::to_string(featuresSelected.size()) + " of " + std::to_string(features.size()) + " with " + select_features_algorithm);
return featuresSelected;
}
void BoostA2DE::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
{
//
// Logging setup
//
// loguru::set_thread_name("BoostA2DE");
// loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
// loguru::add_file("boostA2DE.log", loguru::Truncate, loguru::Verbosity_MAX);
// Algorithm based on the adaboost algorithm for classification
// as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
fitted = true;
double alpha_t = 0;
torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
bool finished = false;
std::vector<int> featuresUsed;
if (selectFeatures) {
featuresUsed = initializeModels(smoothing);
if (featuresUsed.size() == 0) {
return;
}
auto ypred = predict(X_train);
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
// Update significance of the models
for (int i = 0; i < n_models; ++i) {
significanceModels[i] = alpha_t;
}
if (finished) {
return;
}
}
int numItemsPack = 0; // The counter of the models inserted in the current pack
// Variables to control the accuracy finish condition
double priorAccuracy = 0.0;
double improvement = 1.0;
double convergence_threshold = 1e-4;
int tolerance = 0; // number of times the accuracy is lower than the convergence_threshold
// Step 0: Set the finish condition
// epsilon sub t > 0.5 => inverse the weights policy
// validation error is not decreasing
// run out of features
bool ascending = order_algorithm == Orders.ASC;
std::mt19937 g{ 173 };
std::vector<std::pair<int, int>> pairSelection;
while (!finished) {
// Step 1: Build ranking with mutual information
pairSelection = metrics.SelectKPairs(weights_, featuresUsed, ascending, 0); // Get all the pairs sorted
if (order_algorithm == Orders.RAND) {
std::shuffle(pairSelection.begin(), pairSelection.end(), g);
}
int k = bisection ? pow(2, tolerance) : 1;
int counter = 0; // The model counter of the current pack
// VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
while (counter++ < k && pairSelection.size() > 0) {
auto feature_pair = pairSelection[0];
pairSelection.erase(pairSelection.begin());
std::unique_ptr<Classifier> model;
model = std::make_unique<SPnDE>(std::vector<int>({ feature_pair.first, feature_pair.second }));
model->fit(dataset, features, className, states, weights_, smoothing);
alpha_t = 0.0;
if (!block_update) {
auto ypred = model->predict(X_train);
// Step 3.1: Compute the classifier amout of say
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
}
// Step 3.4: Store classifier and its accuracy to weigh its future vote
numItemsPack++;
models.push_back(std::move(model));
significanceModels.push_back(alpha_t);
n_models++;
// VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
}
if (block_update) {
std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);
}
if (convergence && !finished) {
auto y_val_predict = predict(X_test);
double accuracy = (y_val_predict == y_test).sum().item<double>() / (double)y_test.size(0);
if (priorAccuracy == 0) {
priorAccuracy = accuracy;
} else {
improvement = accuracy - priorAccuracy;
}
if (improvement < convergence_threshold) {
// VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
tolerance++;
} else {
// VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
tolerance = 0; // Reset the counter if the model performs better
numItemsPack = 0;
}
if (convergence_best) {
// Keep the best accuracy until now as the prior accuracy
priorAccuracy = std::max(accuracy, priorAccuracy);
} else {
// Keep the last accuray obtained as the prior accuracy
priorAccuracy = accuracy;
}
}
// VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
finished = finished || tolerance > maxTolerance || pairSelection.size() == 0;
}
if (tolerance > maxTolerance) {
if (numItemsPack < n_models) {
notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated");
// VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
for (int i = 0; i < numItemsPack; ++i) {
significanceModels.pop_back();
models.pop_back();
n_models--;
}
} else {
notes.push_back("Convergence threshold reached & 0 models eliminated");
// VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
}
}
if (pairSelection.size() > 0) {
notes.push_back("Pairs not used in train: " + std::to_string(pairSelection.size()));
status = WARNING;
}
notes.push_back("Number of models: " + std::to_string(n_models));
}
std::vector<std::string> BoostA2DE::graph(const std::string& title) const
{
return Ensemble::graph(title);
}
}

View File

@ -1,25 +0,0 @@
// ***************************************************************
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
// SPDX-FileType: SOURCE
// SPDX-License-Identifier: MIT
// ***************************************************************
#ifndef BOOSTA2DE_H
#define BOOSTA2DE_H
#include <string>
#include <vector>
#include "bayesnet/classifiers/SPnDE.h"
#include "Boost.h"
namespace bayesnet {
class BoostA2DE : public Boost {
public:
explicit BoostA2DE(bool predict_voting = false);
virtual ~BoostA2DE() = default;
std::vector<std::string> graph(const std::string& title = "BoostA2DE") const override;
protected:
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
private:
std::vector<int> initializeModels(const Smoothing_t smoothing);
};
}
#endif

View File

@ -4,40 +4,275 @@
// SPDX-License-Identifier: MIT
// ***************************************************************
#include <random>
#include <set>
#include <functional>
#include <limits.h>
#include <tuple>
#include <folding.hpp>
#include "bayesnet/feature_selection/CFS.h"
#include "bayesnet/feature_selection/FCBF.h"
#include "bayesnet/feature_selection/IWSS.h"
#include "BoostAODE.h"
#include "lib/log/loguru.cpp"
namespace bayesnet {
BoostAODE::BoostAODE(bool predict_voting) : Boost(predict_voting)
BoostAODE::BoostAODE(bool predict_voting) : Ensemble(predict_voting)
{
validHyperparameters = {
"maxModels", "bisection", "order", "convergence", "convergence_best", "threshold",
"select_features", "maxTolerance", "predict_voting", "block_update"
};
}
std::vector<int> BoostAODE::initializeModels(const Smoothing_t smoothing)
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. Dont move any classifiers out of models
5. n_models <- k
6. Make prediction, compute alpha, update weights
7. Dont 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);
std::vector<int> featuresSelected = featureSelection(weights_);
for (const int& feature : featuresSelected) {
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_, smoothing);
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(featuresSelected.size()) + " of " + std::to_string(features.size()) + " with " + select_features_algorithm);
return featuresSelected;
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, const Smoothing_t smoothing)
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);
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)
@ -47,7 +282,7 @@ namespace bayesnet {
bool finished = false;
std::vector<int> featuresUsed;
if (selectFeatures) {
featuresUsed = initializeModels(smoothing);
featuresUsed = initializeModels();
auto ypred = predict(X_train);
std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
// Update significance of the models
@ -83,13 +318,13 @@ namespace bayesnet {
);
int k = bisection ? pow(2, tolerance) : 1;
int counter = 0; // The model counter of the current pack
// VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
while (counter++ < k && featureSelection.size() > 0) {
auto feature = featureSelection[0];
featureSelection.erase(featureSelection.begin());
std::unique_ptr<Classifier> model;
model = std::make_unique<SPODE>(feature);
model->fit(dataset, features, className, states, weights_, smoothing);
model->fit(dataset, features, className, states, weights_);
alpha_t = 0.0;
if (!block_update) {
auto ypred = model->predict(X_train);
@ -102,7 +337,7 @@ namespace bayesnet {
models.push_back(std::move(model));
significanceModels.push_back(alpha_t);
n_models++;
// VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
}
if (block_update) {
std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);
@ -116,10 +351,10 @@ namespace bayesnet {
improvement = accuracy - priorAccuracy;
}
if (improvement < convergence_threshold) {
// VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
tolerance++;
} else {
// VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
tolerance = 0; // Reset the counter if the model performs better
numItemsPack = 0;
}
@ -131,13 +366,13 @@ namespace bayesnet {
priorAccuracy = accuracy;
}
}
// VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
finished = finished || tolerance > maxTolerance || featuresUsed.size() == features.size();
}
if (tolerance > maxTolerance) {
if (numItemsPack < n_models) {
notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated");
// VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
for (int i = 0; i < numItemsPack; ++i) {
significanceModels.pop_back();
models.pop_back();
@ -145,7 +380,7 @@ namespace bayesnet {
}
} else {
notes.push_back("Convergence threshold reached & 0 models eliminated");
// VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
}
}
if (featuresUsed.size() != features.size()) {

View File

@ -6,21 +6,45 @@
#ifndef BOOSTAODE_H
#define BOOSTAODE_H
#include <string>
#include <vector>
#include <map>
#include "bayesnet/classifiers/SPODE.h"
#include "Boost.h"
#include "bayesnet/feature_selection/FeatureSelect.h"
#include "Ensemble.h"
namespace bayesnet {
class BoostAODE : public Boost {
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 trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
void buildModel(const torch::Tensor& weights) override;
void trainModel(const torch::Tensor& weights) override;
private:
std::vector<int> initializeModels(const Smoothing_t smoothing);
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

View File

@ -3,21 +3,22 @@
// SPDX-FileType: SOURCE
// SPDX-License-Identifier: MIT
// ***************************************************************
#include "Ensemble.h"
#include "bayesnet/utils/CountingSemaphore.h"
namespace bayesnet {
Ensemble::Ensemble(bool predict_voting) : Classifier(Network()), n_models(0), predict_voting(predict_voting)
{
};
const std::string ENSEMBLE_NOT_FITTED = "Ensemble has not been fitted";
void Ensemble::trainModel(const torch::Tensor& weights, const Smoothing_t smoothing)
void Ensemble::trainModel(const torch::Tensor& weights)
{
n_models = models.size();
for (auto i = 0; i < n_models; ++i) {
// fit with std::vectors
models[i]->fit(dataset, features, className, states, smoothing);
models[i]->fit(dataset, features, className, states);
}
}
std::vector<int> Ensemble::compute_arg_max(std::vector<std::vector<double>>& X)
@ -84,9 +85,17 @@ namespace bayesnet {
{
auto n_states = models[0]->getClassNumStates();
torch::Tensor y_pred = torch::zeros({ X.size(1), n_states }, torch::kFloat32);
auto threads{ std::vector<std::thread>() };
std::mutex mtx;
for (auto i = 0; i < n_models; ++i) {
auto ypredict = models[i]->predict_proba(X);
y_pred += ypredict * significanceModels[i];
threads.push_back(std::thread([&, i]() {
auto ypredict = models[i]->predict_proba(X);
std::lock_guard<std::mutex> lock(mtx);
y_pred += ypredict * significanceModels[i];
}));
}
for (auto& thread : threads) {
thread.join();
}
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
y_pred /= sum;
@ -96,15 +105,23 @@ namespace bayesnet {
{
auto n_states = models[0]->getClassNumStates();
std::vector<std::vector<double>> y_pred(X[0].size(), std::vector<double>(n_states, 0.0));
auto threads{ std::vector<std::thread>() };
std::mutex mtx;
for (auto i = 0; i < n_models; ++i) {
auto ypredict = models[i]->predict_proba(X);
assert(ypredict.size() == y_pred.size());
assert(ypredict[0].size() == y_pred[0].size());
// Multiply each prediction by the significance of the model and then add it to the final prediction
for (auto j = 0; j < ypredict.size(); ++j) {
std::transform(y_pred[j].begin(), y_pred[j].end(), ypredict[j].begin(), y_pred[j].begin(),
[significanceModels = significanceModels[i]](double x, double y) { return x + y * significanceModels; });
}
threads.push_back(std::thread([&, i]() {
auto ypredict = models[i]->predict_proba(X);
assert(ypredict.size() == y_pred.size());
assert(ypredict[0].size() == y_pred[0].size());
std::lock_guard<std::mutex> lock(mtx);
// Multiply each prediction by the significance of the model and then add it to the final prediction
for (auto j = 0; j < ypredict.size(); ++j) {
std::transform(y_pred[j].begin(), y_pred[j].end(), ypredict[j].begin(), y_pred[j].begin(),
[significanceModels = significanceModels[i]](double x, double y) { return x + y * significanceModels; });
}
}));
}
for (auto& thread : threads) {
thread.join();
}
auto sum = std::reduce(significanceModels.begin(), significanceModels.end());
//Divide each element of the prediction by the sum of the significances
@ -124,9 +141,17 @@ namespace bayesnet {
{
// Build a m x n_models tensor with the predictions of each model
torch::Tensor y_pred = torch::zeros({ X.size(1), n_models }, torch::kInt32);
auto threads{ std::vector<std::thread>() };
std::mutex mtx;
for (auto i = 0; i < n_models; ++i) {
auto ypredict = models[i]->predict(X);
y_pred.index_put_({ "...", i }, ypredict);
threads.push_back(std::thread([&, i]() {
auto ypredict = models[i]->predict(X);
std::lock_guard<std::mutex> lock(mtx);
y_pred.index_put_({ "...", i }, ypredict);
}));
}
for (auto& thread : threads) {
thread.join();
}
return voting(y_pred);
}

View File

@ -46,7 +46,7 @@ namespace bayesnet {
unsigned n_models;
std::vector<std::unique_ptr<Classifier>> models;
std::vector<double> significanceModels;
void trainModel(const torch::Tensor& weights, const Smoothing_t smoothing) override;
void trainModel(const torch::Tensor& weights) override;
bool predict_voting;
};
}

View File

@ -5,20 +5,20 @@
// ***************************************************************
#include <thread>
#include <mutex>
#include <sstream>
#include <numeric>
#include <algorithm>
#include "Network.h"
#include "bayesnet/utils/bayesnetUtils.h"
#include "bayesnet/utils/CountingSemaphore.h"
#include <pthread.h>
#include <fstream>
namespace bayesnet {
Network::Network() : fitted{ false }, classNumStates{ 0 }
Network::Network() : fitted{ false }, maxThreads{ 0.95 }, classNumStates{ 0 }, laplaceSmoothing{ 0 }
{
}
Network::Network(const Network& other) : features(other.features), className(other.className), classNumStates(other.getClassNumStates()),
fitted(other.fitted), samples(other.samples)
Network::Network(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();
@ -35,15 +35,16 @@ namespace bayesnet {
nodes.clear();
samples = torch::Tensor();
}
float Network::getMaxThreads() const
{
return maxThreads;
}
torch::Tensor& Network::getSamples()
{
return samples;
}
void Network::addNode(const std::string& name)
{
if (fitted) {
throw std::invalid_argument("Cannot add node to a fitted network. Initialize first.");
}
if (name == "") {
throw std::invalid_argument("Node name cannot be empty");
}
@ -93,21 +94,12 @@ namespace bayesnet {
}
void Network::addEdge(const std::string& parent, const std::string& child)
{
if (fitted) {
throw std::invalid_argument("Cannot add edge to a fitted network. Initialize first.");
}
if (nodes.find(parent) == nodes.end()) {
throw std::invalid_argument("Parent node " + parent + " does not exist");
}
if (nodes.find(child) == nodes.end()) {
throw std::invalid_argument("Child node " + child + " does not exist");
}
// Check if the edge is already in the graph
for (auto& node : nodes[parent]->getChildren()) {
if (node->getName() == child) {
throw std::invalid_argument("Edge " + parent + " -> " + child + " already exists");
}
}
// Temporarily add edge to check for cycles
nodes[parent]->addChild(nodes[child].get());
nodes[child]->addParent(nodes[parent].get());
@ -163,7 +155,7 @@ namespace bayesnet {
classNumStates = nodes.at(className)->getNumStates();
}
// X comes in nxm, where n is the number of features and m the number of samples
void Network::fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
void Network::fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states)
{
checkFitData(X.size(1), X.size(0), y.size(0), featureNames, className, states, weights);
this->className = className;
@ -172,17 +164,17 @@ namespace bayesnet {
for (int i = 0; i < featureNames.size(); ++i) {
auto row_feature = X.index({ i, "..." });
}
completeFit(states, weights, smoothing);
completeFit(states, weights);
}
void Network::fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
void Network::fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states)
{
checkFitData(samples.size(1), samples.size(0) - 1, samples.size(1), featureNames, className, states, weights);
this->className = className;
this->samples = samples;
completeFit(states, weights, smoothing);
completeFit(states, weights);
}
// input_data comes in nxm, where n is the number of features and m the number of samples
void Network::fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights_, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing)
void Network::fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights_, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states)
{
const torch::Tensor weights = torch::tensor(weights_, torch::kFloat64);
checkFitData(input_data[0].size(), input_data.size(), labels.size(), featureNames, className, states, weights);
@ -193,43 +185,17 @@ namespace bayesnet {
samples.index_put_({ i, "..." }, torch::tensor(input_data[i], torch::kInt32));
}
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
completeFit(states, weights, smoothing);
completeFit(states, weights);
}
void Network::completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing)
void Network::completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights)
{
setStates(states);
laplaceSmoothing = 1.0 / samples.size(1); // To use in CPT computation
std::vector<std::thread> threads;
auto& semaphore = CountingSemaphore::getInstance();
const double n_samples = static_cast<double>(samples.size(1));
auto worker = [&](std::pair<const std::string, std::unique_ptr<Node>>& node, int i) {
std::string threadName = "FitWorker-" + std::to_string(i);
#if defined(__linux__)
pthread_setname_np(pthread_self(), threadName.c_str());
#else
pthread_setname_np(threadName.c_str());
#endif
double numStates = static_cast<double>(node.second->getNumStates());
double smoothing_factor;
switch (smoothing) {
case Smoothing_t::ORIGINAL:
smoothing_factor = 1.0 / n_samples;
break;
case Smoothing_t::LAPLACE:
smoothing_factor = 1.0;
break;
case Smoothing_t::CESTNIK:
smoothing_factor = 1 / numStates;
break;
default:
smoothing_factor = 0.0; // No smoothing
}
node.second->computeCPT(samples, features, smoothing_factor, weights);
semaphore.release();
};
int i = 0;
for (auto& node : nodes) {
semaphore.acquire();
threads.emplace_back(worker, std::ref(node), i++);
threads.emplace_back([this, &node, &weights]() {
node.second->computeCPT(samples, features, laplaceSmoothing, weights);
});
}
for (auto& thread : threads) {
thread.join();
@ -241,38 +207,14 @@ namespace bayesnet {
if (!fitted) {
throw std::logic_error("You must call fit() before calling predict()");
}
// Ensure the sample size is equal to the number of features
if (samples.size(0) != features.size() - 1) {
throw std::invalid_argument("(T) Sample size (" + std::to_string(samples.size(0)) +
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
}
torch::Tensor result;
std::vector<std::thread> threads;
std::mutex mtx;
auto& semaphore = CountingSemaphore::getInstance();
result = torch::zeros({ samples.size(1), classNumStates }, torch::kFloat64);
auto worker = [&](const torch::Tensor& sample, int i) {
std::string threadName = "PredictWorker-" + std::to_string(i);
#if defined(__linux__)
pthread_setname_np(pthread_self(), threadName.c_str());
#else
pthread_setname_np(threadName.c_str());
#endif
for (int i = 0; i < samples.size(1); ++i) {
const torch::Tensor sample = samples.index({ "...", i });
auto psample = predict_sample(sample);
auto temp = torch::tensor(psample, torch::kFloat64);
{
std::lock_guard<std::mutex> lock(mtx);
result.index_put_({ i, "..." }, temp);
}
semaphore.release();
};
for (int i = 0; i < samples.size(1); ++i) {
semaphore.acquire();
const torch::Tensor sample = samples.index({ "...", i });
threads.emplace_back(worker, sample, i);
}
for (auto& thread : threads) {
thread.join();
// result.index_put_({ i, "..." }, torch::tensor(predict_sample(sample), torch::kFloat64));
result.index_put_({ i, "..." }, temp);
}
if (proba)
return result;
@ -297,38 +239,18 @@ namespace bayesnet {
if (!fitted) {
throw std::logic_error("You must call fit() before calling predict()");
}
// Ensure the sample size is equal to the number of features
if (tsamples.size() != features.size() - 1) {
throw std::invalid_argument("(V) Sample size (" + std::to_string(tsamples.size()) +
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
}
std::vector<int> predictions(tsamples[0].size(), 0);
std::vector<int> predictions;
std::vector<int> sample;
std::vector<std::thread> threads;
auto& semaphore = CountingSemaphore::getInstance();
auto worker = [&](const std::vector<int>& sample, const int row, int& prediction) {
std::string threadName = "(V)PWorker-" + std::to_string(row);
#if defined(__linux__)
pthread_setname_np(pthread_self(), threadName.c_str());
#else
pthread_setname_np(threadName.c_str());
#endif
auto classProbabilities = predict_sample(sample);
auto maxElem = max_element(classProbabilities.begin(), classProbabilities.end());
int predictedClass = distance(classProbabilities.begin(), maxElem);
prediction = predictedClass;
semaphore.release();
};
for (int row = 0; row < tsamples[0].size(); ++row) {
sample.clear();
for (int col = 0; col < tsamples.size(); ++col) {
sample.push_back(tsamples[col][row]);
}
semaphore.acquire();
threads.emplace_back(worker, sample, row, std::ref(predictions[row]));
}
for (auto& thread : threads) {
thread.join();
std::vector<double> classProbabilities = predict_sample(sample);
// Find the class with the maximum posterior probability
auto maxElem = max_element(classProbabilities.begin(), classProbabilities.end());
int predictedClass = distance(classProbabilities.begin(), maxElem);
predictions.push_back(predictedClass);
}
return predictions;
}
@ -339,36 +261,14 @@ namespace bayesnet {
if (!fitted) {
throw std::logic_error("You must call fit() before calling predict_proba()");
}
// Ensure the sample size is equal to the number of features
if (tsamples.size() != features.size() - 1) {
throw std::invalid_argument("(V) Sample size (" + std::to_string(tsamples.size()) +
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
}
std::vector<std::vector<double>> predictions(tsamples[0].size(), std::vector<double>(classNumStates, 0.0));
std::vector<std::vector<double>> predictions;
std::vector<int> sample;
std::vector<std::thread> threads;
auto& semaphore = CountingSemaphore::getInstance();
auto worker = [&](const std::vector<int>& sample, int row, std::vector<double>& predictions) {
std::string threadName = "(V)PWorker-" + std::to_string(row);
#if defined(__linux__)
pthread_setname_np(pthread_self(), threadName.c_str());
#else
pthread_setname_np(threadName.c_str());
#endif
std::vector<double> classProbabilities = predict_sample(sample);
predictions = classProbabilities;
semaphore.release();
};
for (int row = 0; row < tsamples[0].size(); ++row) {
sample.clear();
for (int col = 0; col < tsamples.size(); ++col) {
sample.push_back(tsamples[col][row]);
}
semaphore.acquire();
threads.emplace_back(worker, sample, row, std::ref(predictions[row]));
}
for (auto& thread : threads) {
thread.join();
predictions.push_back(predict_sample(sample));
}
return predictions;
}
@ -386,6 +286,11 @@ namespace bayesnet {
// Return 1xn std::vector of probabilities
std::vector<double> Network::predict_sample(const std::vector<int>& sample)
{
// Ensure the sample size is equal to the number of features
if (sample.size() != features.size() - 1) {
throw std::invalid_argument("Sample size (" + std::to_string(sample.size()) +
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
}
std::map<std::string, int> evidence;
for (int i = 0; i < sample.size(); ++i) {
evidence[features[i]] = sample[i];
@ -395,26 +300,44 @@ namespace bayesnet {
// Return 1xn std::vector of probabilities
std::vector<double> Network::predict_sample(const torch::Tensor& sample)
{
// Ensure the sample size is equal to the number of features
if (sample.size(0) != features.size() - 1) {
throw std::invalid_argument("Sample size (" + std::to_string(sample.size(0)) +
") does not match the number of features (" + std::to_string(features.size() - 1) + ")");
}
std::map<std::string, int> evidence;
for (int i = 0; i < sample.size(0); ++i) {
evidence[features[i]] = sample[i].item<int>();
}
return exactInference(evidence);
}
double Network::computeFactor(std::map<std::string, int>& completeEvidence)
{
double result = 1.0;
for (auto& node : getNodes()) {
result *= node.second->getFactorValue(completeEvidence);
}
return result;
}
std::vector<double> Network::exactInference(std::map<std::string, int>& evidence)
{
std::vector<double> result(classNumStates, 0.0);
auto completeEvidence = std::map<std::string, int>(evidence);
std::vector<std::thread> threads;
std::mutex mtx;
for (int i = 0; i < classNumStates; ++i) {
completeEvidence[getClassName()] = i;
double partial = 1.0;
for (auto& node : getNodes()) {
partial *= node.second->getFactorValue(completeEvidence);
}
result[i] = partial;
threads.emplace_back([this, &result, &evidence, i, &mtx]() {
auto completeEvidence = std::map<std::string, int>(evidence);
completeEvidence[getClassName()] = i;
double factor = computeFactor(completeEvidence);
std::lock_guard<std::mutex> lock(mtx);
result[i] = factor;
});
}
for (auto& thread : threads) {
thread.join();
}
// Normalize result
double sum = std::accumulate(result.begin(), result.end(), 0.0);
double sum = accumulate(result.begin(), result.end(), 0.0);
transform(result.begin(), result.end(), result.begin(), [sum](const double& value) { return value / sum; });
return result;
}

View File

@ -12,18 +12,14 @@
#include "Node.h"
namespace bayesnet {
enum class Smoothing_t {
NONE = -1,
ORIGINAL = 0,
LAPLACE,
CESTNIK
};
class Network {
public:
Network();
explicit Network(float);
explicit Network(const Network&);
~Network() = default;
torch::Tensor& getSamples();
float getMaxThreads() const;
void addNode(const std::string&);
void addEdge(const std::string&, const std::string&);
std::map<std::string, std::unique_ptr<Node>>& getNodes();
@ -36,9 +32,9 @@ namespace bayesnet {
/*
Notice: Nodes have to be inserted in the same order as they are in the dataset, i.e., first node is first column and so on.
*/
void fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
void fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
void fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const Smoothing_t smoothing);
void fit(const std::vector<std::vector<int>>& input_data, const std::vector<int>& labels, const std::vector<double>& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states);
void fit(const torch::Tensor& X, const torch::Tensor& y, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states);
void fit(const torch::Tensor& samples, const torch::Tensor& weights, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states);
std::vector<int> predict(const std::vector<std::vector<int>>&); // Return mx1 std::vector of predictions
torch::Tensor predict(const torch::Tensor&); // Return mx1 tensor of predictions
torch::Tensor predict_tensor(const torch::Tensor& samples, const bool proba);
@ -54,16 +50,19 @@ namespace bayesnet {
private:
std::map<std::string, std::unique_ptr<Node>> nodes;
bool fitted;
float maxThreads = 0.95;
int classNumStates;
std::vector<std::string> features; // Including classname
std::string className;
double laplaceSmoothing;
torch::Tensor samples; // n+1xm tensor used to fit the model
bool isCyclic(const std::string&, std::unordered_set<std::string>&, std::unordered_set<std::string>&);
std::vector<double> predict_sample(const std::vector<int>&);
std::vector<double> predict_sample(const torch::Tensor&);
std::vector<double> exactInference(std::map<std::string, int>&);
void completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const Smoothing_t smoothing);
void checkFitData(int n_samples, int n_features, int n_samples_y, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
double computeFactor(std::map<std::string, int>&);
void completeFit(const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
void checkFitData(int n_features, int n_samples, int n_samples_y, const std::vector<std::string>& featureNames, const std::string& className, const std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights);
void setStates(const std::map<std::string, std::vector<int>>&);
};
}

View File

@ -90,54 +90,51 @@ namespace bayesnet {
}
return result;
}
void Node::computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double smoothing, const torch::Tensor& weights)
void Node::computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double laplaceSmoothing, const torch::Tensor& weights)
{
dimensions.clear();
// Get dimensions of the CPT
dimensions.push_back(numStates);
transform(parents.begin(), parents.end(), back_inserter(dimensions), [](const auto& parent) { return parent->getNumStates(); });
// Create a tensor of zeros with the dimensions of the CPT
cpTable = torch::zeros(dimensions, torch::kDouble) + smoothing;
cpTable = torch::zeros(dimensions, torch::kFloat) + laplaceSmoothing;
// Fill table with counts
auto pos = find(features.begin(), features.end(), name);
if (pos == features.end()) {
throw std::logic_error("Feature " + name + " not found in dataset");
}
int name_index = pos - features.begin();
c10::List<c10::optional<at::Tensor>> coordinates;
for (int n_sample = 0; n_sample < dataset.size(1); ++n_sample) {
coordinates.clear();
auto sample = dataset.index({ "...", n_sample });
coordinates.push_back(sample[name_index]);
c10::List<c10::optional<at::Tensor>> coordinates;
coordinates.push_back(dataset.index({ name_index, n_sample }));
for (auto parent : parents) {
pos = find(features.begin(), features.end(), parent->getName());
if (pos == features.end()) {
throw std::logic_error("Feature parent " + parent->getName() + " not found in dataset");
}
int parent_index = pos - features.begin();
coordinates.push_back(sample[parent_index]);
coordinates.push_back(dataset.index({ parent_index, n_sample }));
}
// Increment the count of the corresponding coordinate
cpTable.index_put_({ coordinates }, weights.index({ n_sample }), true);
cpTable.index_put_({ coordinates }, cpTable.index({ coordinates }) + weights.index({ n_sample }).item<double>());
}
// Normalize the counts
// Divide each row by the sum of the row
cpTable = cpTable / cpTable.sum(0);
}
double Node::getFactorValue(std::map<std::string, int>& evidence)
float Node::getFactorValue(std::map<std::string, int>& evidence)
{
c10::List<c10::optional<at::Tensor>> coordinates;
// following predetermined order of indices in the cpTable (see Node.h)
coordinates.push_back(at::tensor(evidence[name]));
transform(parents.begin(), parents.end(), std::back_inserter(coordinates), [&evidence](const auto& parent) { return at::tensor(evidence[parent->getName()]); });
return cpTable.index({ coordinates }).item<double>();
return cpTable.index({ coordinates }).item<float>();
}
std::vector<std::string> Node::graph(const std::string& className)
{
auto output = std::vector<std::string>();
auto suffix = name == className ? ", fontcolor=red, fillcolor=lightblue, style=filled " : "";
output.push_back("\"" + name + "\" [shape=circle" + suffix + "] \n");
transform(children.begin(), children.end(), back_inserter(output), [this](const auto& child) { return "\"" + name + "\" -> \"" + child->getName() + "\""; });
output.push_back(name + " [shape=circle" + suffix + "] \n");
transform(children.begin(), children.end(), back_inserter(output), [this](const auto& child) { return name + " -> " + child->getName(); });
return output;
}
}

View File

@ -23,12 +23,12 @@ namespace bayesnet {
std::vector<Node*>& getParents();
std::vector<Node*>& getChildren();
torch::Tensor& getCPT();
void computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double smoothing, const torch::Tensor& weights);
void computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double laplaceSmoothing, const torch::Tensor& weights);
int getNumStates() const;
void setNumStates(int);
unsigned minFill();
std::vector<std::string> graph(const std::string& clasName); // Returns a std::vector of std::strings representing the graph in graphviz format
double getFactorValue(std::map<std::string, int>&);
float getFactorValue(std::map<std::string, int>&);
private:
std::string name;
std::vector<Node*> parents;

View File

@ -30,53 +30,6 @@ namespace bayesnet {
}
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
}
std::vector<std::pair<int, int>> Metrics::SelectKPairs(const torch::Tensor& weights, std::vector<int>& featuresExcluded, bool ascending, unsigned k)
{
// Return the K Best features
auto n = features.size();
// compute scores
scoresKPairs.clear();
pairsKBest.clear();
auto labels = samples.index({ -1, "..." });
for (int i = 0; i < n - 1; ++i) {
if (std::find(featuresExcluded.begin(), featuresExcluded.end(), i) != featuresExcluded.end()) {
continue;
}
for (int j = i + 1; j < n; ++j) {
if (std::find(featuresExcluded.begin(), featuresExcluded.end(), j) != featuresExcluded.end()) {
continue;
}
auto key = std::make_pair(i, j);
auto value = conditionalMutualInformation(samples.index({ i, "..." }), samples.index({ j, "..." }), labels, weights);
scoresKPairs.push_back({ key, value });
}
}
// sort scores
if (ascending) {
sort(scoresKPairs.begin(), scoresKPairs.end(), [](auto& a, auto& b)
{ return a.second < b.second; });
} else {
sort(scoresKPairs.begin(), scoresKPairs.end(), [](auto& a, auto& b)
{ return a.second > b.second; });
}
for (auto& [pairs, score] : scoresKPairs) {
pairsKBest.push_back(pairs);
}
if (k != 0 && k < pairsKBest.size()) {
if (ascending) {
int limit = pairsKBest.size() - k;
for (int i = 0; i < limit; i++) {
pairsKBest.erase(pairsKBest.begin());
scoresKPairs.erase(scoresKPairs.begin());
}
} else {
pairsKBest.resize(k);
scoresKPairs.resize(k);
}
}
return pairsKBest;
}
std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k)
{
// Return the K Best features
@ -116,10 +69,7 @@ namespace bayesnet {
{
return scoresKBest;
}
std::vector<std::pair<std::pair<int, int>, double>> Metrics::getScoresKPairs() const
{
return scoresKPairs;
}
torch::Tensor Metrics::conditionalEdge(const torch::Tensor& weights)
{
auto result = std::vector<double>();
@ -198,20 +148,24 @@ namespace bayesnet {
}
return entropyValue;
}
// H(X|Y,C) = sum_{y in Y, c in C} p(x,c) H(X|Y=y,C=c)
// 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]);
@ -220,29 +174,34 @@ namespace bayesnet {
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_xc = marginalCount[keyMarginal] / totalWeight;
double p_y_given_xc = jointFreq / marginalCount[keyMarginal];
if (p_y_given_xc > 0) {
conditionalEntropy -= (jointFreq / totalWeight) * std::log(p_y_given_xc);
}
}
return conditionalEntropy;
}
// I(X;Y) = H(Y) - H(Y|X) ; I(X;Y) >= 0
// I(X;Y) = H(Y) - H(Y|X)
double Metrics::mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights)
{
return std::max(entropy(firstFeature, weights) - conditionalEntropy(firstFeature, secondFeature, weights), 0.0);
return entropy(firstFeature, weights) - conditionalEntropy(firstFeature, secondFeature, weights);
}
// I(X;Y|C) = H(X|C) - H(X|Y,C) >= 0
// 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);

View File

@ -16,9 +16,7 @@ namespace bayesnet {
Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
Metrics(const std::vector<std::vector<int>>& vsamples, const std::vector<int>& labels, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0);
std::vector<std::pair<int, int>> SelectKPairs(const torch::Tensor& weights, std::vector<int>& featuresExcluded, bool ascending = false, unsigned k = 0);
std::vector<double> getScoresKBest() const;
std::vector<std::pair<std::pair<int, int>, double>> getScoresKPairs() const;
double mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
double conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights);
torch::Tensor conditionalEdge(const torch::Tensor& weights);
@ -35,7 +33,7 @@ namespace bayesnet {
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
{
std::vector<std::pair<T, T>> result;
for (int i = 0; i < source.size() - 1; ++i) {
for (int i = 0; i < source.size(); ++i) {
T temp = source[i];
for (int j = i + 1; j < source.size(); ++j) {
result.push_back({ temp, source[j] });
@ -54,8 +52,6 @@ namespace bayesnet {
int classNumStates = 0;
std::vector<double> scoresKBest;
std::vector<int> featuresKBest; // sorted indices of the features
std::vector<std::pair<int, int>> pairsKBest; // sorted indices of the pairs
std::vector<std::pair<std::pair<int, int>, double>> scoresKPairs;
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
};
}

View File

@ -1,46 +0,0 @@
#ifndef COUNTING_SEMAPHORE_H
#define COUNTING_SEMAPHORE_H
#include <mutex>
#include <condition_variable>
#include <algorithm>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <thread>
class CountingSemaphore {
public:
static CountingSemaphore& getInstance()
{
static CountingSemaphore instance;
return instance;
}
// Delete copy constructor and assignment operator
CountingSemaphore(const CountingSemaphore&) = delete;
CountingSemaphore& operator=(const CountingSemaphore&) = delete;
void acquire()
{
std::unique_lock<std::mutex> lock(mtx_);
cv_.wait(lock, [this]() { return count_ > 0; });
--count_;
}
void release()
{
std::lock_guard<std::mutex> lock(mtx_);
++count_;
if (count_ <= max_count_) {
cv_.notify_one();
}
}
private:
CountingSemaphore()
: max_count_(std::max(1u, static_cast<uint>(0.95 * std::thread::hardware_concurrency()))),
count_(max_count_)
{
}
std::mutex mtx_;
std::condition_variable cv_;
const uint max_count_;
uint count_;
};
#endif

View File

@ -53,14 +53,14 @@ namespace bayesnet {
}
}
void MST::insertElement(std::list<int>& variables, int variable)
void insertElement(std::list<int>& variables, int variable)
{
if (std::find(variables.begin(), variables.end(), variable) == variables.end()) {
variables.push_front(variable);
}
}
std::vector<std::pair<int, int>> MST::reorder(std::vector<std::pair<float, std::pair<int, int>>> T, int root_original)
std::vector<std::pair<int, int>> reorder(std::vector<std::pair<float, std::pair<int, int>>> T, int root_original)
{
// Create the edges of a DAG from the MST
// replacing unordered_set with list because unordered_set cannot guarantee the order of the elements inserted

View File

@ -14,8 +14,6 @@ namespace bayesnet {
public:
MST() = default;
MST(const std::vector<std::string>& features, const torch::Tensor& weights, const int root);
void insertElement(std::list<int>& variables, int variable);
std::vector<std::pair<int, int>> reorder(std::vector<std::pair<float, std::pair<int, int>>> T, int root_original);
std::vector<std::pair<int, int>> maximumSpanningTree();
private:
torch::Tensor weights;

View File

@ -137,7 +137,7 @@
include(CMakeParseArguments)
option(CODE_COVERAGE_VERBOSE "Verbose information" TRUE)
option(CODE_COVERAGE_VERBOSE "Verbose information" FALSE)
# Check prereqs
find_program( GCOV_PATH gcov )
@ -160,11 +160,7 @@ foreach(LANG ${LANGUAGES})
endif()
elseif(NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU"
AND NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "(LLVM)?[Ff]lang")
if ("${LANG}" MATCHES "CUDA")
message(STATUS "Ignoring CUDA")
else()
message(FATAL_ERROR "Compiler is not GNU or Flang! Aborting...")
endif()
message(FATAL_ERROR "Compiler is not GNU or Flang! Aborting...")
endif()
endforeach()

View File

@ -1,16 +1,36 @@
@startuml
title clang-uml class diagram model
class "bayesnet::Node" as C_0010428199432536647474
class C_0010428199432536647474 #aliceblue;line:blue;line.dotted;text:blue {
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 smoothing, const torch::Tensor & weights) : 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> &) : double
+getFactorValue(std::map<std::string,int> &) : float
+getName() const : std::string
+getNumStates() const : int
+getParents() : std::vector<Node *> &
@ -21,29 +41,24 @@ class C_0010428199432536647474 #aliceblue;line:blue;line.dotted;text:blue {
+setNumStates(int) : void
__
}
enum "bayesnet::Smoothing_t" as C_0013393078277439680282
enum C_0013393078277439680282 {
NONE
ORIGINAL
LAPLACE
CESTNIK
}
class "bayesnet::Network" as C_0009493661199123436603
class C_0009493661199123436603 #aliceblue;line:blue;line.dotted;text:blue {
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, const Smoothing_t smoothing) : void
+fit(const torch::Tensor & X, const torch::Tensor & y, const torch::Tensor & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : void
+fit(const std::vector<std::vector<int>> & input_data, const std::vector<int> & labels, const std::vector<double> & weights, const std::vector<std::string> & featureNames, const std::string & className, const std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : void
+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 &
@ -61,21 +76,21 @@ class C_0009493661199123436603 #aliceblue;line:blue;line.dotted;text:blue {
+version() : std::string
__
}
enum "bayesnet::status_t" as C_0005907365846270811004
enum C_0005907365846270811004 {
enum "bayesnet::status_t" as C_0000738420730783851375
enum C_0000738420730783851375 {
NORMAL
WARNING
ERROR
}
abstract "bayesnet::BaseClassifier" as C_0002617087915615796317
abstract C_0002617087915615796317 #aliceblue;line:blue;line.dotted;text:blue {
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, const Smoothing_t smoothing) = 0 : BaseClassifier &
{abstract} +fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) = 0 : BaseClassifier &
{abstract} +fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const torch::Tensor & weights, const Smoothing_t smoothing) = 0 : BaseClassifier &
{abstract} +fit(std::vector<std::vector<int>> & X, std::vector<int> & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) = 0 : BaseClassifier &
{abstract} +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
@ -94,35 +109,12 @@ abstract C_0002617087915615796317 #aliceblue;line:blue;line.dotted;text:blue {
{abstract} +setHyperparameters(const nlohmann::json & hyperparameters) = 0 : void
{abstract} +show() const = 0 : std::vector<std::string>
{abstract} +topological_order() = 0 : std::vector<std::string>
{abstract} #trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) = 0 : void
{abstract} #trainModel(const torch::Tensor & weights) = 0 : void
__
#validHyperparameters : std::vector<std::string>
}
class "bayesnet::Metrics" as C_0005895723015084986588
class C_0005895723015084986588 #aliceblue;line:blue;line.dotted;text:blue {
+Metrics() = default : void
+Metrics(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int classNumStates) : void
+Metrics(const std::vector<std::vector<int>> & vsamples, const std::vector<int> & labels, const std::vector<std::string> & features, const std::string & className, const int classNumStates) : void
..
+SelectKBestWeighted(const torch::Tensor & weights, bool ascending = false, unsigned int k = 0) : std::vector<int>
+SelectKPairs(const torch::Tensor & weights, std::vector<int> & featuresExcluded, bool ascending = false, unsigned int k = 0) : std::vector<std::pair<int,int>>
+conditionalEdge(const torch::Tensor & weights) : torch::Tensor
+conditionalEntropy(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & labels, const torch::Tensor & weights) : double
+conditionalMutualInformation(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & labels, const torch::Tensor & weights) : double
#doCombinations<T>(const std::vector<T> & source) : std::vector<std::pair<T, T> >
+entropy(const torch::Tensor & feature, const torch::Tensor & weights) : double
+getScoresKBest() const : std::vector<double>
+getScoresKPairs() const : std::vector<std::pair<std::pair<int,int>,double>>
+maximumSpanningTree(const std::vector<std::string> & features, const torch::Tensor & weights, const int root) : std::vector<std::pair<int,int>>
+mutualInformation(const torch::Tensor & firstFeature, const torch::Tensor & secondFeature, const torch::Tensor & weights) : double
#pop_first<T>(std::vector<T> & v) : T
__
#className : std::string
#features : std::vector<std::string>
#samples : torch::Tensor
}
abstract "bayesnet::Classifier" as C_0016351972983202413152
abstract C_0016351972983202413152 #aliceblue;line:blue;line.dotted;text:blue {
abstract "bayesnet::Classifier" as C_0002043996622900301644
abstract C_0002043996622900301644 #aliceblue;line:blue;line.dotted;text:blue {
+Classifier(Network model) : void
+~Classifier() = default : void
..
@ -131,10 +123,10 @@ abstract C_0016351972983202413152 #aliceblue;line:blue;line.dotted;text:blue {
{abstract} #buildModel(const torch::Tensor & weights) = 0 : void
#checkFitParameters() : void
+dump_cpt() const : std::string
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : Classifier &
+fit(std::vector<std::vector<int>> & X, std::vector<int> & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : Classifier &
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : Classifier &
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const torch::Tensor & weights, const Smoothing_t smoothing) : Classifier &
+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
@ -151,7 +143,7 @@ abstract C_0016351972983202413152 #aliceblue;line:blue;line.dotted;text:blue {
+setHyperparameters(const nlohmann::json & hyperparameters) : void
+show() const : std::vector<std::string>
+topological_order() : std::vector<std::string>
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
#trainModel(const torch::Tensor & weights) : void
__
#className : std::string
#dataset : torch::Tensor
@ -165,8 +157,8 @@ __
#states : std::map<std::string,std::vector<int>>
#status : status_t
}
class "bayesnet::KDB" as C_0008902920152122000044
class C_0008902920152122000044 #aliceblue;line:blue;line.dotted;text:blue {
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
..
@ -175,26 +167,8 @@ class C_0008902920152122000044 #aliceblue;line:blue;line.dotted;text:blue {
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
__
}
class "bayesnet::SPODE" as C_0004096182510460307610
class C_0004096182510460307610 #aliceblue;line:blue;line.dotted;text:blue {
+SPODE(int root) : void
+~SPODE() = default : void
..
#buildModel(const torch::Tensor & weights) : void
+graph(const std::string & name = "SPODE") const : std::vector<std::string>
__
}
class "bayesnet::SPnDE" as C_0016268916386101512883
class C_0016268916386101512883 #aliceblue;line:blue;line.dotted;text:blue {
+SPnDE(std::vector<int> parents) : void
+~SPnDE() = default : void
..
#buildModel(const torch::Tensor & weights) : void
+graph(const std::string & name = "SPnDE") const : std::vector<std::string>
__
}
class "bayesnet::TAN" as C_0014087955399074584137
class C_0014087955399074584137 #aliceblue;line:blue;line.dotted;text:blue {
class "bayesnet::TAN" as C_0001760994424884323017
class C_0001760994424884323017 #aliceblue;line:blue;line.dotted;text:blue {
+TAN() : void
+~TAN() = default : void
..
@ -202,8 +176,8 @@ class C_0014087955399074584137 #aliceblue;line:blue;line.dotted;text:blue {
+graph(const std::string & name = "TAN") const : std::vector<std::string>
__
}
class "bayesnet::Proposal" as C_0017759964713298103839
class C_0017759964713298103839 #aliceblue;line:blue;line.dotted;text:blue {
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
..
@ -216,42 +190,74 @@ __
#discretizers : map<std::string,mdlp::CPPFImdlp *>
#y : torch::Tensor
}
class "bayesnet::KDBLd" as C_0002756018222998454702
class C_0002756018222998454702 #aliceblue;line:blue;line.dotted;text:blue {
+KDBLd(int k) : void
+~KDBLd() = default : void
..
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : KDBLd &
+graph(const std::string & name = "KDB") const : std::vector<std::string>
+predict(torch::Tensor & X) : torch::Tensor
{static} +version() : std::string
__
}
class "bayesnet::SPODELd" as C_0010957245114062042836
class C_0010957245114062042836 #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, const Smoothing_t smoothing) : SPODELd &
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : SPODELd &
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states, const Smoothing_t smoothing) : SPODELd &
+graph(const std::string & name = "SPODELd") const : std::vector<std::string>
+predict(torch::Tensor & X) : torch::Tensor
{static} +version() : std::string
__
}
class "bayesnet::TANLd" as C_0013350632773616302678
class C_0013350632773616302678 #aliceblue;line:blue;line.dotted;text:blue {
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, const Smoothing_t smoothing) : TANLd &
+graph(const std::string & name = "TANLd") const : std::vector<std::string>
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : TANLd &
+graph(const std::string & name = "TAN") const : std::vector<std::string>
+predict(torch::Tensor & X) : torch::Tensor
{static} +version() : std::string
__
}
class "bayesnet::Ensemble" as C_0015881931090842884611
class C_0015881931090842884611 #aliceblue;line:blue;line.dotted;text:blue {
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
..
@ -274,7 +280,7 @@ class C_0015881931090842884611 #aliceblue;line:blue;line.dotted;text:blue {
+score(torch::Tensor & X, torch::Tensor & y) : float
+show() const : std::vector<std::string>
+topological_order() : std::vector<std::string>
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
#trainModel(const torch::Tensor & weights) : void
#voting(torch::Tensor & votes) : torch::Tensor
__
#models : std::vector<std::unique_ptr<Classifier>>
@ -282,223 +288,41 @@ __
#predict_voting : bool
#significanceModels : std::vector<double>
}
class "bayesnet::A2DE" as C_0001410789567057647859
class C_0001410789567057647859 #aliceblue;line:blue;line.dotted;text:blue {
+A2DE(bool predict_voting = false) : void
+~A2DE() : void
..
#buildModel(const torch::Tensor & weights) : void
+graph(const std::string & title = "A2DE") const : std::vector<std::string>
+setHyperparameters(const nlohmann::json & hyperparameters) : void
__
}
class "bayesnet::AODE" as C_0006288892608974306258
class C_0006288892608974306258 #aliceblue;line:blue;line.dotted;text:blue {
+AODE(bool predict_voting = false) : void
+~AODE() : void
..
#buildModel(const torch::Tensor & weights) : void
+graph(const std::string & title = "AODE") const : std::vector<std::string>
+setHyperparameters(const nlohmann::json & hyperparameters) : void
__
}
abstract "bayesnet::FeatureSelect" as C_0013562609546004646591
abstract C_0013562609546004646591 #aliceblue;line:blue;line.dotted;text:blue {
+FeatureSelect(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights) : void
+~FeatureSelect() : void
..
#computeMeritCFS() : double
#computeSuFeatures(const int a, const int b) : double
#computeSuLabels() : void
{abstract} +fit() = 0 : void
+getFeatures() const : std::vector<int>
+getScores() const : std::vector<double>
#initialize() : void
#symmetricalUncertainty(int a, int b) : double
__
#fitted : bool
#maxFeatures : int
#selectedFeatures : std::vector<int>
#selectedScores : std::vector<double>
#suFeatures : std::map<std::pair<int,int>,double>
#suLabels : std::vector<double>
#weights : const torch::Tensor &
}
class "bayesnet::(anonymous_60342586)" as C_0005584545181746538542
class C_0005584545181746538542 #aliceblue;line:blue;line.dotted;text:blue {
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_60343240)" as C_0016227156982041949444
class C_0016227156982041949444 #aliceblue;line:blue;line.dotted;text:blue {
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::Boost" as C_0009819322948617116148
class C_0009819322948617116148 #aliceblue;line:blue;line.dotted;text:blue {
+Boost(bool predict_voting = false) : void
+~Boost() = default : void
..
#buildModel(const torch::Tensor & weights) : void
#featureSelection(torch::Tensor & weights_) : std::vector<int>
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
#update_weights(torch::Tensor & ytrain, torch::Tensor & ypred, torch::Tensor & weights) : std::tuple<torch::Tensor &,double,bool>
#update_weights_block(int k, torch::Tensor & ytrain, torch::Tensor & weights) : std::tuple<torch::Tensor &,double,bool>
__
#X_test : torch::Tensor
#X_train : torch::Tensor
#bisection : bool
#block_update : bool
#convergence : bool
#convergence_best : bool
#featureSelector : FeatureSelect *
#maxTolerance : int
#order_algorithm : std::string
#selectFeatures : bool
#select_features_algorithm : std::string
#threshold : double
#y_test : torch::Tensor
#y_train : torch::Tensor
}
class "bayesnet::AODELd" as C_0003898187834670349177
class C_0003898187834670349177 #aliceblue;line:blue;line.dotted;text:blue {
+AODELd(bool predict_voting = true) : void
+~AODELd() = default : void
..
#buildModel(const torch::Tensor & weights) : void
+fit(torch::Tensor & X_, torch::Tensor & y_, const std::vector<std::string> & features_, const std::string & className_, std::map<std::string,std::vector<int>> & states_, const Smoothing_t smoothing) : AODELd &
+graph(const std::string & name = "AODELd") const : std::vector<std::string>
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
__
}
class "bayesnet::(anonymous_60275628)" as C_0009086919615463763584
class C_0009086919615463763584 #aliceblue;line:blue;line.dotted;text:blue {
__
+CFS : std::string
+FCBF : std::string
+IWSS : std::string
}
class "bayesnet::(anonymous_60276282)" as C_0015251985607563196159
class C_0015251985607563196159 #aliceblue;line:blue;line.dotted;text:blue {
__
+ASC : std::string
+DESC : std::string
+RAND : std::string
}
class "bayesnet::BoostA2DE" as C_0000272055465257861326
class C_0000272055465257861326 #aliceblue;line:blue;line.dotted;text:blue {
+BoostA2DE(bool predict_voting = false) : void
+~BoostA2DE() = default : void
..
+graph(const std::string & title = "BoostA2DE") const : std::vector<std::string>
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
__
}
class "bayesnet::(anonymous_60275502)" as C_0016033655851510053155
class C_0016033655851510053155 #aliceblue;line:blue;line.dotted;text:blue {
__
+CFS : std::string
+FCBF : std::string
+IWSS : std::string
}
class "bayesnet::(anonymous_60276156)" as C_0000379522761622473555
class C_0000379522761622473555 #aliceblue;line:blue;line.dotted;text:blue {
__
+ASC : std::string
+DESC : std::string
+RAND : std::string
}
class "bayesnet::BoostAODE" as C_0002867772739198819061
class C_0002867772739198819061 #aliceblue;line:blue;line.dotted;text:blue {
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>
#trainModel(const torch::Tensor & weights, const Smoothing_t smoothing) : void
+setHyperparameters(const nlohmann::json & hyperparameters_) : void
#trainModel(const torch::Tensor & weights) : void
__
}
class "bayesnet::CFS" as C_0000093018845530739957
class C_0000093018845530739957 #aliceblue;line:blue;line.dotted;text:blue {
+CFS(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights) : void
+~CFS() : void
..
+fit() : void
__
}
class "bayesnet::FCBF" as C_0001157456122733975432
class C_0001157456122733975432 #aliceblue;line:blue;line.dotted;text:blue {
+FCBF(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights, const double threshold) : void
+~FCBF() : void
..
+fit() : void
__
}
class "bayesnet::IWSS" as C_0000066148117395428429
class C_0000066148117395428429 #aliceblue;line:blue;line.dotted;text:blue {
+IWSS(const torch::Tensor & samples, const std::vector<std::string> & features, const std::string & className, const int maxFeatures, const int classNumStates, const torch::Tensor & weights, const double threshold) : void
+~IWSS() : void
..
+fit() : void
__
}
class "bayesnet::(anonymous_60730495)" as C_0004857727320042830573
class C_0004857727320042830573 #aliceblue;line:blue;line.dotted;text:blue {
__
+CFS : std::string
+FCBF : std::string
+IWSS : std::string
}
class "bayesnet::(anonymous_60731150)" as C_0000076541533312623385
class C_0000076541533312623385 #aliceblue;line:blue;line.dotted;text:blue {
__
+ASC : std::string
+DESC : std::string
+RAND : std::string
}
class "bayesnet::(anonymous_60653004)" as C_0001444063444142949758
class C_0001444063444142949758 #aliceblue;line:blue;line.dotted;text:blue {
__
+CFS : std::string
+FCBF : std::string
+IWSS : std::string
}
class "bayesnet::(anonymous_60653658)" as C_0007139277546931322856
class C_0007139277546931322856 #aliceblue;line:blue;line.dotted;text:blue {
__
+ASC : std::string
+DESC : std::string
+RAND : std::string
}
class "bayesnet::(anonymous_60731375)" as C_0010493853592456211189
class C_0010493853592456211189 #aliceblue;line:blue;line.dotted;text:blue {
__
+CFS : std::string
+FCBF : std::string
+IWSS : std::string
}
class "bayesnet::(anonymous_60732030)" as C_0007011438637915849564
class C_0007011438637915849564 #aliceblue;line:blue;line.dotted;text:blue {
__
+ASC : std::string
+DESC : std::string
+RAND : std::string
}
class "bayesnet::MST" as C_0001054867409378333602
class C_0001054867409378333602 #aliceblue;line:blue;line.dotted;text:blue {
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
..
+insertElement(std::list<int> & variables, int variable) : void
+maximumSpanningTree() : std::vector<std::pair<int,int>>
+reorder(std::vector<std::pair<float,std::pair<int,int>>> T, int root_original) : std::vector<std::pair<int,int>>
__
}
class "bayesnet::Graph" as C_0009576333456015187741
class C_0009576333456015187741 #aliceblue;line:blue;line.dotted;text:blue {
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
@ -508,73 +332,81 @@ class C_0009576333456015187741 #aliceblue;line:blue;line.dotted;text:blue {
+union_set(int u, int v) : void
__
}
C_0010428199432536647474 --> C_0010428199432536647474 : -parents
C_0010428199432536647474 --> C_0010428199432536647474 : -children
C_0009493661199123436603 ..> C_0013393078277439680282
C_0009493661199123436603 o-- C_0010428199432536647474 : -nodes
C_0002617087915615796317 ..> C_0013393078277439680282
C_0002617087915615796317 ..> C_0005907365846270811004
C_0016351972983202413152 ..> C_0013393078277439680282
C_0016351972983202413152 o-- C_0009493661199123436603 : #model
C_0016351972983202413152 o-- C_0005895723015084986588 : #metrics
C_0016351972983202413152 o-- C_0005907365846270811004 : #status
C_0002617087915615796317 <|-- C_0016351972983202413152
class "bayesnet::KDBLd" as C_0000344502277874806837
class C_0000344502277874806837 #aliceblue;line:blue;line.dotted;text:blue {
+KDBLd(int k) : void
+~KDBLd() = default : void
..
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : KDBLd &
+graph(const std::string & name = "KDB") const : std::vector<std::string>
+predict(torch::Tensor & X) : torch::Tensor
{static} +version() : std::string
__
}
class "bayesnet::AODE" as C_0000786111576121788282
class C_0000786111576121788282 #aliceblue;line:blue;line.dotted;text:blue {
+AODE(bool predict_voting = false) : void
+~AODE() : void
..
#buildModel(const torch::Tensor & weights) : void
+graph(const std::string & title = "AODE") const : std::vector<std::string>
+setHyperparameters(const nlohmann::json & hyperparameters) : void
__
}
class "bayesnet::SPODELd" as C_0001369655639257755354
class C_0001369655639257755354 #aliceblue;line:blue;line.dotted;text:blue {
+SPODELd(int root) : void
+~SPODELd() = default : void
..
+commonFit(const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : SPODELd &
+fit(torch::Tensor & X, torch::Tensor & y, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : SPODELd &
+fit(torch::Tensor & dataset, const std::vector<std::string> & features, const std::string & className, std::map<std::string,std::vector<int>> & states) : SPODELd &
+graph(const std::string & name = "SPODE") const : std::vector<std::string>
+predict(torch::Tensor & X) : torch::Tensor
{static} +version() : std::string
__
}
class "bayesnet::AODELd" as C_0000487273479333793647
class C_0000487273479333793647 #aliceblue;line:blue;line.dotted;text:blue {
+AODELd(bool predict_voting = true) : void
+~AODELd() = default : void
..
#buildModel(const torch::Tensor & weights) : void
+fit(torch::Tensor & X_, torch::Tensor & y_, const std::vector<std::string> & features_, const std::string & className_, std::map<std::string,std::vector<int>> & states_) : AODELd &
+graph(const std::string & name = "AODELd") const : std::vector<std::string>
#trainModel(const torch::Tensor & weights) : void
__
}
C_0001303524929067080934 --> C_0001303524929067080934 : -parents
C_0001303524929067080934 --> C_0001303524929067080934 : -children
C_0001186707649890429575 o-- C_0001303524929067080934 : -nodes
C_0000327135989451974539 ..> C_0000738420730783851375
C_0002043996622900301644 o-- C_0001186707649890429575 : #model
C_0002043996622900301644 o-- C_0000736965376885623323 : #metrics
C_0002043996622900301644 o-- C_0000738420730783851375 : #status
C_0000327135989451974539 <|-- C_0002043996622900301644
C_0002043996622900301644 <|-- C_0001112865019015250005
C_0002043996622900301644 <|-- C_0001760994424884323017
C_0002219995589162262979 ..> C_0001186707649890429575
C_0001760994424884323017 <|-- C_0001668829096702037834
C_0002219995589162262979 <|-- C_0001668829096702037834
C_0000736965376885623323 <|-- C_0001695326193250580823
C_0001695326193250580823 <|-- C_0000011627355691342494
C_0001695326193250580823 <|-- C_0000144682015341746929
C_0001695326193250580823 <|-- C_0000008268514674428553
C_0002043996622900301644 <|-- C_0000512022813807538451
C_0001985241386355360576 o-- C_0002043996622900301644 : #models
C_0002043996622900301644 <|-- C_0001985241386355360576
C_0000358471592399852382 --> C_0001695326193250580823 : -featureSelector
C_0001985241386355360576 <|-- C_0000358471592399852382
C_0001112865019015250005 <|-- C_0000344502277874806837
C_0002219995589162262979 <|-- C_0000344502277874806837
C_0001985241386355360576 <|-- C_0000786111576121788282
C_0000512022813807538451 <|-- C_0001369655639257755354
C_0002219995589162262979 <|-- C_0001369655639257755354
C_0001985241386355360576 <|-- C_0000487273479333793647
C_0002219995589162262979 <|-- C_0000487273479333793647
C_0016351972983202413152 <|-- C_0008902920152122000044
C_0016351972983202413152 <|-- C_0004096182510460307610
C_0016351972983202413152 <|-- C_0016268916386101512883
C_0016351972983202413152 <|-- C_0014087955399074584137
C_0017759964713298103839 ..> C_0009493661199123436603
C_0002756018222998454702 ..> C_0013393078277439680282
C_0008902920152122000044 <|-- C_0002756018222998454702
C_0017759964713298103839 <|-- C_0002756018222998454702
C_0010957245114062042836 ..> C_0013393078277439680282
C_0004096182510460307610 <|-- C_0010957245114062042836
C_0017759964713298103839 <|-- C_0010957245114062042836
C_0013350632773616302678 ..> C_0013393078277439680282
C_0014087955399074584137 <|-- C_0013350632773616302678
C_0017759964713298103839 <|-- C_0013350632773616302678
C_0015881931090842884611 ..> C_0013393078277439680282
C_0015881931090842884611 o-- C_0016351972983202413152 : #models
C_0016351972983202413152 <|-- C_0015881931090842884611
C_0015881931090842884611 <|-- C_0001410789567057647859
C_0015881931090842884611 <|-- C_0006288892608974306258
C_0005895723015084986588 <|-- C_0013562609546004646591
C_0009819322948617116148 --> C_0013562609546004646591 : #featureSelector
C_0015881931090842884611 <|-- C_0009819322948617116148
C_0003898187834670349177 ..> C_0013393078277439680282
C_0015881931090842884611 <|-- C_0003898187834670349177
C_0017759964713298103839 <|-- C_0003898187834670349177
C_0000272055465257861326 ..> C_0013393078277439680282
C_0009819322948617116148 <|-- C_0000272055465257861326
C_0002867772739198819061 ..> C_0013393078277439680282
C_0009819322948617116148 <|-- C_0002867772739198819061
C_0013562609546004646591 <|-- C_0000093018845530739957
C_0013562609546004646591 <|-- C_0001157456122733975432
C_0013562609546004646591 <|-- C_0000066148117395428429
'Generated with clang-uml, version 0.5.5
'LLVM version clang version 18.1.8 (Fedora 18.1.8-5.fc41)
'Generated with clang-uml, version 0.5.1
'LLVM version clang version 17.0.6 (Fedora 17.0.6-2.fc39)
@enduml

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -1,314 +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 12.1.0 (20240811.2233)
<!-- Generated by graphviz version 8.1.0 (20230707.0739)
-->
<!-- Title: BayesNet Pages: 1 -->
<svg width="3725pt" height="432pt"
viewBox="0.00 0.00 3724.84 431.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 427.8)">
<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,-427.8 3720.84,-427.8 3720.84,4 -4,4"/>
<!-- node0 -->
<g id="node1" class="node">
<title>node0</title>
<polygon fill="none" stroke="black" points="1655.43,-398.35 1655.43,-413.26 1625.69,-423.8 1583.63,-423.8 1553.89,-413.26 1553.89,-398.35 1583.63,-387.8 1625.69,-387.8 1655.43,-398.35"/>
<text text-anchor="middle" x="1604.66" y="-401.53" font-family="Times,serif" font-size="12.00">BayesNet</text>
</g>
<polygon fill="white" stroke="none" points="-4,4 -4,-283.8 1627.95,-283.8 1627.95,4 -4,4"/>
<!-- node1 -->
<g id="node2" class="node">
<g id="node1" class="node">
<title>node1</title>
<polygon fill="none" stroke="black" points="413.32,-257.8 372.39,-273.03 206.66,-279.8 40.93,-273.03 0,-257.8 114.69,-245.59 298.64,-245.59 413.32,-257.8"/>
<text text-anchor="middle" x="206.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libc10.so</text>
</g>
<!-- node0&#45;&gt;node1 -->
<g id="edge1" class="edge">
<title>node0&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M1553.59,-400.53C1451.65,-391.91 1215.69,-371.61 1017.66,-351.8 773.36,-327.37 488.07,-295.22 329.31,-277.01"/>
<polygon fill="black" stroke="black" points="329.93,-273.56 319.6,-275.89 329.14,-280.51 329.93,-273.56"/>
<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="node3" class="node">
<g id="node2" class="node">
<title>node2</title>
<polygon fill="none" stroke="black" points="894.21,-257.8 848.35,-273.03 662.66,-279.8 476.98,-273.03 431.12,-257.8 559.61,-245.59 765.71,-245.59 894.21,-257.8"/>
<text text-anchor="middle" x="662.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libc10_cuda.so</text>
<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>
<!-- node0&#45;&gt;node2 -->
<g id="edge2" class="edge">
<title>node0&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M1555.34,-397.37C1408.12,-375.18 969.52,-309.06 767.13,-278.55"/>
<polygon fill="black" stroke="black" points="767.81,-275.12 757.4,-277.09 766.77,-282.04 767.81,-275.12"/>
<!-- node1&#45;&gt;node2 -->
<g id="edge1" class="edge">
<title>node1&#45;&gt;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="node4" class="node">
<g id="node3" class="node">
<title>node3</title>
<polygon fill="none" stroke="black" points="1338.68,-257.8 1296.49,-273.03 1125.66,-279.8 954.84,-273.03 912.65,-257.8 1030.86,-245.59 1220.46,-245.59 1338.68,-257.8"/>
<text text-anchor="middle" x="1125.66" y="-257.53" font-family="Times,serif" font-size="12.00">/home/rmontanana/Code/libtorch/lib/libkineto.a</text>
<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>
<!-- node0&#45;&gt;node3 -->
<g id="edge3" class="edge">
<title>node0&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M1566.68,-393.54C1484.46,-369.17 1289.3,-311.32 1188.44,-281.41"/>
<polygon fill="black" stroke="black" points="1189.53,-278.09 1178.95,-278.6 1187.54,-284.8 1189.53,-278.09"/>
<!-- node1&#45;&gt;node3 -->
<g id="edge2" class="edge">
<title>node1&#45;&gt;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="node5" class="node">
<g id="node4" class="node">
<title>node4</title>
<polygon fill="none" stroke="black" points="1552.26,-257.8 1532.93,-273.03 1454.66,-279.8 1376.4,-273.03 1357.07,-257.8 1411.23,-245.59 1498.1,-245.59 1552.26,-257.8"/>
<text text-anchor="middle" x="1454.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/lib64/libcuda.so</text>
<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>
<!-- node0&#45;&gt;node4 -->
<g id="edge4" class="edge">
<title>node0&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M1586.27,-387.39C1559.5,-362.05 1509.72,-314.92 1479.65,-286.46"/>
<polygon fill="black" stroke="black" points="1482.13,-283.99 1472.46,-279.65 1477.31,-289.07 1482.13,-283.99"/>
</g>
<!-- node5 -->
<g id="node6" class="node">
<title>node5</title>
<polygon fill="none" stroke="black" points="1873.26,-257.8 1843.23,-273.03 1721.66,-279.8 1600.09,-273.03 1570.06,-257.8 1654.19,-245.59 1789.13,-245.59 1873.26,-257.8"/>
<text text-anchor="middle" x="1721.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libcudart.so</text>
</g>
<!-- node0&#45;&gt;node5 -->
<g id="edge5" class="edge">
<title>node0&#45;&gt;node5</title>
<path fill="none" stroke="black" d="M1619.76,-387.77C1628.83,-377.46 1640.53,-363.98 1650.66,-351.8 1668.32,-330.59 1687.84,-306.03 1701.94,-288.1"/>
<polygon fill="black" stroke="black" points="1704.43,-290.59 1707.84,-280.56 1698.92,-286.27 1704.43,-290.59"/>
</g>
<!-- node6 -->
<g id="node7" class="node">
<title>node6</title>
<polygon fill="none" stroke="black" points="2231.79,-257.8 2198.1,-273.03 2061.66,-279.8 1925.23,-273.03 1891.53,-257.8 1985.95,-245.59 2137.38,-245.59 2231.79,-257.8"/>
<text text-anchor="middle" x="2061.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libnvToolsExt.so</text>
</g>
<!-- node0&#45;&gt;node6 -->
<g id="edge6" class="edge">
<title>node0&#45;&gt;node6</title>
<path fill="none" stroke="black" d="M1642.06,-393.18C1721.31,-368.56 1906.71,-310.95 2002.32,-281.24"/>
<polygon fill="black" stroke="black" points="2003.28,-284.61 2011.79,-278.3 2001.21,-277.92 2003.28,-284.61"/>
</g>
<!-- node7 -->
<g id="node8" class="node">
<title>node7</title>
<polygon fill="none" stroke="black" points="2541.44,-257.8 2512.56,-273.03 2395.66,-279.8 2278.76,-273.03 2249.89,-257.8 2330.79,-245.59 2460.54,-245.59 2541.44,-257.8"/>
<text text-anchor="middle" x="2395.66" y="-257.53" font-family="Times,serif" font-size="12.00">/usr/local/cuda/lib64/libnvrtc.so</text>
</g>
<!-- node0&#45;&gt;node7 -->
<g id="edge7" class="edge">
<title>node0&#45;&gt;node7</title>
<path fill="none" stroke="black" d="M1651.19,-396.45C1780.36,-373.26 2144.76,-307.85 2311.05,-277.99"/>
<polygon fill="black" stroke="black" points="2311.47,-281.47 2320.7,-276.26 2310.24,-274.58 2311.47,-281.47"/>
</g>
<!-- node8 -->
<g id="node9" class="node">
<title>node8</title>
<polygon fill="none" stroke="black" points="1642.01,-326.35 1642.01,-341.26 1620.13,-351.8 1589.19,-351.8 1567.31,-341.26 1567.31,-326.35 1589.19,-315.8 1620.13,-315.8 1642.01,-326.35"/>
<text text-anchor="middle" x="1604.66" y="-329.53" font-family="Times,serif" font-size="12.00">fimdlp</text>
</g>
<!-- node0&#45;&gt;node8 -->
<g id="edge8" class="edge">
<title>node0&#45;&gt;node8</title>
<path fill="none" stroke="black" d="M1604.66,-387.5C1604.66,-380.21 1604.66,-371.53 1604.66,-363.34"/>
<polygon fill="black" stroke="black" points="1608.16,-363.42 1604.66,-353.42 1601.16,-363.42 1608.16,-363.42"/>
</g>
<!-- node19 -->
<g id="node10" class="node">
<title>node19</title>
<polygon fill="none" stroke="black" points="2709.74,-267.37 2634.66,-279.8 2559.58,-267.37 2588.26,-247.24 2681.06,-247.24 2709.74,-267.37"/>
<text text-anchor="middle" x="2634.66" y="-257.53" font-family="Times,serif" font-size="12.00">torch_library</text>
</g>
<!-- node0&#45;&gt;node19 -->
<g id="edge29" class="edge">
<title>node0&#45;&gt;node19</title>
<path fill="none" stroke="black" d="M1655.87,-399.32C1798.23,-383.79 2210.64,-336.94 2550.66,-279.8 2559.43,-278.33 2568.68,-276.62 2577.72,-274.86"/>
<polygon fill="black" stroke="black" points="2578.38,-278.3 2587.5,-272.92 2577.01,-271.43 2578.38,-278.3"/>
</g>
<!-- node8&#45;&gt;node1 -->
<g id="edge9" class="edge">
<title>node8&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M1566.84,-331.58C1419.81,-326.72 872.06,-307.69 421.66,-279.8 401.07,-278.53 379.38,-277.02 358.03,-275.43"/>
<polygon fill="black" stroke="black" points="358.3,-271.94 348.06,-274.67 357.77,-278.92 358.3,-271.94"/>
</g>
<!-- node8&#45;&gt;node2 -->
<g id="edge10" class="edge">
<title>node8&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M1566.86,-330C1445.11,-320.95 1057.97,-292.18 831.67,-275.36"/>
<polygon fill="black" stroke="black" points="832.09,-271.89 821.86,-274.63 831.57,-278.87 832.09,-271.89"/>
</g>
<!-- node8&#45;&gt;node3 -->
<g id="edge11" class="edge">
<title>node8&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M1567.08,-327.31C1495.4,-316.84 1336.86,-293.67 1230.62,-278.14"/>
<polygon fill="black" stroke="black" points="1231.44,-274.72 1221.04,-276.74 1230.42,-281.65 1231.44,-274.72"/>
</g>
<!-- node8&#45;&gt;node4 -->
<g id="edge12" class="edge">
<title>node8&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M1578.53,-320.61C1555.96,-310.08 1522.92,-294.66 1496.64,-282.4"/>
<polygon fill="black" stroke="black" points="1498.12,-279.22 1487.58,-278.17 1495.16,-285.57 1498.12,-279.22"/>
</g>
<!-- node8&#45;&gt;node5 -->
<g id="edge13" class="edge">
<title>node8&#45;&gt;node5</title>
<path fill="none" stroke="black" d="M1627.78,-318.97C1644.15,-309.18 1666.44,-295.84 1685.2,-284.62"/>
<polygon fill="black" stroke="black" points="1686.83,-287.73 1693.61,-279.59 1683.23,-281.72 1686.83,-287.73"/>
</g>
<!-- node8&#45;&gt;node6 -->
<g id="edge14" class="edge">
<title>node8&#45;&gt;node6</title>
<path fill="none" stroke="black" d="M1642.45,-327.02C1712.36,-316.31 1863.89,-293.1 1964.32,-277.71"/>
<polygon fill="black" stroke="black" points="1964.84,-281.18 1974.2,-276.2 1963.78,-274.26 1964.84,-281.18"/>
</g>
<!-- node8&#45;&gt;node7 -->
<g id="edge15" class="edge">
<title>node8&#45;&gt;node7</title>
<path fill="none" stroke="black" d="M1642.33,-330.01C1740.75,-322.64 2013.75,-301.7 2240.66,-279.8 2254.16,-278.5 2268.32,-277.06 2282.35,-275.58"/>
<polygon fill="black" stroke="black" points="2282.49,-279.08 2292.06,-274.54 2281.75,-272.12 2282.49,-279.08"/>
</g>
<!-- node8&#45;&gt;node19 -->
<g id="edge16" class="edge">
<title>node8&#45;&gt;node19</title>
<path fill="none" stroke="black" d="M1642.25,-332.63C1770.06,-331.64 2199.48,-324.94 2550.66,-279.8 2560.1,-278.59 2570.07,-276.92 2579.71,-275.1"/>
<polygon fill="black" stroke="black" points="2580.21,-278.57 2589.34,-273.21 2578.86,-271.7 2580.21,-278.57"/>
</g>
<!-- node20 -->
<g id="node11" class="node">
<title>node20</title>
<polygon fill="none" stroke="black" points="2606.81,-185.8 2533.89,-201.03 2238.66,-207.8 1943.43,-201.03 1870.52,-185.8 2074.82,-173.59 2402.5,-173.59 2606.81,-185.8"/>
<text text-anchor="middle" x="2238.66" y="-185.53" font-family="Times,serif" font-size="12.00">&#45;Wl,&#45;&#45;no&#45;as&#45;needed,&quot;/home/rmontanana/Code/libtorch/lib/libtorch.so&quot; &#45;Wl,&#45;&#45;as&#45;needed</text>
</g>
<!-- node19&#45;&gt;node20 -->
<g id="edge17" class="edge">
<title>node19&#45;&gt;node20</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2583.63,-250.21C2572.76,-248.03 2561.34,-245.79 2550.66,-243.8 2482.14,-231.05 2404.92,-217.93 2344.44,-207.93"/>
<polygon fill="black" stroke="black" points="2345.28,-204.52 2334.84,-206.34 2344.14,-211.42 2345.28,-204.52"/>
<!-- node1&#45;&gt;node4 -->
<g id="edge3" class="edge">
<title>node1&#45;&gt;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="node12" class="node">
<g id="node5" class="node">
<title>node9</title>
<polygon fill="none" stroke="black" points="2542.56,-123.37 2445.66,-135.8 2348.77,-123.37 2385.78,-103.24 2505.55,-103.24 2542.56,-123.37"/>
<text text-anchor="middle" x="2445.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch_cpu_library</text>
<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>
<!-- node19&#45;&gt;node9 -->
<g id="edge18" class="edge">
<title>node19&#45;&gt;node9</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2635.72,-246.84C2636.4,-227.49 2634.61,-192.58 2615.66,-171.8 2601.13,-155.87 2551.93,-141.56 2510.18,-131.84"/>
<polygon fill="black" stroke="black" points="2511.2,-128.48 2500.67,-129.68 2509.65,-135.31 2511.2,-128.48"/>
</g>
<!-- node13 -->
<g id="node16" class="node">
<title>node13</title>
<polygon fill="none" stroke="black" points="3056.45,-195.37 2953.66,-207.8 2850.87,-195.37 2890.13,-175.24 3017.19,-175.24 3056.45,-195.37"/>
<text text-anchor="middle" x="2953.66" y="-185.53" font-family="Times,serif" font-size="12.00">torch_cuda_library</text>
</g>
<!-- node19&#45;&gt;node13 -->
<g id="edge22" class="edge">
<title>node19&#45;&gt;node13</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2685.21,-249.71C2741.11,-237.45 2831.21,-217.67 2891.42,-204.46"/>
<polygon fill="black" stroke="black" points="2891.8,-207.96 2900.82,-202.4 2890.3,-201.13 2891.8,-207.96"/>
<!-- node1&#45;&gt;node9 -->
<g id="edge4" class="edge">
<title>node1&#45;&gt;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="node13" class="node">
<g id="node6" class="node">
<title>node10</title>
<polygon fill="none" stroke="black" points="2362.4,-27.9 2285.6,-43.12 1974.66,-49.9 1663.72,-43.12 1586.93,-27.9 1802.1,-15.68 2147.22,-15.68 2362.4,-27.9"/>
<text text-anchor="middle" x="1974.66" y="-27.63" font-family="Times,serif" font-size="12.00">&#45;Wl,&#45;&#45;no&#45;as&#45;needed,&quot;/home/rmontanana/Code/libtorch/lib/libtorch_cpu.so&quot; &#45;Wl,&#45;&#45;as&#45;needed</text>
<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">&#45;Wl,&#45;&#45;no&#45;as&#45;needed,&quot;/home/rmontanana/Code/libtorch/lib/libtorch.so&quot; &#45;Wl,&#45;&#45;as&#45;needed</text>
</g>
<!-- node9&#45;&gt;node10 -->
<g id="edge19" class="edge">
<g id="edge5" class="edge">
<title>node9&#45;&gt;node10</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2381.16,-105.31C2301.63,-91.15 2165.65,-66.92 2073.05,-50.43"/>
<polygon fill="black" stroke="black" points="2073.93,-47.03 2063.48,-48.72 2072.71,-53.92 2073.93,-47.03"/>
<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>
<!-- node11 -->
<g id="node14" class="node">
<title>node11</title>
<polygon fill="none" stroke="black" points="2510.72,-37.46 2445.66,-49.9 2380.61,-37.46 2405.46,-17.34 2485.87,-17.34 2510.72,-37.46"/>
<text text-anchor="middle" x="2445.66" y="-27.63" font-family="Times,serif" font-size="12.00">caffe2::mkl</text>
<!-- 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&#45;&gt;node11 -->
<g id="edge20" class="edge">
<title>node9&#45;&gt;node11</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2445.66,-102.95C2445.66,-91.68 2445.66,-75.4 2445.66,-61.37"/>
<polygon fill="black" stroke="black" points="2449.16,-61.78 2445.66,-51.78 2442.16,-61.78 2449.16,-61.78"/>
<!-- node9&#45;&gt;node5 -->
<g id="edge6" class="edge">
<title>node9&#45;&gt;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>
<!-- node12 -->
<g id="node15" class="node">
<title>node12</title>
<polygon fill="none" stroke="black" points="2794.95,-41.76 2661.66,-63.8 2528.37,-41.76 2579.28,-6.09 2744.04,-6.09 2794.95,-41.76"/>
<text text-anchor="middle" x="2661.66" y="-34.75" font-family="Times,serif" font-size="12.00">dummy</text>
<text text-anchor="middle" x="2661.66" y="-20.5" font-family="Times,serif" font-size="12.00">(protobuf::libprotobuf)</text>
<!-- 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">&#45;Wl,&#45;&#45;no&#45;as&#45;needed,&quot;/home/rmontanana/Code/libtorch/lib/libtorch_cpu.so&quot; &#45;Wl,&#45;&#45;as&#45;needed</text>
</g>
<!-- node9&#45;&gt;node12 -->
<g id="edge21" class="edge">
<title>node9&#45;&gt;node12</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2481.82,-102.76C2512.55,-90.82 2557.5,-73.36 2594.77,-58.89"/>
<polygon fill="black" stroke="black" points="2595.6,-62.32 2603.65,-55.44 2593.06,-55.79 2595.6,-62.32"/>
<!-- node5&#45;&gt;node6 -->
<g id="edge7" class="edge">
<title>node5&#45;&gt;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>
<!-- node13&#45;&gt;node9 -->
<g id="edge28" class="edge">
<title>node13&#45;&gt;node9</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2880.59,-179.79C2799.97,-169.71 2666.42,-152.57 2551.66,-135.8 2540.2,-134.13 2528.06,-132.27 2516.24,-130.41"/>
<polygon fill="black" stroke="black" points="2516.96,-126.98 2506.54,-128.86 2515.87,-133.89 2516.96,-126.98"/>
<!-- 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>
<!-- node14 -->
<g id="node17" class="node">
<title>node14</title>
<polygon fill="none" stroke="black" points="3346.69,-113.8 3268.85,-129.03 2953.66,-135.8 2638.48,-129.03 2560.63,-113.8 2778.75,-101.59 3128.58,-101.59 3346.69,-113.8"/>
<text text-anchor="middle" x="2953.66" y="-113.53" font-family="Times,serif" font-size="12.00">&#45;Wl,&#45;&#45;no&#45;as&#45;needed,&quot;/home/rmontanana/Code/libtorch/lib/libtorch_cuda.so&quot; &#45;Wl,&#45;&#45;as&#45;needed</text>
<!-- node5&#45;&gt;node7 -->
<g id="edge8" class="edge">
<title>node5&#45;&gt;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>
<!-- node13&#45;&gt;node14 -->
<g id="edge23" class="edge">
<title>node13&#45;&gt;node14</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M2953.66,-174.97C2953.66,-167.13 2953.66,-157.01 2953.66,-147.53"/>
<polygon fill="black" stroke="black" points="2957.16,-147.59 2953.66,-137.59 2950.16,-147.59 2957.16,-147.59"/>
<!-- 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>
<!-- node15 -->
<g id="node18" class="node">
<title>node15</title>
<polygon fill="none" stroke="black" points="3514.74,-123.37 3439.66,-135.8 3364.58,-123.37 3393.26,-103.24 3486.06,-103.24 3514.74,-123.37"/>
<text text-anchor="middle" x="3439.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch::cudart</text>
</g>
<!-- node13&#45;&gt;node15 -->
<g id="edge24" class="edge">
<title>node13&#45;&gt;node15</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3028.35,-180.51C3109.24,-171.17 3241.96,-154.78 3355.66,-135.8 3364.43,-134.34 3373.69,-132.63 3382.72,-130.88"/>
<polygon fill="black" stroke="black" points="3383.38,-134.31 3392.51,-128.93 3382.02,-127.45 3383.38,-134.31"/>
</g>
<!-- node17 -->
<g id="node20" class="node">
<title>node17</title>
<polygon fill="none" stroke="black" points="3716.84,-123.37 3624.66,-135.8 3532.48,-123.37 3567.69,-103.24 3681.63,-103.24 3716.84,-123.37"/>
<text text-anchor="middle" x="3624.66" y="-113.53" font-family="Times,serif" font-size="12.00">torch::nvtoolsext</text>
</g>
<!-- node13&#45;&gt;node17 -->
<g id="edge26" class="edge">
<title>node13&#45;&gt;node17</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3033.64,-183.25C3144.1,-175.14 3349.47,-158.53 3523.66,-135.8 3534.84,-134.35 3546.67,-132.57 3558.15,-130.72"/>
<polygon fill="black" stroke="black" points="3558.68,-134.18 3567.98,-129.1 3557.54,-127.27 3558.68,-134.18"/>
</g>
<!-- node16 -->
<g id="node19" class="node">
<title>node16</title>
<polygon fill="none" stroke="black" points="3510.78,-27.9 3496.7,-43.12 3439.66,-49.9 3382.63,-43.12 3368.54,-27.9 3408.01,-15.68 3471.31,-15.68 3510.78,-27.9"/>
<text text-anchor="middle" x="3439.66" y="-27.63" font-family="Times,serif" font-size="12.00">CUDA::cudart</text>
</g>
<!-- node15&#45;&gt;node16 -->
<g id="edge25" class="edge">
<title>node15&#45;&gt;node16</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3439.66,-102.95C3439.66,-91.68 3439.66,-75.4 3439.66,-61.37"/>
<polygon fill="black" stroke="black" points="3443.16,-61.78 3439.66,-51.78 3436.16,-61.78 3443.16,-61.78"/>
</g>
<!-- node18 -->
<g id="node21" class="node">
<title>node18</title>
<polygon fill="none" stroke="black" points="3714.32,-27.9 3696.56,-43.12 3624.66,-49.9 3552.77,-43.12 3535.01,-27.9 3584.76,-15.68 3664.56,-15.68 3714.32,-27.9"/>
<text text-anchor="middle" x="3624.66" y="-27.63" font-family="Times,serif" font-size="12.00">CUDA::nvToolsExt</text>
</g>
<!-- node17&#45;&gt;node18 -->
<g id="edge27" class="edge">
<title>node17&#45;&gt;node18</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M3624.66,-102.95C3624.66,-91.68 3624.66,-75.4 3624.66,-61.37"/>
<polygon fill="black" stroke="black" points="3628.16,-61.78 3624.66,-51.78 3621.16,-61.78 3628.16,-61.78"/>
<!-- node5&#45;&gt;node8 -->
<g id="edge9" class="edge">
<title>node5&#45;&gt;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>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -27,4 +27,4 @@ The hyperparameters defined in the algorithm are:
## Operation
### [Base Algorithm](./algorithm.md)
### [Algorithm](./algorithm.md)

File diff suppressed because it is too large Load Diff

BIN
docs/coverage.pdf Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

BIN
html/amber.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

View 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&nbsp;%</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&nbsp;%</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>

View 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&nbsp;%</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&nbsp;%</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>

View 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>

View 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&nbsp;%</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&nbsp;%</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 &lt;vector&gt;</span>
<span id="L9"><span class="lineNum"> 9</span> : #include &lt;torch/torch.h&gt;</span>
<span id="L10"><span class="lineNum"> 10</span> : #include &lt;nlohmann/json.hpp&gt;</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&amp; fit(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; 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&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) = 0;</span>
<span id="L19"><span class="lineNum"> 19</span> : virtual BaseClassifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) = 0;</span>
<span id="L20"><span class="lineNum"> 20</span> : virtual BaseClassifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; 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&amp; X) = 0;</span>
<span id="L23"><span class="lineNum"> 23</span> : std::vector&lt;int&gt; virtual predict(std::vector&lt;std::vector&lt;int &gt;&gt;&amp; X) = 0;</span>
<span id="L24"><span class="lineNum"> 24</span> : torch::Tensor virtual predict_proba(torch::Tensor&amp; X) = 0;</span>
<span id="L25"><span class="lineNum"> 25</span> : std::vector&lt;std::vector&lt;double&gt;&gt; virtual predict_proba(std::vector&lt;std::vector&lt;int &gt;&gt;&amp; 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&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y) = 0;</span>
<span id="L28"><span class="lineNum"> 28</span> : float virtual score(torch::Tensor&amp; X, torch::Tensor&amp; 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&lt;std::string&gt; virtual show() const = 0;</span>
<span id="L34"><span class="lineNum"> 34</span> : std::vector&lt;std::string&gt; virtual graph(const std::string&amp; title = &quot;&quot;) 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&lt;std::string&gt; virtual topological_order() = 0;</span>
<span id="L37"><span class="lineNum"> 37</span> : std::vector&lt;std::string&gt; 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&amp; hyperparameters) = 0;</span>
<span id="L40"><span class="lineNum"> 40</span> : std::vector&lt;std::string&gt;&amp; 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&amp; weights) = 0;</span>
<span id="L43"><span class="lineNum"> 43</span> : std::vector&lt;std::string&gt; 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>

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

View 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&nbsp;%</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&nbsp;%</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&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">16</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)</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&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">92</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">112</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">128</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</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&amp;)</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&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">548</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">660</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</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&amp;)</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&amp;)</a></td>
<td class="coverFnHi">1576</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</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&amp;)</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>

View 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&nbsp;%</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&nbsp;%</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&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1760</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&amp;)</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&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">128</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">852</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">660</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</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&amp;)</a></td>
<td class="coverFnHi">1844</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</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&amp;)</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&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">548</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">112</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)</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&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</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&amp;)</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>

View 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>

View 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&nbsp;%</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&nbsp;%</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 &lt;sstream&gt;</span>
<span id="L8"><span class="lineNum"> 8</span> : #include &quot;bayesnet/utils/bayesnetUtils.h&quot;</span>
<span id="L9"><span class="lineNum"> 9</span> : #include &quot;Classifier.h&quot;</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 = &quot;Classifier has not been fitted&quot;;</span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 1760 : Classifier&amp; Classifier::build(const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; 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-&gt;features = features;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 1760 : this-&gt;className = className;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 1760 : this-&gt;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&amp; 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&amp; 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 &lt;&lt; &quot;* Error in X and y dimensions *\n&quot;;</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 16 : oss &lt;&lt; &quot;X dimensions: &quot; &lt;&lt; dataset.sizes() &lt;&lt; &quot;\n&quot;;</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 16 : oss &lt;&lt; &quot;y dimensions: &quot; &lt;&lt; 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&amp; 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&amp; Classifier::fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; 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&amp; Classifier::fit(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; 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&lt;int&gt;(X.size()), static_cast&lt;int&gt;(X[0].size()) }, torch::kInt32);</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 976 : for (int i = 0; i &lt; X.size(); ++i) {</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 3360 : dataset.index_put_({ i, &quot;...&quot; }, 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&amp; Classifier::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; 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-&gt;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&amp; Classifier::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; 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-&gt;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(&quot;dataset (X, y) must be of type Integer&quot;);</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(&quot;Classifier: X &quot; + std::to_string(dataset.size(0) - 1) + &quot; and features &quot; + std::to_string(features.size()) + &quot; must have the same number of features&quot;);</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(&quot;class name not found in states&quot;);</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(&quot;feature [&quot; + feature + &quot;] not found in states&quot;);</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&amp; 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&lt;int&gt; Classifier::predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; 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&lt;std::vector&lt;int&gt;&gt; Xd(n_, std::vector&lt;int&gt;(m_, 0));</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 40 : for (auto i = 0; i &lt; n_; i++) {</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 64 : Xd[i] = std::vector&lt;int&gt;(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&amp; 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&lt;std::vector&lt;double&gt;&gt; Classifier::predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; 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&lt;std::vector&lt;int&gt;&gt; Xd(n_, std::vector&lt;int&gt;(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 &lt; n_; i++) {</span></span>
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 9000 : Xd[i] = std::vector&lt;int&gt;(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&amp; X, torch::Tensor&amp; 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&lt;float&gt;() / 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&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; 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&lt;std::string&gt; 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&amp; 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&lt;std::string&gt; 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&amp; 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(&quot;Invalid hyperparameters&quot; + 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>

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

View 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&nbsp;%</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&nbsp;%</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>

View 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&nbsp;%</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&nbsp;%</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>

View 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>

View 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&nbsp;%</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&nbsp;%</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 &lt;torch/torch.h&gt;</span>
<span id="L10"><span class="lineNum"> 10</span> : #include &quot;bayesnet/utils/BayesMetrics.h&quot;</span>
<span id="L11"><span class="lineNum"> 11</span> : #include &quot;bayesnet/network/Network.h&quot;</span>
<span id="L12"><span class="lineNum"> 12</span> : #include &quot;bayesnet/BaseClassifier.h&quot;</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&amp; fit(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L20"><span class="lineNum"> 20</span> : Classifier&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L21"><span class="lineNum"> 21</span> : Classifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L22"><span class="lineNum"> 22</span> : Classifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; 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&amp; X) override;</span>
<span id="L29"><span class="lineNum"> 29</span> : std::vector&lt;int&gt; predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X) override;</span>
<span id="L30"><span class="lineNum"> 30</span> : torch::Tensor predict_proba(torch::Tensor&amp; X) override;</span>
<span id="L31"><span class="lineNum"> 31</span> : std::vector&lt;std::vector&lt;double&gt;&gt; predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; 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&amp; X, torch::Tensor&amp; y) override;</span>
<span id="L35"><span class="lineNum"> 35</span> : float score(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y) override;</span>
<span id="L36"><span class="lineNum"> 36</span> : std::vector&lt;std::string&gt; show() const override;</span>
<span id="L37"><span class="lineNum"> 37</span> : std::vector&lt;std::string&gt; topological_order() override;</span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 80 : std::vector&lt;std::string&gt; 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&amp; 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&lt;std::string&gt; features;</span>
<span id="L47"><span class="lineNum"> 47</span> : std::string className;</span>
<span id="L48"><span class="lineNum"> 48</span> : std::map&lt;std::string, std::vector&lt;int&gt;&gt; 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&lt;std::string&gt; 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&amp; weights) = 0;</span>
<span id="L54"><span class="lineNum"> 54</span> : void trainModel(const torch::Tensor&amp; weights) override;</span>
<span id="L55"><span class="lineNum"> 55</span> : void buildDataset(torch::Tensor&amp; y);</span>
<span id="L56"><span class="lineNum"> 56</span> : private:</span>
<span id="L57"><span class="lineNum"> 57</span> : Classifier&amp; build(const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; 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>

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

View 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&nbsp;%</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&nbsp;%</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&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) 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&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</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&amp;)</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&lt;int, std::allocator&lt;int&gt; &gt;&amp;, at::Tensor&amp;)</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>

View 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&nbsp;%</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&nbsp;%</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&lt;int, std::allocator&lt;int&gt; &gt;&amp;, at::Tensor&amp;)</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&amp;)</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&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) 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&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</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>

View 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>

View File

@ -0,0 +1,195 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.cc<span style="font-size: 80%;"> (source / <a href="KDB.cc.func-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">96.3&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">5</td>
<td class="headerCovTableEntry">5</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Line data Source code</pre>
<pre class="source">
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
<span id="L6"><span class="lineNum"> 6</span> : </span>
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;KDB.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 148 : KDB::KDB(int k, float theta) : Classifier(Network()), k(k), theta(theta)</span></span>
<span id="L11"><span class="lineNum"> 11</span> : {</span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 444 : validHyperparameters = { &quot;k&quot;, &quot;theta&quot; };</span></span>
<span id="L13"><span class="lineNum"> 13</span> : </span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 444 : }</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 12 : void KDB::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L16"><span class="lineNum"> 16</span> : {</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 12 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 12 : if (hyperparameters.contains(&quot;k&quot;)) {</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 4 : k = hyperparameters[&quot;k&quot;];</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 4 : hyperparameters.erase(&quot;k&quot;);</span></span>
<span id="L21"><span class="lineNum"> 21</span> : }</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 12 : if (hyperparameters.contains(&quot;theta&quot;)) {</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 4 : theta = hyperparameters[&quot;theta&quot;];</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 4 : hyperparameters.erase(&quot;theta&quot;);</span></span>
<span id="L25"><span class="lineNum"> 25</span> : }</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 12 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 12 : }</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 52 : void KDB::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L29"><span class="lineNum"> 29</span> : {</span>
<span id="L30"><span class="lineNum"> 30</span> : /*</span>
<span id="L31"><span class="lineNum"> 31</span> : 1. For each feature Xi, compute mutual information, I(X;C),</span>
<span id="L32"><span class="lineNum"> 32</span> : where C is the class.</span>
<span id="L33"><span class="lineNum"> 33</span> : 2. Compute class conditional mutual information I(Xi;XjIC), f or each</span>
<span id="L34"><span class="lineNum"> 34</span> : pair of features Xi and Xj, where i#j.</span>
<span id="L35"><span class="lineNum"> 35</span> : 3. Let the used variable list, S, be empty.</span>
<span id="L36"><span class="lineNum"> 36</span> : 4. Let the DAG network being constructed, BN, begin with a single</span>
<span id="L37"><span class="lineNum"> 37</span> : class node, C.</span>
<span id="L38"><span class="lineNum"> 38</span> : 5. Repeat until S includes all domain features</span>
<span id="L39"><span class="lineNum"> 39</span> : 5.1. Select feature Xmax which is not in S and has the largest value</span>
<span id="L40"><span class="lineNum"> 40</span> : I(Xmax;C).</span>
<span id="L41"><span class="lineNum"> 41</span> : 5.2. Add a node to BN representing Xmax.</span>
<span id="L42"><span class="lineNum"> 42</span> : 5.3. Add an arc from C to Xmax in BN.</span>
<span id="L43"><span class="lineNum"> 43</span> : 5.4. Add m = min(lSl,/c) arcs from m distinct features Xj in S with</span>
<span id="L44"><span class="lineNum"> 44</span> : the highest value for I(Xmax;X,jC).</span>
<span id="L45"><span class="lineNum"> 45</span> : 5.5. Add Xmax to S.</span>
<span id="L46"><span class="lineNum"> 46</span> : Compute the conditional probabilility infered by the structure of BN by</span>
<span id="L47"><span class="lineNum"> 47</span> : using counts from DB, and output BN.</span>
<span id="L48"><span class="lineNum"> 48</span> : */</span>
<span id="L49"><span class="lineNum"> 49</span> : // 1. For each feature Xi, compute mutual information, I(X;C),</span>
<span id="L50"><span class="lineNum"> 50</span> : // where C is the class.</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 52 : addNodes();</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 156 : const torch::Tensor&amp; y = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 52 : std::vector&lt;double&gt; mi;</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 396 : for (auto i = 0; i &lt; features.size(); i++) {</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 1032 : torch::Tensor firstFeature = dataset.index({ i, &quot;...&quot; });</span></span>
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 344 : mi.push_back(metrics.mutualInformation(firstFeature, y, weights));</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 344 : }</span></span>
<span id="L58"><span class="lineNum"> 58</span> : // 2. Compute class conditional mutual information I(Xi;XjIC), f or each</span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 52 : auto conditionalEdgeWeights = metrics.conditionalEdge(weights);</span></span>
<span id="L60"><span class="lineNum"> 60</span> : // 3. Let the used variable list, S, be empty.</span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 52 : std::vector&lt;int&gt; S;</span></span>
<span id="L62"><span class="lineNum"> 62</span> : // 4. Let the DAG network being constructed, BN, begin with a single</span>
<span id="L63"><span class="lineNum"> 63</span> : // class node, C.</span>
<span id="L64"><span class="lineNum"> 64</span> : // 5. Repeat until S includes all domain features</span>
<span id="L65"><span class="lineNum"> 65</span> : // 5.1. Select feature Xmax which is not in S and has the largest value</span>
<span id="L66"><span class="lineNum"> 66</span> : // I(Xmax;C).</span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 52 : auto order = argsort(mi);</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 396 : for (auto idx : order) {</span></span>
<span id="L69"><span class="lineNum"> 69</span> : // 5.2. Add a node to BN representing Xmax.</span>
<span id="L70"><span class="lineNum"> 70</span> : // 5.3. Add an arc from C to Xmax in BN.</span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 344 : model.addEdge(className, features[idx]);</span></span>
<span id="L72"><span class="lineNum"> 72</span> : // 5.4. Add m = min(lSl,/c) arcs from m distinct features Xj in S with</span>
<span id="L73"><span class="lineNum"> 73</span> : // the highest value for I(Xmax;X,jC).</span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 344 : add_m_edges(idx, S, conditionalEdgeWeights);</span></span>
<span id="L75"><span class="lineNum"> 75</span> : // 5.5. Add Xmax to S.</span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 344 : S.push_back(idx);</span></span>
<span id="L77"><span class="lineNum"> 77</span> : }</span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 448 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 344 : void KDB::add_m_edges(int idx, std::vector&lt;int&gt;&amp; S, torch::Tensor&amp; weights)</span></span>
<span id="L80"><span class="lineNum"> 80</span> : {</span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 344 : auto n_edges = std::min(k, static_cast&lt;int&gt;(S.size()));</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 344 : auto cond_w = clone(weights);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 344 : bool exit_cond = k == 0;</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 344 : int num = 0;</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 1004 : while (!exit_cond) {</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 2640 : auto max_minfo = argmax(cond_w.index({ idx, &quot;...&quot; })).item&lt;int&gt;();</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 660 : auto belongs = find(S.begin(), S.end(), max_minfo) != S.end();</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 1764 : if (belongs &amp;&amp; cond_w.index({ idx, max_minfo }).item&lt;float&gt;() &gt; theta) {</span></span>
<span id="L89"><span class="lineNum"> 89</span> : try {</span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 320 : model.addEdge(features[max_minfo], features[idx]);</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 320 : num++;</span></span>
<span id="L92"><span class="lineNum"> 92</span> : }</span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaUNC tlaBgUNC"> 0 : catch (const std::invalid_argument&amp; e) {</span></span>
<span id="L94"><span class="lineNum"> 94</span> : // Loops are not allowed</span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaUNC"> 0 : }</span></span>
<span id="L96"><span class="lineNum"> 96</span> : }</span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC tlaBgGNC"> 2640 : cond_w.index_put_({ idx, max_minfo }, -1);</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 1980 : auto candidates_mask = cond_w.index({ idx, &quot;...&quot; }).gt(theta);</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 660 : auto candidates = candidates_mask.nonzero();</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 660 : exit_cond = num == n_edges || candidates.size(0) == 0;</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 660 : }</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 2692 : }</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 8 : std::vector&lt;std::string&gt; KDB::graph(const std::string&amp; title) const</span></span>
<span id="L104"><span class="lineNum"> 104</span> : {</span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 8 : std::string header{ title };</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 8 : if (title == &quot;KDB&quot;) {</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 8 : header += &quot; (k=&quot; + std::to_string(k) + &quot;, theta=&quot; + std::to_string(theta) + &quot;)&quot;;</span></span>
<span id="L108"><span class="lineNum"> 108</span> : }</span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 16 : return model.graph(header);</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 8 : }</span></span>
<span id="L111"><span class="lineNum"> 111</span> : }</span>
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.cc</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<map name="overview">
<area shape="rect" coords="0,0,79,3" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,4,79,7" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,8,79,11" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,12,79,15" href="KDB.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,16,79,19" href="KDB.cc.gcov.html#L5" target="source" alt="overview">
<area shape="rect" coords="0,20,79,23" href="KDB.cc.gcov.html#L9" target="source" alt="overview">
<area shape="rect" coords="0,24,79,27" href="KDB.cc.gcov.html#L13" target="source" alt="overview">
<area shape="rect" coords="0,28,79,31" href="KDB.cc.gcov.html#L17" target="source" alt="overview">
<area shape="rect" coords="0,32,79,35" href="KDB.cc.gcov.html#L21" target="source" alt="overview">
<area shape="rect" coords="0,36,79,39" href="KDB.cc.gcov.html#L25" target="source" alt="overview">
<area shape="rect" coords="0,40,79,43" href="KDB.cc.gcov.html#L29" target="source" alt="overview">
<area shape="rect" coords="0,44,79,47" href="KDB.cc.gcov.html#L33" target="source" alt="overview">
<area shape="rect" coords="0,48,79,51" href="KDB.cc.gcov.html#L37" target="source" alt="overview">
<area shape="rect" coords="0,52,79,55" href="KDB.cc.gcov.html#L41" target="source" alt="overview">
<area shape="rect" coords="0,56,79,59" href="KDB.cc.gcov.html#L45" target="source" alt="overview">
<area shape="rect" coords="0,60,79,63" href="KDB.cc.gcov.html#L49" target="source" alt="overview">
<area shape="rect" coords="0,64,79,67" href="KDB.cc.gcov.html#L53" target="source" alt="overview">
<area shape="rect" coords="0,68,79,71" href="KDB.cc.gcov.html#L57" target="source" alt="overview">
<area shape="rect" coords="0,72,79,75" href="KDB.cc.gcov.html#L61" target="source" alt="overview">
<area shape="rect" coords="0,76,79,79" href="KDB.cc.gcov.html#L65" target="source" alt="overview">
<area shape="rect" coords="0,80,79,83" href="KDB.cc.gcov.html#L69" target="source" alt="overview">
<area shape="rect" coords="0,84,79,87" href="KDB.cc.gcov.html#L73" target="source" alt="overview">
<area shape="rect" coords="0,88,79,91" href="KDB.cc.gcov.html#L77" target="source" alt="overview">
<area shape="rect" coords="0,92,79,95" href="KDB.cc.gcov.html#L81" target="source" alt="overview">
<area shape="rect" coords="0,96,79,99" href="KDB.cc.gcov.html#L85" target="source" alt="overview">
<area shape="rect" coords="0,100,79,103" href="KDB.cc.gcov.html#L89" target="source" alt="overview">
<area shape="rect" coords="0,104,79,107" href="KDB.cc.gcov.html#L93" target="source" alt="overview">
<area shape="rect" coords="0,108,79,111" href="KDB.cc.gcov.html#L97" target="source" alt="overview">
</map>
<center>
<a href="KDB.cc.gcov.html#top" target="source">Top</a><br><br>
<img src="KDB.cc.gcov.png" width=80 height=110 alt="Overview" border=0 usemap="#overview">
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

View 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/classifiers/KDB.h - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.h<span style="font-size: 80%;"> (<a href="KDB.h.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">1</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDB.h.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.h.gcov.html#L20">bayesnet::KDB::~KDB()</a></td>
<td class="coverFnHi">44</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/classifiers/KDB.h - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.h<span style="font-size: 80%;"> (<a href="KDB.h.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">1</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDB.h.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.h.gcov.html#L20">bayesnet::KDB::~KDB()</a></td>
<td class="coverFnHi">44</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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.h</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<frameset cols="120,*">
<frame src="KDB.h.gcov.overview.html" name="overview">
<frame src="KDB.h.gcov.html" name="source">
<noframes>
<center>Frames not supported by your browser!<br></center>
</noframes>
</frameset>
</html>

View 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/KDB.h</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDB.h<span style="font-size: 80%;"> (source / <a href="KDB.h.func-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">1</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Line data Source code</pre>
<pre class="source">
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
<span id="L6"><span class="lineNum"> 6</span> : </span>
<span id="L7"><span class="lineNum"> 7</span> : #ifndef KDB_H</span>
<span id="L8"><span class="lineNum"> 8</span> : #define KDB_H</span>
<span id="L9"><span class="lineNum"> 9</span> : #include &lt;torch/torch.h&gt;</span>
<span id="L10"><span class="lineNum"> 10</span> : #include &quot;bayesnet/utils/bayesnetUtils.h&quot;</span>
<span id="L11"><span class="lineNum"> 11</span> : #include &quot;Classifier.h&quot;</span>
<span id="L12"><span class="lineNum"> 12</span> : namespace bayesnet {</span>
<span id="L13"><span class="lineNum"> 13</span> : class KDB : public Classifier {</span>
<span id="L14"><span class="lineNum"> 14</span> : private:</span>
<span id="L15"><span class="lineNum"> 15</span> : int k;</span>
<span id="L16"><span class="lineNum"> 16</span> : float theta;</span>
<span id="L17"><span class="lineNum"> 17</span> : void add_m_edges(int idx, std::vector&lt;int&gt;&amp; S, torch::Tensor&amp; weights);</span>
<span id="L18"><span class="lineNum"> 18</span> : protected:</span>
<span id="L19"><span class="lineNum"> 19</span> : void buildModel(const torch::Tensor&amp; weights) override;</span>
<span id="L20"><span class="lineNum"> 20</span> : public:</span>
<span id="L21"><span class="lineNum"> 21</span> : explicit KDB(int k, float theta = 0.03);</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC tlaBgGNC"> 44 : virtual ~KDB() = default;</span></span>
<span id="L23"><span class="lineNum"> 23</span> : void setHyperparameters(const nlohmann::json&amp; hyperparameters_) override;</span>
<span id="L24"><span class="lineNum"> 24</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;KDB&quot;) const override;</span>
<span id="L25"><span class="lineNum"> 25</span> : };</span>
<span id="L26"><span class="lineNum"> 26</span> : }</span>
<span id="L27"><span class="lineNum"> 27</span> : #endif</span>
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,27 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDB.h</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<map name="overview">
<area shape="rect" coords="0,0,79,3" href="KDB.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,4,79,7" href="KDB.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,8,79,11" href="KDB.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,12,79,15" href="KDB.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,16,79,19" href="KDB.h.gcov.html#L5" target="source" alt="overview">
<area shape="rect" coords="0,20,79,23" href="KDB.h.gcov.html#L9" target="source" alt="overview">
<area shape="rect" coords="0,24,79,27" href="KDB.h.gcov.html#L13" target="source" alt="overview">
</map>
<center>
<a href="KDB.h.gcov.html#top" target="source">Top</a><br><br>
<img src="KDB.h.gcov.png" width=80 height=26 alt="Overview" border=0 usemap="#overview">
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

View 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/KDBLd.cc - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.cc<span style="font-size: 80%;"> (<a href="KDBLd.cc.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">17</td>
<td class="headerCovTableEntry">17</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">4</td>
<td class="headerCovTableEntry">4</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDBLd.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">bayesnet::KDBLd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">bayesnet::KDBLd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">16</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">bayesnet::KDBLd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">20</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">bayesnet::KDBLd::KDBLd(int)</a></td>
<td class="coverFnHi">68</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/KDBLd.cc - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.cc<span style="font-size: 80%;"> (<a href="KDBLd.cc.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">17</td>
<td class="headerCovTableEntry">17</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">4</td>
<td class="headerCovTableEntry">4</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDBLd.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">bayesnet::KDBLd::KDBLd(int)</a></td>
<td class="coverFnHi">68</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">bayesnet::KDBLd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">20</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">bayesnet::KDBLd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">bayesnet::KDBLd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">16</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/KDBLd.cc</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<frameset cols="120,*">
<frame src="KDBLd.cc.gcov.overview.html" name="overview">
<frame src="KDBLd.cc.gcov.html" name="source">
<noframes>
<center>Frames not supported by your browser!<br></center>
</noframes>
</frameset>
</html>

View File

@ -0,0 +1,119 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.cc<span style="font-size: 80%;"> (source / <a href="KDBLd.cc.func-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">17</td>
<td class="headerCovTableEntry">17</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">4</td>
<td class="headerCovTableEntry">4</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Line data Source code</pre>
<pre class="source">
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
<span id="L6"><span class="lineNum"> 6</span> : </span>
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;KDBLd.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 68 : KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 20 : KDBLd&amp; KDBLd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L12"><span class="lineNum"> 12</span> : {</span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 20 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 20 : features = features_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 20 : className = className_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 20 : Xf = X_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 20 : y = y_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : // Fills std::vectors Xv &amp; yv with the data from tensors X_ (discretized) &amp; y</span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 20 : states = fit_local_discretization(y);</span></span>
<span id="L20"><span class="lineNum"> 20</span> : // We have discretized the input data</span>
<span id="L21"><span class="lineNum"> 21</span> : // 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 20 : KDB::fit(dataset, features, className, states);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 20 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 20 : return *this;</span></span>
<span id="L25"><span class="lineNum"> 25</span> : }</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 16 : torch::Tensor KDBLd::predict(torch::Tensor&amp; X)</span></span>
<span id="L27"><span class="lineNum"> 27</span> : {</span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 16 : auto Xt = prepareX(X);</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 32 : return KDB::predict(Xt);</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 16 : }</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 4 : std::vector&lt;std::string&gt; KDBLd::graph(const std::string&amp; name) const</span></span>
<span id="L32"><span class="lineNum"> 32</span> : {</span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 4 : return KDB::graph(name);</span></span>
<span id="L34"><span class="lineNum"> 34</span> : }</span>
<span id="L35"><span class="lineNum"> 35</span> : }</span>
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.cc</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<map name="overview">
<area shape="rect" coords="0,0,79,3" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,4,79,7" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,8,79,11" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,12,79,15" href="KDBLd.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,16,79,19" href="KDBLd.cc.gcov.html#L5" target="source" alt="overview">
<area shape="rect" coords="0,20,79,23" href="KDBLd.cc.gcov.html#L9" target="source" alt="overview">
<area shape="rect" coords="0,24,79,27" href="KDBLd.cc.gcov.html#L13" target="source" alt="overview">
<area shape="rect" coords="0,28,79,31" href="KDBLd.cc.gcov.html#L17" target="source" alt="overview">
<area shape="rect" coords="0,32,79,35" href="KDBLd.cc.gcov.html#L21" target="source" alt="overview">
</map>
<center>
<a href="KDBLd.cc.gcov.html#top" target="source">Top</a><br><br>
<img src="KDBLd.cc.gcov.png" width=80 height=34 alt="Overview" border=0 usemap="#overview">
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

View 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/classifiers/KDBLd.h - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.h<span style="font-size: 80%;"> (<a href="KDBLd.h.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">1</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="KDBLd.h.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.h.gcov.html#L15">bayesnet::KDBLd::~KDBLd()</a></td>
<td class="coverFnHi">20</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/classifiers/KDBLd.h - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.h<span style="font-size: 80%;"> (<a href="KDBLd.h.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">1</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="KDBLd.h.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.h.gcov.html#L15">bayesnet::KDBLd::~KDBLd()</a></td>
<td class="coverFnHi">20</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/KDBLd.h</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<frameset cols="120,*">
<frame src="KDBLd.h.gcov.overview.html" name="overview">
<frame src="KDBLd.h.gcov.html" name="source">
<noframes>
<center>Frames not supported by your browser!<br></center>
</noframes>
</frameset>
</html>

View File

@ -0,0 +1,108 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - KDBLd.h<span style="font-size: 80%;"> (source / <a href="KDBLd.h.func-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</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&nbsp;%</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">1</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Line data Source code</pre>
<pre class="source">
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
<span id="L6"><span class="lineNum"> 6</span> : </span>
<span id="L7"><span class="lineNum"> 7</span> : #ifndef KDBLD_H</span>
<span id="L8"><span class="lineNum"> 8</span> : #define KDBLD_H</span>
<span id="L9"><span class="lineNum"> 9</span> : #include &quot;Proposal.h&quot;</span>
<span id="L10"><span class="lineNum"> 10</span> : #include &quot;KDB.h&quot;</span>
<span id="L11"><span class="lineNum"> 11</span> : </span>
<span id="L12"><span class="lineNum"> 12</span> : namespace bayesnet {</span>
<span id="L13"><span class="lineNum"> 13</span> : class KDBLd : public KDB, public Proposal {</span>
<span id="L14"><span class="lineNum"> 14</span> : private:</span>
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
<span id="L16"><span class="lineNum"> 16</span> : explicit KDBLd(int k);</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 20 : virtual ~KDBLd() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : KDBLd&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L19"><span class="lineNum"> 19</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;KDB&quot;) const override;</span>
<span id="L20"><span class="lineNum"> 20</span> : torch::Tensor predict(torch::Tensor&amp; X) override;</span>
<span id="L21"><span class="lineNum"> 21</span> : static inline std::string version() { return &quot;0.0.1&quot;; };</span>
<span id="L22"><span class="lineNum"> 22</span> : };</span>
<span id="L23"><span class="lineNum"> 23</span> : }</span>
<span id="L24"><span class="lineNum"> 24</span> : #endif // !KDBLD_H</span>
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/KDBLd.h</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<map name="overview">
<area shape="rect" coords="0,0,79,3" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,4,79,7" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,8,79,11" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,12,79,15" href="KDBLd.h.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,16,79,19" href="KDBLd.h.gcov.html#L5" target="source" alt="overview">
<area shape="rect" coords="0,20,79,23" href="KDBLd.h.gcov.html#L9" target="source" alt="overview">
</map>
<center>
<a href="KDBLd.h.gcov.html#top" target="source">Top</a><br><br>
<img src="KDBLd.h.gcov.png" width=80 height=23 alt="Overview" border=0 usemap="#overview">
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

View File

@ -0,0 +1,139 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Proposal.cc<span style="font-size: 80%;"> (<a href="Proposal.cc.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">97.7&nbsp;%</td>
<td class="headerCovTableEntry">86</td>
<td class="headerCovTableEntry">84</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">8</td>
<td class="headerCovTableEntry">8</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="Proposal.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">bayesnet::Proposal::prepareX(at::Tensor&amp;)</a></td>
<td class="coverFnHi">168</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">bayesnet::Proposal::~Proposal()</a></td>
<td class="coverFnHi">200</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)</a></td>
<td class="coverFnHi">212</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">bayesnet::Proposal::checkInput(at::Tensor const&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">228</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">bayesnet::Proposal::fit_local_discretization[abi:cxx11](at::Tensor const&amp;)</a></td>
<td class="coverFnHi">232</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">bayesnet::Proposal::Proposal(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">424</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#2}::operator()&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">1372</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#1}::operator()&lt;bayesnet::Node*&gt;(bayesnet::Node* const&amp;) const</a></td>
<td class="coverFnHi">2696</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,139 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Proposal.cc<span style="font-size: 80%;"> (<a href="Proposal.cc.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">97.7&nbsp;%</td>
<td class="headerCovTableEntry">86</td>
<td class="headerCovTableEntry">84</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">8</td>
<td class="headerCovTableEntry">8</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="Proposal.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#1}::operator()&lt;bayesnet::Node*&gt;(bayesnet::Node* const&amp;) const</a></td>
<td class="coverFnHi">2696</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#2}::operator()&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">1372</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">bayesnet::Proposal::Proposal(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">424</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">bayesnet::Proposal::checkInput(at::Tensor const&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">228</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">bayesnet::Proposal::fit_local_discretization[abi:cxx11](at::Tensor const&amp;)</a></td>
<td class="coverFnHi">232</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)</a></td>
<td class="coverFnHi">212</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">bayesnet::Proposal::prepareX(at::Tensor&amp;)</a></td>
<td class="coverFnHi">168</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">bayesnet::Proposal::~Proposal()</a></td>
<td class="coverFnHi">200</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/Proposal.cc</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<frameset cols="120,*">
<frame src="Proposal.cc.gcov.overview.html" name="overview">
<frame src="Proposal.cc.gcov.html" name="source">
<noframes>
<center>Frames not supported by your browser!<br></center>
</noframes>
</frameset>
</html>

View File

@ -0,0 +1,200 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - Proposal.cc<span style="font-size: 80%;"> (source / <a href="Proposal.cc.func-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">97.7&nbsp;%</td>
<td class="headerCovTableEntry">86</td>
<td class="headerCovTableEntry">84</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">8</td>
<td class="headerCovTableEntry">8</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Line data Source code</pre>
<pre class="source">
<span id="L1"><span class="lineNum"> 1</span> : // ***************************************************************</span>
<span id="L2"><span class="lineNum"> 2</span> : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez</span>
<span id="L3"><span class="lineNum"> 3</span> : // SPDX-FileType: SOURCE</span>
<span id="L4"><span class="lineNum"> 4</span> : // SPDX-License-Identifier: MIT</span>
<span id="L5"><span class="lineNum"> 5</span> : // ***************************************************************</span>
<span id="L6"><span class="lineNum"> 6</span> : </span>
<span id="L7"><span class="lineNum"> 7</span> : #include &lt;ArffFiles.h&gt;</span>
<span id="L8"><span class="lineNum"> 8</span> : #include &quot;Proposal.h&quot;</span>
<span id="L9"><span class="lineNum"> 9</span> : </span>
<span id="L10"><span class="lineNum"> 10</span> : namespace bayesnet {</span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 424 : Proposal::Proposal(torch::Tensor&amp; dataset_, std::vector&lt;std::string&gt;&amp; features_, std::string&amp; className_) : pDataset(dataset_), pFeatures(features_), pClassName(className_) {}</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 200 : Proposal::~Proposal()</span></span>
<span id="L13"><span class="lineNum"> 13</span> : {</span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 1896 : for (auto&amp; [key, value] : discretizers) {</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 1696 : delete value;</span></span>
<span id="L16"><span class="lineNum"> 16</span> : }</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 200 : }</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 228 : void Proposal::checkInput(const torch::Tensor&amp; X, const torch::Tensor&amp; y)</span></span>
<span id="L19"><span class="lineNum"> 19</span> : {</span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 228 : if (!torch::is_floating_point(X)) {</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaUNC tlaBgUNC"> 0 : throw std::invalid_argument(&quot;X must be a floating point tensor&quot;);</span></span>
<span id="L22"><span class="lineNum"> 22</span> : }</span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC tlaBgGNC"> 228 : if (torch::is_floating_point(y)) {</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaUNC tlaBgUNC"> 0 : throw std::invalid_argument(&quot;y must be an integer tensor&quot;);</span></span>
<span id="L25"><span class="lineNum"> 25</span> : }</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC tlaBgGNC"> 228 : }</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 212 : map&lt;std::string, std::vector&lt;int&gt;&gt; Proposal::localDiscretizationProposal(const map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; oldStates, Network&amp; model)</span></span>
<span id="L28"><span class="lineNum"> 28</span> : {</span>
<span id="L29"><span class="lineNum"> 29</span> : // order of local discretization is important. no good 0, 1, 2...</span>
<span id="L30"><span class="lineNum"> 30</span> : // although we rediscretize features after the local discretization of every feature</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 212 : auto order = model.topological_sort();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 212 : auto&amp; nodes = model.getNodes();</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 212 : map&lt;std::string, std::vector&lt;int&gt;&gt; states = oldStates;</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 212 : std::vector&lt;int&gt; indicesToReDiscretize;</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 212 : bool upgrade = false; // Flag to check if we need to upgrade the model</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 1776 : for (auto feature : order) {</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 1564 : auto nodeParents = nodes[feature]-&gt;getParents();</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 1564 : if (nodeParents.size() &lt; 2) continue; // Only has class as parent</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 1324 : upgrade = true;</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 1324 : int index = find(pFeatures.begin(), pFeatures.end(), feature) - pFeatures.begin();</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 1324 : indicesToReDiscretize.push_back(index); // We need to re-discretize this feature</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 1324 : std::vector&lt;std::string&gt; parents;</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 4020 : transform(nodeParents.begin(), nodeParents.end(), back_inserter(parents), [](const auto&amp; p) { return p-&gt;getName(); });</span></span>
<span id="L44"><span class="lineNum"> 44</span> : // Remove class as parent as it will be added later</span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 1324 : parents.erase(remove(parents.begin(), parents.end(), pClassName), parents.end());</span></span>
<span id="L46"><span class="lineNum"> 46</span> : // Get the indices of the parents</span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 1324 : std::vector&lt;int&gt; indices;</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 1324 : indices.push_back(-1); // Add class index</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 2696 : transform(parents.begin(), parents.end(), back_inserter(indices), [&amp;](const auto&amp; p) {return find(pFeatures.begin(), pFeatures.end(), p) - pFeatures.begin(); });</span></span>
<span id="L50"><span class="lineNum"> 50</span> : // Now we fit the discretizer of the feature, conditioned on its parents and the class i.e. discretizer.fit(X[index], X[indices] + y)</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 1324 : std::vector&lt;std::string&gt; yJoinParents(Xf.size(1));</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 4020 : for (auto idx : indices) {</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 958640 : for (int i = 0; i &lt; Xf.size(1); ++i) {</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 2867832 : yJoinParents[i] += to_string(pDataset.index({ idx, i }).item&lt;int&gt;());</span></span>
<span id="L55"><span class="lineNum"> 55</span> : }</span>
<span id="L56"><span class="lineNum"> 56</span> : }</span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 1324 : auto arff = ArffFiles();</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 1324 : auto yxv = arff.factorize(yJoinParents);</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 2648 : auto xvf_ptr = Xf.index({ index }).data_ptr&lt;float&gt;();</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 1324 : auto xvf = std::vector&lt;mdlp::precision_t&gt;(xvf_ptr, xvf_ptr + Xf.size(1));</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 1324 : discretizers[feature]-&gt;fit(xvf, yxv);</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 1804 : }</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 212 : if (upgrade) {</span></span>
<span id="L64"><span class="lineNum"> 64</span> : // Discretize again X (only the affected indices) with the new fitted discretizers</span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 1536 : for (auto index : indicesToReDiscretize) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 2648 : auto Xt_ptr = Xf.index({ index }).data_ptr&lt;float&gt;();</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 1324 : auto Xt = std::vector&lt;float&gt;(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 5296 : pDataset.index_put_({ index, &quot;...&quot; }, torch::tensor(discretizers[pFeatures[index]]-&gt;transform(Xt)));</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 1324 : auto xStates = std::vector&lt;int&gt;(discretizers[pFeatures[index]]-&gt;getCutPoints().size() + 1);</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 1324 : iota(xStates.begin(), xStates.end(), 0);</span></span>
<span id="L71"><span class="lineNum"> 71</span> : //Update new states of the feature/node</span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 1324 : states[pFeatures[index]] = xStates;</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 1324 : }</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 212 : const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 212 : model.fit(pDataset, weights, pFeatures, pClassName, states);</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 212 : }</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 424 : return states;</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 960128 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 232 : map&lt;std::string, std::vector&lt;int&gt;&gt; Proposal::fit_local_discretization(const torch::Tensor&amp; y)</span></span>
<span id="L80"><span class="lineNum"> 80</span> : {</span>
<span id="L81"><span class="lineNum"> 81</span> : // Discretize the continuous input data and build pDataset (Classifier::dataset)</span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 232 : int m = Xf.size(1);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 232 : int n = Xf.size(0);</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 232 : map&lt;std::string, std::vector&lt;int&gt;&gt; states;</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 232 : pDataset = torch::zeros({ n + 1, m }, torch::kInt32);</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 232 : auto yv = std::vector&lt;int&gt;(y.data_ptr&lt;int&gt;(), y.data_ptr&lt;int&gt;() + y.size(0));</span></span>
<span id="L87"><span class="lineNum"> 87</span> : // discretize input data by feature(row)</span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 1944 : for (auto i = 0; i &lt; pFeatures.size(); ++i) {</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 1712 : auto* discretizer = new mdlp::CPPFImdlp();</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 3424 : auto Xt_ptr = Xf.index({ i }).data_ptr&lt;float&gt;();</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 1712 : auto Xt = std::vector&lt;float&gt;(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 1712 : discretizer-&gt;fit(Xt, yv);</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 6848 : pDataset.index_put_({ i, &quot;...&quot; }, torch::tensor(discretizer-&gt;transform(Xt)));</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 1712 : auto xStates = std::vector&lt;int&gt;(discretizer-&gt;getCutPoints().size() + 1);</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 1712 : iota(xStates.begin(), xStates.end(), 0);</span></span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 1712 : states[pFeatures[i]] = xStates;</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 1712 : discretizers[pFeatures[i]] = discretizer;</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 1712 : }</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 232 : int n_classes = torch::max(y).item&lt;int&gt;() + 1;</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 232 : auto yStates = std::vector&lt;int&gt;(n_classes);</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 232 : iota(yStates.begin(), yStates.end(), 0);</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 232 : states[pClassName] = yStates;</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 696 : pDataset.index_put_({ n, &quot;...&quot; }, y);</span></span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 464 : return states;</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 3888 : }</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 168 : torch::Tensor Proposal::prepareX(torch::Tensor&amp; X)</span></span>
<span id="L107"><span class="lineNum"> 107</span> : {</span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 168 : auto Xtd = torch::zeros_like(X, torch::kInt32);</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 1376 : for (int i = 0; i &lt; X.size(0); ++i) {</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 1208 : auto Xt = std::vector&lt;float&gt;(X[i].data_ptr&lt;float&gt;(), X[i].data_ptr&lt;float&gt;() + X.size(1));</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 1208 : auto Xd = discretizers[pFeatures[i]]-&gt;transform(Xt);</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 3624 : Xtd.index_put_({ i }, torch::tensor(Xd, torch::kInt32));</span></span>
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 1208 : }</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 336 : return Xtd;</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 1376 : }</span></span>
<span id="L116"><span class="lineNum"> 116</span> : }</span>
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/Proposal.cc</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<map name="overview">
<area shape="rect" coords="0,0,79,3" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,4,79,7" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,8,79,11" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,12,79,15" href="Proposal.cc.gcov.html#L1" target="source" alt="overview">
<area shape="rect" coords="0,16,79,19" href="Proposal.cc.gcov.html#L5" target="source" alt="overview">
<area shape="rect" coords="0,20,79,23" href="Proposal.cc.gcov.html#L9" target="source" alt="overview">
<area shape="rect" coords="0,24,79,27" href="Proposal.cc.gcov.html#L13" target="source" alt="overview">
<area shape="rect" coords="0,28,79,31" href="Proposal.cc.gcov.html#L17" target="source" alt="overview">
<area shape="rect" coords="0,32,79,35" href="Proposal.cc.gcov.html#L21" target="source" alt="overview">
<area shape="rect" coords="0,36,79,39" href="Proposal.cc.gcov.html#L25" target="source" alt="overview">
<area shape="rect" coords="0,40,79,43" href="Proposal.cc.gcov.html#L29" target="source" alt="overview">
<area shape="rect" coords="0,44,79,47" href="Proposal.cc.gcov.html#L33" target="source" alt="overview">
<area shape="rect" coords="0,48,79,51" href="Proposal.cc.gcov.html#L37" target="source" alt="overview">
<area shape="rect" coords="0,52,79,55" href="Proposal.cc.gcov.html#L41" target="source" alt="overview">
<area shape="rect" coords="0,56,79,59" href="Proposal.cc.gcov.html#L45" target="source" alt="overview">
<area shape="rect" coords="0,60,79,63" href="Proposal.cc.gcov.html#L49" target="source" alt="overview">
<area shape="rect" coords="0,64,79,67" href="Proposal.cc.gcov.html#L53" target="source" alt="overview">
<area shape="rect" coords="0,68,79,71" href="Proposal.cc.gcov.html#L57" target="source" alt="overview">
<area shape="rect" coords="0,72,79,75" href="Proposal.cc.gcov.html#L61" target="source" alt="overview">
<area shape="rect" coords="0,76,79,79" href="Proposal.cc.gcov.html#L65" target="source" alt="overview">
<area shape="rect" coords="0,80,79,83" href="Proposal.cc.gcov.html#L69" target="source" alt="overview">
<area shape="rect" coords="0,84,79,87" href="Proposal.cc.gcov.html#L73" target="source" alt="overview">
<area shape="rect" coords="0,88,79,91" href="Proposal.cc.gcov.html#L77" target="source" alt="overview">
<area shape="rect" coords="0,92,79,95" href="Proposal.cc.gcov.html#L81" target="source" alt="overview">
<area shape="rect" coords="0,96,79,99" href="Proposal.cc.gcov.html#L85" target="source" alt="overview">
<area shape="rect" coords="0,100,79,103" href="Proposal.cc.gcov.html#L89" target="source" alt="overview">
<area shape="rect" coords="0,104,79,107" href="Proposal.cc.gcov.html#L93" target="source" alt="overview">
<area shape="rect" coords="0,108,79,111" href="Proposal.cc.gcov.html#L97" target="source" alt="overview">
<area shape="rect" coords="0,112,79,115" href="Proposal.cc.gcov.html#L101" target="source" alt="overview">
</map>
<center>
<a href="Proposal.cc.gcov.html#top" target="source">Top</a><br><br>
<img src="Proposal.cc.gcov.png" width=80 height=115 alt="Overview" border=0 usemap="#overview">
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

View File

@ -0,0 +1,104 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/SPODE.cc - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - SPODE.cc<span style="font-size: 80%;"> (<a href="SPODE.cc.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">10</td>
<td class="headerCovTableEntry">10</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">3</td>
<td class="headerCovTableEntry">3</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><a href="SPODE.cc.func.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></a></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></span></td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">bayesnet::SPODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">68</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">bayesnet::SPODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1016</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">bayesnet::SPODE::SPODE(int)</a></td>
<td class="coverFnHi">1124</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View File

@ -0,0 +1,104 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - BayesNet Coverage Report - bayesnet/classifiers/SPODE.cc - functions</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="10%" class="headerValue"><a href="../../index.html" target="_parent">top level</a> - <a href="index.html" target="_parent">bayesnet/classifiers</a> - SPODE.cc<span style="font-size: 80%;"> (<a href="SPODE.cc.gcov.html">source</a> / functions)</span></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%" class="headerCovTableHead">Coverage</td>
<td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
<td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">BayesNet Coverage Report</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">10</td>
<td class="headerCovTableEntry">10</td>
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-05-06 17:54:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
<td class="headerCovTableEntry">3</td>
<td class="headerCovTableEntry">3</td>
</tr>
<tr>
<td class="headerItem">Legend:</td>
<td class="headerValueLeg"> Lines:
<span class="coverLegendCov">hit</span>
<span class="coverLegendNoCov">not hit</span>
</td>
<td></td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table cellpadding=1 cellspacing=1 border=0>
<tr><td><br></td></tr>
<tr>
<td class="tableHead">Function Name <span title="Click to sort table by function name" class="tableHeadSort"><img src="../../glass.png" width=10 height=14 alt="Sort by function name" title="Click to sort table by function name" border=0></span></td>
<td class="tableHead">Hit count <span title="Click to sort table by function hit count" class="tableHeadSort"><a href="SPODE.cc.func-c.html"><img src="../../updown.png" width=10 height=14 alt="Sort by function hit count" title="Click to sort table by function hit count" border=0></a></span></td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">bayesnet::SPODE::SPODE(int)</a></td>
<td class="coverFnHi">1124</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">bayesnet::SPODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1016</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">bayesnet::SPODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">68</td>
</tr>
</table>
<br>
</center>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
</table>
<br>
</body>
</html>

View 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/SPODE.cc</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<frameset cols="120,*">
<frame src="SPODE.cc.gcov.overview.html" name="overview">
<frame src="SPODE.cc.gcov.html" name="source">
<noframes>
<center>Frames not supported by your browser!<br></center>
</noframes>
</frameset>
</html>

Some files were not shown because too many files have changed in this diff Show More