Compare commits
2 Commits
28be43db02
...
conan
Author | SHA1 | Date | |
---|---|---|---|
dfa74056f5
|
|||
839be5335d
|
17
CLAUDE.md
17
CLAUDE.md
@@ -9,14 +9,17 @@ BayesNet is a C++ library implementing Bayesian Network Classifiers. It provides
|
|||||||
## Build System & Dependencies
|
## Build System & Dependencies
|
||||||
|
|
||||||
### Dependency Management
|
### Dependency Management
|
||||||
|
|
||||||
The project supports **two package managers**:
|
The project supports **two package managers**:
|
||||||
|
|
||||||
#### vcpkg (Default)
|
#### vcpkg (Default)
|
||||||
- Uses vcpkg with private registry at https://github.com/rmontanana/vcpkg-stash
|
|
||||||
|
- Uses vcpkg with private registry at <https://github.com/rmontanana/vcpkg-stash>
|
||||||
- Core dependencies: libtorch, nlohmann-json, folding, fimdlp, arff-files, catch2
|
- Core dependencies: libtorch, nlohmann-json, folding, fimdlp, arff-files, catch2
|
||||||
- All dependencies defined in `vcpkg.json` with version overrides
|
- All dependencies defined in `vcpkg.json` with version overrides
|
||||||
|
|
||||||
#### Conan (Alternative)
|
#### Conan (Alternative)
|
||||||
|
|
||||||
- Modern C++ package manager with better dependency resolution
|
- Modern C++ package manager with better dependency resolution
|
||||||
- Configured via `conanfile.py` for packaging and distribution
|
- Configured via `conanfile.py` for packaging and distribution
|
||||||
- Supports subset of dependencies (libtorch, nlohmann-json, catch2)
|
- Supports subset of dependencies (libtorch, nlohmann-json, catch2)
|
||||||
@@ -25,6 +28,7 @@ The project supports **two package managers**:
|
|||||||
### Build Commands
|
### Build Commands
|
||||||
|
|
||||||
#### Using vcpkg (Default)
|
#### Using vcpkg (Default)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Initialize dependencies
|
# Initialize dependencies
|
||||||
make init
|
make init
|
||||||
@@ -49,6 +53,7 @@ make clean
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Using Conan
|
#### Using Conan
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install Conan first: pip install conan
|
# Install Conan first: pip install conan
|
||||||
|
|
||||||
@@ -74,6 +79,7 @@ make conan-clean
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CMake Configuration
|
### CMake Configuration
|
||||||
|
|
||||||
- Uses CMake 3.27+ with C++17 standard
|
- Uses CMake 3.27+ with C++17 standard
|
||||||
- Debug builds automatically enable testing and coverage
|
- Debug builds automatically enable testing and coverage
|
||||||
- Release builds optimize with `-Ofast`
|
- Release builds optimize with `-Ofast`
|
||||||
@@ -89,6 +95,7 @@ make conan-clean
|
|||||||
- Coverage reporting with lcov/genhtml
|
- Coverage reporting with lcov/genhtml
|
||||||
|
|
||||||
### Test Categories
|
### Test Categories
|
||||||
|
|
||||||
- A2DE, BoostA2DE, BoostAODE, XSPODE, XSPnDE, XBAODE, XBA2DE
|
- A2DE, BoostA2DE, BoostAODE, XSPODE, XSPnDE, XBAODE, XBA2DE
|
||||||
- Classifier, Ensemble, FeatureSelection, Metrics, Models
|
- Classifier, Ensemble, FeatureSelection, Metrics, Models
|
||||||
- Network, Node, MST, Modules
|
- Network, Node, MST, Modules
|
||||||
@@ -96,6 +103,7 @@ make conan-clean
|
|||||||
## Code Architecture
|
## Code Architecture
|
||||||
|
|
||||||
### Core Structure
|
### Core Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
bayesnet/
|
bayesnet/
|
||||||
├── BaseClassifier.h # Abstract base for all classifiers
|
├── BaseClassifier.h # Abstract base for all classifiers
|
||||||
@@ -107,12 +115,14 @@ bayesnet/
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Key Design Patterns
|
### Key Design Patterns
|
||||||
|
|
||||||
- **BaseClassifier** abstract interface for all algorithms
|
- **BaseClassifier** abstract interface for all algorithms
|
||||||
- Template-based design with both std::vector and torch::Tensor support
|
- Template-based design with both std::vector and torch::Tensor support
|
||||||
- Network/Node abstraction for Bayesian network representation
|
- Network/Node abstraction for Bayesian network representation
|
||||||
- Feature selection as separate, composable modules
|
- Feature selection as separate, composable modules
|
||||||
|
|
||||||
### Data Handling
|
### Data Handling
|
||||||
|
|
||||||
- Supports both discrete integer data and continuous data with discretization
|
- Supports both discrete integer data and continuous data with discretization
|
||||||
- ARFF file format support through arff-files library
|
- ARFF file format support through arff-files library
|
||||||
- Tensor operations via PyTorch C++ (libtorch)
|
- Tensor operations via PyTorch C++ (libtorch)
|
||||||
@@ -128,6 +138,7 @@ bayesnet/
|
|||||||
## Sample Applications
|
## Sample Applications
|
||||||
|
|
||||||
Sample code in `sample/` directory demonstrates library usage:
|
Sample code in `sample/` directory demonstrates library usage:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make sample fname=tests/data/iris.arff model=TANLd
|
make sample fname=tests/data/iris.arff model=TANLd
|
||||||
```
|
```
|
||||||
@@ -135,6 +146,7 @@ make sample fname=tests/data/iris.arff model=TANLd
|
|||||||
## Package Distribution
|
## Package Distribution
|
||||||
|
|
||||||
### Creating Conan Packages
|
### Creating Conan Packages
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create package locally
|
# Create package locally
|
||||||
make conan-create
|
make conan-create
|
||||||
@@ -148,7 +160,9 @@ make conan-upload remote=myremote profile=myprofile
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Using the Library
|
### Using the Library
|
||||||
|
|
||||||
With Conan:
|
With Conan:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# conanfile.txt or conanfile.py
|
# conanfile.txt or conanfile.py
|
||||||
[requires]
|
[requires]
|
||||||
@@ -159,6 +173,7 @@ cmake
|
|||||||
```
|
```
|
||||||
|
|
||||||
With vcpkg:
|
With vcpkg:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"dependencies": ["bayesnet"]
|
"dependencies": ["bayesnet"]
|
||||||
|
@@ -18,7 +18,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors")
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
|
||||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
|
||||||
@@ -68,18 +67,19 @@ target_link_libraries(bayesnet
|
|||||||
# -------
|
# -------
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
MESSAGE("Debug mode")
|
MESSAGE("Debug mode")
|
||||||
set(ENABLE_TESTING ON)
|
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(CODE_COVERAGE ON)
|
MESSAGE("Release mode")
|
||||||
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
MESSAGE(STATUS "Testing enabled")
|
MESSAGE(STATUS "Testing enabled")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors")
|
||||||
find_package(Catch2 CONFIG REQUIRED)
|
find_package(Catch2 CONFIG REQUIRED)
|
||||||
find_package(arff-files CONFIG REQUIRED)
|
find_package(arff-files CONFIG REQUIRED)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
include(CTest)
|
include(CTest)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
else(ENABLE_TESTING)
|
else(ENABLE_TESTING)
|
||||||
message("Release mode")
|
|
||||||
endif (ENABLE_TESTING)
|
endif (ENABLE_TESTING)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
@@ -99,17 +99,14 @@ configure_package_config_file(
|
|||||||
install(TARGETS bayesnet
|
install(TARGETS bayesnet
|
||||||
EXPORT bayesnetTargets
|
EXPORT bayesnetTargets
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib)
|
||||||
CONFIGURATIONS Release)
|
|
||||||
|
|
||||||
install(DIRECTORY bayesnet/
|
install(DIRECTORY bayesnet/
|
||||||
DESTINATION include/bayesnet
|
DESTINATION include/bayesnet
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
CONFIGURATIONS Release
|
|
||||||
PATTERN "*.h")
|
PATTERN "*.h")
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h
|
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h
|
||||||
DESTINATION include/bayesnet
|
DESTINATION include/bayesnet)
|
||||||
CONFIGURATIONS Release)
|
|
||||||
|
|
||||||
install(EXPORT bayesnetTargets
|
install(EXPORT bayesnetTargets
|
||||||
FILE bayesnetTargets.cmake
|
FILE bayesnetTargets.cmake
|
||||||
|
@@ -24,16 +24,15 @@ bayesnet/1.2.0
|
|||||||
[generators]
|
[generators]
|
||||||
CMakeDeps
|
CMakeDeps
|
||||||
CMakeToolchain
|
CMakeToolchain
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install dependencies:
|
1. Install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
conan install . --build=missing
|
conan install . --build=missing
|
||||||
```
|
```
|
||||||
|
|
||||||
3. In your CMakeLists.txt:
|
1. In your CMakeLists.txt:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
find_package(bayesnet REQUIRED)
|
find_package(bayesnet REQUIRED)
|
||||||
@@ -69,8 +68,8 @@ make conan-create
|
|||||||
For the custom dependencies, you'll need to create Conan recipes:
|
For the custom dependencies, you'll need to create Conan recipes:
|
||||||
|
|
||||||
1. **folding**: Cross-validation library
|
1. **folding**: Cross-validation library
|
||||||
2. **fimdlp**: Discretization library
|
1. **fimdlp**: Discretization library
|
||||||
3. **arff-files**: ARFF file format parser
|
1. **arff-files**: ARFF file format parser
|
||||||
|
|
||||||
Contact the maintainer or create custom recipes for these packages.
|
Contact the maintainer or create custom recipes for these packages.
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@@ -220,8 +220,8 @@ release: ## Build release version using Conan
|
|||||||
|
|
||||||
conan-create: ## Create Conan package
|
conan-create: ## Create Conan package
|
||||||
@echo ">>> Creating Conan package..."
|
@echo ">>> Creating Conan package..."
|
||||||
@conan create . --build=missing -tf "" --profile=release -tf ""
|
@conan create . --build=missing -tf "" --profile=release
|
||||||
@conan create . --build=missing -tf "" --profile=debug
|
@conan create . --build=missing -tf "" --profile=debug -o "&:enable_coverage=False" -o "&:enable_testing=False"
|
||||||
@echo ">>> Done"
|
@echo ">>> Done"
|
||||||
|
|
||||||
profile ?= release
|
profile ?= release
|
||||||
|
Reference in New Issue
Block a user