Update sample project and README
This commit is contained in:
3
Makefile
3
Makefile
@@ -111,7 +111,8 @@ fname = "tests/data/iris.arff"
|
|||||||
sample: ## Build sample
|
sample: ## Build sample
|
||||||
@echo ">>> Building Sample...";
|
@echo ">>> Building Sample...";
|
||||||
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
||||||
@cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug && cmake --build build -t bayesnet_sample
|
@cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && \
|
||||||
|
cmake --build build -t bayesnet_sample
|
||||||
sample/build/bayesnet_sample $(fname)
|
sample/build/bayesnet_sample $(fname)
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
88
README.md
88
README.md
@@ -12,43 +12,103 @@
|
|||||||
|
|
||||||
Bayesian Network Classifiers library
|
Bayesian Network Classifiers library
|
||||||
|
|
||||||
## Dependencies
|
## Setup
|
||||||
|
|
||||||
The only external dependency is [libtorch](https://pytorch.org/cppdocs/installing.html) which can be installed with the following commands:
|
### Using the vcpkg library
|
||||||
|
|
||||||
```bash
|
You can use the library with the vcpkg library manager. In your project you have to add the following files:
|
||||||
wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
|
|
||||||
unzip libtorch-shared-with-deps-latest.zip
|
#### vcpkg.json
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "sample-project",
|
||||||
|
"version-string": "0.1.0",
|
||||||
|
"dependencies": [
|
||||||
|
"bayesnet"
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Setup
|
#### vcpkg-configuration.json
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"registries": [
|
||||||
|
{
|
||||||
|
"kind": "git",
|
||||||
|
"repository": "https://github.com/rmontanana/vcpkg-stash",
|
||||||
|
"baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
|
||||||
|
"packages": [
|
||||||
|
"folding",
|
||||||
|
"bayesnet",
|
||||||
|
"arff-files",
|
||||||
|
"fimdlp",
|
||||||
|
"libtorch-bin"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default-registry": {
|
||||||
|
"kind": "git",
|
||||||
|
"repository": "https://github.com/microsoft/vcpkg",
|
||||||
|
"baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### CMakeLists.txt
|
||||||
|
|
||||||
|
You have to include the following lines in your `CMakeLists.txt` file:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
find_package(bayesnet CONFIG REQUIRED)
|
||||||
|
|
||||||
|
add_executable(myapp main.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(myapp PRIVATE bayesnet::bayesnet)
|
||||||
|
```
|
||||||
|
|
||||||
|
After that, you can use the `vcpkg` command to install the dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vcpkg install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note: In the `sample` folder you can find a sample application that uses the library. You can use it as a reference to create your own application.**
|
||||||
|
|
||||||
|
## Playing with the library
|
||||||
|
|
||||||
|
The dependencies are managed with [vcpkg](https://vcpkg.io/) and supported by a private vcpkg repository in [https://github.com/rmontanana/vcpkg-stash](https://github.com/rmontanana/vcpkg-stash).
|
||||||
|
|
||||||
### Getting the code
|
### Getting the code
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone --recurse-submodules https://github.com/doctorado-ml/bayesnet
|
git clone https://github.com/doctorado-ml/bayesnet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Once you have the code, you can use the `make` command to build the project. The `Makefile` is used to manage the build process and it will automatically download and install the dependencies.
|
||||||
|
|
||||||
### Release
|
### Release
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make release
|
make init # Install dependencies
|
||||||
make buildr
|
make release # Build the release version
|
||||||
sudo make install
|
make buildr # compile and link the release version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debug & Tests
|
### Debug & Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make debug
|
make init # Install dependencies
|
||||||
make test
|
make debug # Build the debug version
|
||||||
|
make test # Run the tests
|
||||||
```
|
```
|
||||||
|
|
||||||
### Coverage
|
### Coverage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make coverage
|
make coverage # Run the tests with coverage
|
||||||
make viewcoverage
|
make viewcoverage # View the coverage report in the browser
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sample app
|
### Sample app
|
||||||
|
@@ -4,24 +4,19 @@ project(bayesnet_sample)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
find_package(Torch REQUIRED)
|
find_package(Torch CONFIG REQUIRED)
|
||||||
find_library(BayesNet NAMES libBayesNet BayesNet libBayesNet.a REQUIRED)
|
find_package(bayesnet CONFIG REQUIRED)
|
||||||
find_path(Bayesnet_INCLUDE_DIRS REQUIRED NAMES bayesnet)
|
find_package(fimdlp CONFIG REQUIRED)
|
||||||
find_library(FImdlp NAMES libfimdlp.a PATHS REQUIRED)
|
find_package(folding CONFIG REQUIRED)
|
||||||
|
find_package(arff-files CONFIG REQUIRED)
|
||||||
message(STATUS "FImdlp=${FImdlp}")
|
find_package(nlohman_json CONFIG REQUIRED)
|
||||||
message(STATUS "FImdlp_INCLUDE_DIRS=${FImdlp_INCLUDE_DIRS}")
|
|
||||||
message(STATUS "BayesNet=${BayesNet}")
|
|
||||||
message(STATUS "Bayesnet_INCLUDE_DIRS=${Bayesnet_INCLUDE_DIRS}")
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
../tests/lib/Files
|
|
||||||
lib/json/include
|
|
||||||
/usr/local/include
|
|
||||||
/usr/local/include/fimdlp/
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(bayesnet_sample sample.cc)
|
add_executable(bayesnet_sample sample.cc)
|
||||||
target_link_libraries(bayesnet_sample ${FImdlp} "${TORCH_LIBRARIES}" "${BayesNet}")
|
target_link_libraries(bayesnet_sample PRIVATE
|
||||||
add_executable(bayesnet_sample_xspode sample_xspode.cc)
|
fimdlp::fimdlp
|
||||||
target_link_libraries(bayesnet_sample_xspode ${FImdlp} "${TORCH_LIBRARIES}" "${BayesNet}")
|
arff-files::arff-files
|
||||||
|
"${TORCH_LIBRARIES}"
|
||||||
|
bayesnet::bayesnet
|
||||||
|
nlohmann_json::nlohmann_json
|
||||||
|
folding::folding
|
||||||
|
)
|
||||||
|
21
sample/vcpkg-configuration.json
Normal file
21
sample/vcpkg-configuration.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"registries": [
|
||||||
|
{
|
||||||
|
"kind": "git",
|
||||||
|
"repository": "https://github.com/rmontanana/vcpkg-stash",
|
||||||
|
"baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
|
||||||
|
"packages": [
|
||||||
|
"folding",
|
||||||
|
"bayesnet",
|
||||||
|
"arff-files",
|
||||||
|
"fimdlp",
|
||||||
|
"libtorch-bin"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default-registry": {
|
||||||
|
"kind": "git",
|
||||||
|
"repository": "https://github.com/microsoft/vcpkg",
|
||||||
|
"baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605"
|
||||||
|
}
|
||||||
|
}
|
12
sample/vcpkg.json
Normal file
12
sample/vcpkg.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "sample-project",
|
||||||
|
"version-string": "0.1.0",
|
||||||
|
"dependencies": [
|
||||||
|
"bayesnet",
|
||||||
|
"folding",
|
||||||
|
"arff-files",
|
||||||
|
"fimdlp",
|
||||||
|
"nlohmann-json",
|
||||||
|
"libtorch-bin"
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user