
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
DBSampler is a package to sample points in the decision boundary of classification problems (binary or multiclass). It is theorically exact and efficient for very high dimensions. The guarentees:
Pre-built packages currently for MacOS, Windows and Linux systems are available in PyPI and can be installed with:
pip install dbsampler
On uncommon architectures, you may need to first
install Cargo before running pip install vlmc
.
In order to compile from source you will need to install Rust/Cargo and maturin for the python bindings. Maturin is best used within a Python virtual environment:
# activate your desired virtual environment first, then:
pip install maturin
git clone https://github.com/antonio-leitao/dbsampler.git
cd vlmc
# build and install the package:
maturin develop --release
import dbsampler
cover = dbsampler.dbs(data=X,labels=y,n_points=1000,n_epochs=5, sparse=True, parallel=True)
Parameters:
data
: numpy array of shape (samples,features) with the points of every class.labels
: 1-dimensional numpy array with labels of each points. Array must be flattened.n_points
: This determines the number of points sampled from the decision boundary. More points equates for a denser sample but slows the algorithm. Default is 1000.sparse
: boolean (default True
), whether to remove points that are in the same Voronoi Edge or not.parallel
: boolean (default True
)Returns:
cover
: numpy array (n_points, n_features) of points in the decision boundary.Passing the sparse
flag will remove the cover points that fall on the same Voronoi Edge, favoring the first one.
This can drastically reduce the number of points while maintaining a uniform and complete cover of the decision boundary.
Below is the example of 5000
points sampled (left) and the same points with sparse=True
.
DBSampler is written in Rust pre-builds the binaries for Windows, MacOS and most Linux distributions.
DBSampler achieves very high performance due to effective parallization and BLAS support.
Currently manages to calculate a cover of 5 000
points given 10 000
points in 500
dimensions in less than 10 seconds.
More improvments are planned targeted situations where the number of samples times the dimensions is higher than 1 billion where the current implmentations starts to slow down.
For an in-depth explanation check at our paper. The algorithm aims at sampling uniformly points from the edges of Voronoi Cells belonging to points of different classes. The union of these edges is the decision boundary that maximizes the distance between classes.
It starts by building an initial uniform sample of the space containing n_points
. It then iterativelly "pushes" each point to the hyperplane orthogonal to the one between its closest neighbors of different classes.
Sketch of proof of convergence. At each iteration in n_epochs
:
If you use DBSampler in your work or parts of the algorithm please consider citing:
@inproceedings{petri2020on,
title={On The Topological Expressive Power of Neural Networks},
author={Giovanni Petri and Ant{\'o}nio Leit{\~a}o},
booktitle={NeurIPS 2020 Workshop on Topological Data Analysis and Beyond},
year={2020},
url={https://openreview.net/forum?id=I44kJPuvqPD}
}
In the paper above you can find the pseudocode of the algorithm along with the proof of convergence. A complete paper about the method is coming soon.
FAQs
Decision Boundary Sampler
We found that dbsampler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.