Begin conan integration

This commit is contained in:
2025-07-03 01:40:30 +02:00
parent 1ef7ca6180
commit 3d814a79c6
16 changed files with 350 additions and 127 deletions

2
.gitignore vendored
View File

@@ -43,3 +43,5 @@ diagrams/html/**
diagrams/latex/**
.cache
vcpkg_installed
.claude/settings.local.json
CMakeUserPresets.json

93
CHANGELOG.md Normal file
View File

@@ -0,0 +1,93 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- **BREAKING**: Migrated dependency management from vcpkg to Conan
- Updated build system to use Conan toolchain files instead of vcpkg
- Updated `make init` command to use `conan install` instead of `vcpkg install`
- Modified CMakeLists.txt to use Conan's find_package mechanism
- Updated documentation in CLAUDE.md to reflect Conan usage
### Added
- `conanfile.py` - Conan recipe for dependency management with all required dependencies
- CMakeUserPresets.json (generated by Conan)
- Support for Conan build profiles (Release/Debug)
### Removed
- `vcpkg.json` - vcpkg manifest file
- `vcpkg-configuration.json` - vcpkg registry configuration
- vcpkg toolchain dependency in build system
### Notes
- The migration maintains compatibility with existing make targets and workflow
- All dependencies now managed through Conan package manager
## [1.1.0] - 2025-07-02
### Added
- **AdaBoost Implementation**: Complete multi-class SAMME AdaBoost classifier with optimization
- Optimized AdaBoostPredict with 100 estimators as default
- Enhanced predictProbaSample functionality
- Full predict_proba support for probabilistic predictions
- **Decision Tree Classifier**: New base classifier implementation with comprehensive tests
- **XA1DE Model Family**: Extended Averaged One-Dependence Estimators
- XA1DE, XBAODE, XSPODE variants with threading support
- Complete integration with memory optimization
- Prior probability computation in prediction
- **Wilcoxon Statistical Test**: Statistical significance testing for model comparison
- **Folder Management**: Enhanced file organization with folder parameter support across tools
- Added folder parameter to b_best, b_grid, b_main, and b_manage
- **vcpkg Integration**: Package management system integration (now migrated to Conan)
### Enhanced
- **Grid Search System**: Complete refactoring with MPI parallelization
- Grid experiment functionality with conditional result saving
- Fixed smoothing problems and dataset ordering
- Enhanced reporting and summary generation
- **Excel Reporting**: Advanced Excel export capabilities
- ReportExcelCompared class for side-by-side result comparison
- Enhanced formatting with colors and fixed headers
- Automatic file opening after generation
- **Results Management**: Comprehensive result handling and validation
- JSON schema validation for result format integrity
- Improved console reporting with classification reports
- Pagination support for large result sets
- **Statistical Analysis**: Enhanced statistical testing and reporting
- AUC (Area Under Curve) computation and reporting
- Confusion matrix generation and visualization
- Classification reports with color coding
### Performance Improvements
- Optimized AdaBoost training and prediction algorithms
- Enhanced memory management in XA1DE implementations
- Improved discretization algorithms with MDLP integration
- Faster ROC-AUC computation for binary classification problems
### Developer Experience
- **Testing Framework**: Comprehensive test suite with Catch2
- **Build System**: Streamlined CMake configuration with dependency management
- **Documentation**: Enhanced project documentation and build instructions
- **Code Quality**: Refactored codebase with improved error handling and logging
### Bug Fixes
- Fixed predict_proba implementations across multiple classifiers
- Resolved grid search dataset ordering issues
- Fixed Excel report formatting and column width problems
- Corrected time output formatting in various tools
- Fixed memory leaks and stability issues in model implementations
## [1.0.0] - 2024-01-09
### Initial Release
- **Core Framework**: Machine learning experimentation platform for Bayesian Networks
- **Basic Classifiers**: Initial set of Bayesian network classifiers
- **Experiment Management**: Basic experiment orchestration and result storage
- **Dataset Support**: ARFF file format support with discretization
- **Build System**: CMake-based build system with external library integration
- **Command Line Tools**: Initial versions of b_main, b_best, b_list utilities

139
CLAUDE.md Normal file
View File

@@ -0,0 +1,139 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Platform is a C++ machine learning framework for running experiments with Bayesian Networks and other classifiers. It supports both research-focused experimental classifiers and production-ready models through a unified interface.
## Build System
The project uses CMake with Make as the primary build system:
- **Release build**: `make release` (creates `build_Release/` directory)
- **Debug build**: `make debug` (creates `build_Debug/` directory with testing and coverage enabled)
- **Install binaries**: `make install` (copies executables to `~/bin` by default)
- **Clean project**: `make clean` (removes build directories)
- **Initialize dependencies**: `make init` (runs conan install for both Release and Debug)
### Testing
- **Run tests**: `make test` (builds debug version and runs all tests)
- **Coverage report**: `make coverage` (runs tests and generates coverage with gcovr)
- **Single test with options**: `make test opt="-s"` (verbose) or `make test opt="-c='Test Name'"` (specific test)
### Build Targets
Main executables (built from `src/commands/`):
- `b_main`: Main experiment runner
- `b_grid`: Grid search over hyperparameters
- `b_best`: Best results analysis and comparison
- `b_list`: Dataset listing and properties
- `b_manage`: Results management interface
- `b_results`: Results processing
## Dependencies
The project uses Conan for package management with these key dependencies:
- **libtorch**: PyTorch C++ backend for tensor operations
- **nlohmann_json**: JSON processing
- **catch2**: Unit testing framework
- **cli11**: Command-line argument parsing (replacement for argparse)
Custom dependencies (not available in ConanCenter):
- **fimdlp**: MDLP discretization library (needs manual integration)
- **folding**: Cross-validation utilities (needs manual integration)
- **arff-files**: ARFF dataset file handling (needs manual integration)
External dependencies (managed separately):
- **BayesNet**: Core Bayesian network classifiers (from `../lib/`)
- **PyClassifiers**: Python classifier wrappers (from `../lib/`)
- **MPI**: Message Passing Interface for parallel processing
- **Boost**: Python integration and utilities
**Note**: Some dependencies (fimdlp, folding, arff-files) are not available in ConanCenter and need to be:
- Built as custom Conan packages, or
- Integrated using CMake FetchContent, or
- Built separately and found via find_package
## Architecture
### Core Components
**Experiment Framework** (`src/main/`):
- `Experiment.cpp/h`: Main experiment orchestration
- `Models.cpp/h`: Classifier factory and registration system
- `Scores.cpp/h`: Performance metrics calculation
- `HyperParameters.cpp/h`: Parameter management
- `ArgumentsExperiment.cpp/h`: Command-line argument handling
**Data Handling** (`src/common/`):
- `Dataset.cpp/h`: Individual dataset representation
- `Datasets.cpp/h`: Dataset collection management
- `Discretization.cpp/h`: Data discretization utilities
**Classifiers** (`src/experimental_clfs/`):
- `AdaBoost.cpp/h`: Multi-class SAMME AdaBoost implementation
- `DecisionTree.cpp/h`: Decision tree base classifier
- `XA1DE.cpp/h`: Extended AODE variants
- Experimental implementations of Bayesian network classifiers
**Grid Search** (`src/grid/`):
- `GridSearch.cpp/h`: Hyperparameter optimization
- `GridExperiment.cpp/h`: Grid search experiment management
- Uses MPI for parallel hyperparameter evaluation
**Results & Reporting** (`src/results/`, `src/reports/`):
- JSON-based result storage with schema validation
- Excel export capabilities via libxlsxwriter
- Console and paginated result display
### Model Registration System
The framework uses a factory pattern with automatic registration:
- All classifiers inherit from `bayesnet::BaseClassifier`
- Registration happens in `src/main/modelRegister.h`
- Factory creates instances by string name via `Models::create()`
## Configuration
**Environment Configuration** (`.env` file):
- `experiment`: Experiment name/type
- `n_folds`: Cross-validation folds (default: 5)
- `seeds`: Random seeds for reproducibility
- `model`: Default classifier name
- `score`: Primary evaluation metric
- `platform`: System identifier for results
**Grid Search Configuration**:
- `grid_<model_name>_input.json`: Hyperparameter search space
- `grid_<model_name>_output.json`: Search results
## Data Format
**Dataset Requirements**:
- ARFF format files in `datasets/` directory
- `all.txt` file listing datasets: `<name>,<class_name>,<real_features>`
- Supports both discrete and continuous features
- Automatic discretization available via MDLP
**Experimental Data**:
- Results stored in JSON format with versioned schemas
- Test data in `tests/data/` for unit testing
- Sample datasets: iris, diabetes, ecoli, glass, etc.
## Development Workflow
1. **Setup**: Run `make init` to install dependencies via Conan
2. **Development**: Use `make debug` for development builds with testing
3. **Testing**: Run `make test` after changes
4. **Release**: Use `make release` for optimized builds
5. **Experiments**: Use `.env` configuration and run `b_main` with appropriate flags
## Key Features
- **Multi-threaded**: Uses MPI for parallel grid search and experiments
- **Cross-platform**: Supports Linux and macOS via vcpkg
- **Extensible**: Easy classifier registration and integration
- **Research-focused**: Designed for machine learning experimentation
- **Visualization**: DOT graph generation for decision trees and networks

View File

@@ -15,7 +15,7 @@ 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_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_DEBUG " ${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O0 -g")
# Options
@@ -43,8 +43,6 @@ find_package(Boost 1.66.0 REQUIRED COMPONENTS python3 numpy3)
# # Python
find_package(Python3 REQUIRED COMPONENTS Development)
# # target_include_directories(MyTarget SYSTEM PRIVATE ${Python3_INCLUDE_DIRS})
# message("Python_LIBRARIES=${Python_LIBRARIES}")
# # Boost Python
# find_package(boost_python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} CONFIG REQUIRED COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
@@ -63,28 +61,23 @@ endif()
# External libraries - dependencies of Platform
# ---------------------------------------------
find_library(XLSXWRITER_LIB NAMES libxlsxwriter.dylib libxlsxwriter.so PATHS ${Platform_SOURCE_DIR}/lib/libxlsxwriter/lib)
# find_library(XLSXWRITER_LIB NAMES libxlsxwriter.dylib libxlsxwriter.so PATHS ${Platform_SOURCE_DIR}/lib/libxlsxwriter/lib)
# find_path(XLSXWRITER_INCLUDE_DIR xlsxwriter.h)
# find_library(XLSXWRITER_LIBRARY xlsxwriter)
# message("XLSXWRITER_INCLUDE_DIR=${XLSXWRITER_INCLUDE_DIR}")
# message("XLSXWRITER_LIBRARY=${XLSXWRITER_LIBRARY}")
# Conan dependencies
find_package(nlohmann_json CONFIG REQUIRED)
find_package(Catch2 CONFIG REQUIRED)
find_package(argparse CONFIG REQUIRED)
find_package(Torch CONFIG REQUIRED)
find_package(arff-files CONFIG REQUIRED)
find_package(fimdlp CONFIG REQUIRED)
find_package(folding CONFIG REQUIRED)
find_package(argparse CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS python)
find_package(arff-files CONFIG REQUIRED)
find_package(bayesnet CONFIG REQUIRED)
find_package(libxlsxwriter CONFIG REQUIRED)
# BayesNet
find_library(bayesnet NAMES libbayesnet bayesnet libbayesnet.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
find_path(Bayesnet_INCLUDE_DIRS REQUIRED NAMES bayesnet PATHS ${Platform_SOURCE_DIR}/../lib/include)
add_library(bayesnet::bayesnet UNKNOWN IMPORTED)
set_target_properties(bayesnet::bayesnet PROPERTIES
IMPORTED_LOCATION ${bayesnet}
INTERFACE_INCLUDE_DIRECTORIES ${Bayesnet_INCLUDE_DIRS})
message(STATUS "BayesNet=${bayesnet}")
message(STATUS "BayesNet_INCLUDE_DIRS=${Bayesnet_INCLUDE_DIRS}")
find_package(Boost REQUIRED COMPONENTS python)
# PyClassifiers
find_library(PyClassifiers NAMES libPyClassifiers PyClassifiers libPyClassifiers.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
@@ -106,8 +99,9 @@ file(GLOB Platform_SOURCES CONFIGURE_DEPENDS ${Platform_SOURCE_DIR}/src/*.cpp)
# -------
if (ENABLE_TESTING)
enable_testing()
set(CODE_COVERAGE ON)
MESSAGE("Testing enabled")
find_package(Catch2 CONFIG REQUIRED)
# Catch2 is already found above via Conan
include(CTest)
add_subdirectory(tests)
endif (ENABLE_TESTING)

View File

@@ -20,15 +20,33 @@ define ClearTests
fi ;
endef
define build_target
@echo ">>> Building the project for $(1)..."
@if [ -d $(2) ]; then rm -fr $(2); fi
@conan install . --build=missing -of $(2) -s build_type=$(1)
@cmake -S . -B $(2) -DCMAKE_TOOLCHAIN_FILE=$(2)/build/$(1)/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$(1) -D$(3)
endef
define compile_target
@echo ">>> Compiling for $(1)..."
if [ "$(3)" != "" ]; then \
target="-t$(3)"; \
else \
target=""; \
fi
@cmake --build $(2) --config $(1) --parallel $(target)
endef
init: ## Initialize the project installing dependencies
@echo ">>> Installing dependencies"
@vcpkg install
@echo ">>> Installing dependencies with Conan"
@conan install . --output-folder=build --build=missing -s build_type=Release
@conan install . --output-folder=build_debug --build=missing -s build_type=Debug
@echo ">>> Done";
clean: ## Clean the project
@echo ">>> Cleaning the project..."
@if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
@for folder in $(f_release) $(f_debug) vpcpkg_installed install_test ; do \
@for folder in $(f_release) $(f_debug) build build_debug install_test ; do \
if test -d "$$folder" ; then \
echo "- Deleting $$folder folder" ; \
rm -rf "$$folder"; \
@@ -45,11 +63,6 @@ setup: ## Install dependencies for tests and coverage
pip install gcovr; \
fi
dest ?= ${HOME}/bin
main: ## Build only the b_main target
@cmake --build $(f_release) -t b_main --parallel
@cp $(f_release)/src/b_main $(dest)
dest ?= ${HOME}/bin
install: ## Copy binary files to bin folder
@echo "Destination folder: $(dest)"
@@ -70,34 +83,27 @@ dependency: ## Create a dependency graph diagram of the project (build/dependenc
cd $(f_debug) && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png
buildd: ## Build the debug targets
@cmake --build $(f_debug) -t $(app_targets) PlatformSample --parallel
@$(call compile_target,"Debug","$(f_debug)")
buildr: ## Build the release targets
@cmake --build $(f_release) -t $(app_targets) --parallel
@$(call compile_target,"Release","$(f_release)")
clang-uml: ## Create uml class and sequence diagrams
clang-uml -p --add-compile-flag -I /usr/lib/gcc/x86_64-redhat-linux/8/include/
debug: ## Build a debug version of the project with BayesNet from vcpkg
@echo ">>> Building Debug Platform...";
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
@mkdir $(f_debug);
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
debug: ## Build a debug version of the project with Conan
@$(call build_target,"Debug","$(f_debug)", "ENABLE_TESTING=ON")
release: ## Build a Release version of the project with Conan
@$(call build_target,"Release","$(f_release)", "ENABLE_TESTING=OFF")
release: ## Build a Release version of the project with BayesNet from vcpkg
@echo ">>> Building Release Platform...";
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release);
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
opt = ""
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
@echo ">>> Running Platform tests...";
@$(MAKE) clean
@$(MAKE) debug
@cmake --build $(f_debug) -t $(test_targets) --parallel
@$(call "Compile_target", "Debug", "$(f_debug)", $(test_targets))
@for t in $(test_targets); do \
if [ -f $(f_debug)/tests/$$t ]; then \
cd $(f_debug)/tests ; \

41
conanfile.py Normal file
View File

@@ -0,0 +1,41 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout
class PlatformConan(ConanFile):
name = "platform"
version = "1.1.0"
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*", "tests/*", "config/*", "cmake/*"
def requirements(self):
# Core dependencies from vcpkg.json
self.requires("argparse/3.2")
self.requires("libtorch/2.7.0")
self.requires("nlohmann_json/3.11.3")
self.requires("folding/1.1.1")
self.requires("fimdlp/2.1.0")
self.requires("arff-files/1.2.0")
self.requires("bayesnet/1.2.0")
self.requires("libxlsxwriter/1.2.2")
def build_requirements(self):
self.tool_requires("cmake/[>=3.30]")
self.test_requires("catch2/3.8.1")
def layout(self):
cmake_layout(self)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()
def configure(self):
# C++20 requirement
self.settings.compiler.cppstd = "20"

View File

@@ -2,12 +2,10 @@ include_directories(
## Libs
${Python3_INCLUDE_DIRS}
${MPI_CXX_INCLUDE_DIRS}
${TORCH_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/configured_files/include
${PyClassifiers_INCLUDE_DIRS}
## Platform
${Platform_SOURCE_DIR}/src
${Platform_SOURCE_DIR}/results
)
# b_best
@@ -23,7 +21,7 @@ add_executable(
experimental_clfs/DecisionTree.cpp
experimental_clfs/AdaBoost.cpp
)
target_link_libraries(b_best Boost::boost "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy "${XLSXWRITER_LIB}")
target_link_libraries(b_best Boost::boost "${PyClassifiers}" bayesnet::bayesnet argparse::argparse fimdlp::fimdlp ${Python3_LIBRARIES} torch::torch Boost::python Boost::numpy "${XLSXWRITER_LIB}")
# b_grid
set(grid_sources GridSearch.cpp GridData.cpp GridExperiment.cpp GridBase.cpp )
@@ -38,7 +36,7 @@ add_executable(b_grid commands/b_grid.cpp ${grid_sources}
experimental_clfs/DecisionTree.cpp
experimental_clfs/AdaBoost.cpp
)
target_link_libraries(b_grid ${MPI_CXX_LIBRARIES} "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy)
target_link_libraries(b_grid ${MPI_CXX_LIBRARIES} "${PyClassifiers}" bayesnet::bayesnet argparse::argparse fimdlp::fimdlp ${Python3_LIBRARIES} torch::torch Boost::python Boost::numpy)
# b_list
add_executable(b_list commands/b_list.cpp
@@ -51,7 +49,7 @@ add_executable(b_list commands/b_list.cpp
experimental_clfs/DecisionTree.cpp
experimental_clfs/AdaBoost.cpp
)
target_link_libraries(b_list "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy "${XLSXWRITER_LIB}")
target_link_libraries(b_list "${PyClassifiers}" bayesnet::bayesnet argparse::argparse fimdlp::fimdlp ${Python3_LIBRARIES} torch::torch Boost::python Boost::numpy "${XLSXWRITER_LIB}")
# b_main
set(main_sources Experiment.cpp Models.cpp HyperParameters.cpp Scores.cpp ArgumentsExperiment.cpp)
@@ -66,7 +64,7 @@ add_executable(b_main commands/b_main.cpp ${main_sources}
experimental_clfs/DecisionTree.cpp
experimental_clfs/AdaBoost.cpp
)
target_link_libraries(b_main PRIVATE nlohmann_json::nlohmann_json "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy)
target_link_libraries(b_main PRIVATE nlohmann_json::nlohmann_json "${PyClassifiers}" bayesnet::bayesnet argparse::argparse fimdlp::fimdlp ${Python3_LIBRARIES} torch::torch Boost::python Boost::numpy)
# b_manage
set(manage_sources ManageScreen.cpp OptionsMenu.cpp ResultsManager.cpp)
@@ -78,7 +76,8 @@ add_executable(
results/Result.cpp results/ResultsDataset.cpp results/ResultsDatasetConsole.cpp
main/Scores.cpp
)
target_link_libraries(b_manage "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" fimdlp bayesnet::bayesnet)
target_link_libraries(b_manage torch::torch "${XLSXWRITER_LIB}" fimdlp::fimdlp bayesnet::bayesnet argparse::argparse)
# b_results
add_executable(b_results commands/b_results.cpp)
target_link_libraries(b_results torch::torch "${XLSXWRITER_LIB}" fimdlp::fimdlp bayesnet::bayesnet argparse::argparse)

View File

@@ -2,8 +2,8 @@
#include <filesystem>
#include <fstream>
#include <vector>
#include <argparse/argparse.hpp>
#include <nlohmann/json.hpp>
#include "nlohmann/json.hpp"
#include "argparse/argparse.hpp"
#include "common/Paths.h"
#include "results/JsonValidator.h"
#include "results/SchemaV1_0.h"

View File

@@ -1,4 +1,4 @@
#include <ArffFiles/ArffFiles.hpp>
#include <ArffFiles.hpp>
#include <fstream>
#include "Dataset.h"
namespace platform {

18
src/common/TensorUtils.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef TENSOR_UTILS_H
#define TENSOR_UTILS_H
#include <torch/torch.h>
#include <vector>
namespace platform {
template <typename T>
std::vector<T> tensorToVector(const torch::Tensor& tensor)
{
torch::Tensor contig_tensor = tensor.contiguous();
auto num_elements = contig_tensor.numel();
const T* tensor_data = contig_tensor.data_ptr<T>();
std::vector<T> result(tensor_data, tensor_data + num_elements);
return result;
}
}
#endif

View File

@@ -6,17 +6,11 @@
#include <string>
#include <vector>
#include <algorithm>
#include <torch/torch.h>
#include <cstdlib>
extern char **environ;
namespace platform {
template <typename T>
std::vector<T> tensorToVector(const torch::Tensor& tensor)
{
torch::Tensor contig_tensor = tensor.contiguous();
auto num_elements = contig_tensor.numel();
const T* tensor_data = contig_tensor.data_ptr<T>();
std::vector<T> result(tensor_data, tensor_data + num_elements);
return result;
}
static std::string trim(const std::string& str)
{
std::string result = str;

View File

@@ -3,6 +3,7 @@
#include <numeric>
#include <utility>
#include "RocAuc.h"
#include "common/TensorUtils.h" // tensorToVector
namespace platform {
double RocAuc::compute(const torch::Tensor& y_proba, const torch::Tensor& labels)

View File

@@ -1,6 +1,6 @@
#include <sstream>
#include "Scores.h"
#include "common/Utils.h" // tensorToVector
#include "common/TensorUtils.h" // tensorToVector
#include "common/Colors.h"
namespace platform {
Scores::Scores(torch::Tensor& y_test, torch::Tensor& y_proba, int num_classes, std::vector<std::string> labels) : num_classes(num_classes), labels(labels), y_test(y_test), y_proba(y_proba)

View File

@@ -7,7 +7,7 @@
#include <string>
#include "TestUtils.h"
#include "folding.hpp"
#include <ArffFiles/ArffFiles.hpp>
#include <ArffFiles.hpp>
#include <bayesnet/classifiers/TAN.h>
#include "config_platform.h"

View File

@@ -1,21 +0,0 @@
{
"default-registry": {
"kind": "git",
"baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/rmontanana/vcpkg-stash",
"baseline": "1ea69243c0e8b0de77c9d1dd6e1d7593ae7f3627",
"packages": [
"arff-files",
"bayesnet",
"fimdlp",
"folding",
"libtorch-bin"
]
}
]
}

View File

@@ -1,43 +0,0 @@
{
"name": "platform",
"version-string": "1.1.0",
"dependencies": [
"arff-files",
"nlohmann-json",
"fimdlp",
"libtorch-bin",
"folding",
"catch2",
"argparse"
],
"overrides": [
{
"name": "arff-files",
"version": "1.1.0"
},
{
"name": "fimdlp",
"version": "2.0.1"
},
{
"name": "libtorch-bin",
"version": "2.7.0"
},
{
"name": "folding",
"version": "1.1.1"
},
{
"name": "argparse",
"version": "3.2"
},
{
"name": "catch2",
"version": "3.8.1"
},
{
"name": "nlohmann-json",
"version": "3.11.3"
}
]
}