The UV Package Manager helps keeping track of the needed python packages.
UV can be installed as Standalone by:
curl -LsSf https://astral.sh/uv/install.sh | shThis repository includes a simple 1D example which showcases WSKDE. In the example the WSKDE confidence bounds are calculated and plotted. The example can be executued by cloning the repository, installing the required python packages using uv sync, and running the example as follows:
git clone https://github.com/SDU-Robotics/wilson-score-kde.git
cd wilson-score-kde
uv sync
uv run examples/simple_1D/simple_1D.pyThe example demonstrates how to:
- Define a bandwidth matrix H
- Initialize WSKDE with H
- Set the supervised dataset used for inference
- Compute the z-confidence bounds as p ± σ
(see examples/simple_1D.py for full example)
from wskde.wskde import WSKDE
...
# Load x_train and y_train
# Define x_test
h = 0.5
H = torch.diag(torch.Tensor([h]))
wskde = WSKDE(H)
wskde.set_training_samples(x_train, y_train)
p_test, sigma_test = wskde(x_test, z=1.96)Below shows how to build and install the C++ Wrapper for WSKDE Python implementation
Install the following packages:
sudo apt install python3-dev pybind11-devNavigate into the following folder while standing in the root folder of this repository:
cd cpp/Wrapper/
mkdir build
cd build/
source ../../../.venv/bin/activate
cmake ..
makeTo see if the bindings to python works correctly execute the test:
./WSKDEWrapperTestAfterwards, install the WSKDE Wrapper lib:
sudo make installTo see if the Wrapper lib was installed correctly, build and execute the example:
cd ../../example/
mkdir build
cd build/
cmake ..
make
./WSKDEWrapperLibExampleThe WS-KDE package can be added directly to your uv project over https by:
- HTTPS:
uv add git+https://github.com/SDU-Robotics/wilson-score-kde.git
To clone the python package and install it with pip, do the following:
- Clone project from git
- Activate your virtual python environment
- cd to the root of the wilson-score-kde folder
pip install .
If you found this repository useful, please cite:
@inproceedings{iversen2025global,
title={Global Optimization of Stochastic Black-Box Functions with Arbitrary Noise Distributions using Wilson Score Kernel Density Estimation},
author={Iversen, Thorbj{\o}rn Mosekj{\ae}r and S{\o}rensen, Lars Car{\o}e and Mathiesen, Simon Faarvang and Petersen, Henrik Gordon},
booktitle={2025 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)},
year={2025},
organization={IEEE}
}
For reference to the original Wilson Score Kernel Density Estimation paper, please cite:
@inproceedings{sorensen2020wilson,
title={Wilson score kernel density estimation for bernoulli trials},
author={S{\o}rensen, Lars Car{\o}e and Mathiesen, Simon and Kraft, Dirk and Petersen, Henrik Gordon},
booktitle={17th International Conference on Informatics in Control, Automation and Robotics (ICINCO)},
pages={305--313},
year={2020},
organization={SCITEPRESS Digital Library}
}