Easy to use package of the DNNR regression.
Project description
DNNR: Differential Nearest Neighbors Regression
[Paper] [Documentation]
The Python package of differential nearest neighbors regression (DNNR): Raising KNN-regression to levels of gradient boosting methods.
Whereas KNN regression only uses the averaged value, DNNR also uses the gradient or even higher-order derivatives:
Our implementation uses numpy, sklearn, and the annoy approximate nearest neighbor index. Using annoy is optional, as you can also use sklearn's KDTree as index. We support Python 3.7 to 3.10.
🚀 Quickstart
To install this project, run:
pip install dnnr
🎉 Example
import numpy as np
from dnnr import DNNR
X = np.array([[0], [1], [2], [3]])
y = np.array([0, 0, 1, 1])
model = DNNR(n_neighbors=1, n_derivative_neighbors=3)
model.fit(X, y)
model.predict([[1.5]])
# Will output: 0.25
Also check out our Jupiter Notebook on how to use DNNR.
📊 Hyperparameters
DNNR has three main hyperparameters:
n_neighbors: number of nearest neighbors to use. The default value of3is usually a good choice.n_derivative_neighbors: number of neighbors used in approximating the derivatives. As a default value, we choose3 * dim, wheredimis the input dimension.order: Taylor approximation order, one of1,2,2diag,3diag. The preferable option here is1. Sometimes2diagcan deliver small improvements.2and3diagare implemented but usually do not yield significant improvements.
We recommend a hyperparameter search over the n_derivative_neighbors variable to archive the best performance.
For all options, see the documentation of the DNNR class.
🛠 Development Installation
python3 -m venv venv # create a virtual environment
source venv/bin/activate # and load it
git clone https://github.com/younader/dnnr.git
cd dnnr
pip install -U pip wheel poetry
poetry install
make test # to run the tests
📄 Citation
If you use this library for a scientific publication, please use the following BibTex entry to cite our work:
@InProceedings{pmlr-v162-nader22a,
title = {{DNNR}: Differential Nearest Neighbors Regression},
author = {Nader, Youssef and Sixt, Leon and Landgraf, Tim},
booktitle = {Proceedings of the 39th International Conference on Machine Learning},
pages = {16296--16317},
year = {2022},
editor = {Chaudhuri, Kamalika and Jegelka, Stefanie and Song, Le and Szepesvari, Csaba and Niu, Gang and Sabato, Sivan},
volume = {162},
series = {Proceedings of Machine Learning Research},
month = {17--23 Jul},
publisher = {PMLR},
pdf = {https://proceedings.mlr.press/v162/nader22a/nader22a.pdf},
url = {https://proceedings.mlr.press/v162/nader22a.html},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dnnr-0.1.2.tar.gz.
File metadata
- Download URL: dnnr-0.1.2.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad60dccbdcb9287fd1644aceb118cb517d1fa1d37adeade97271af62afe6bac
|
|
| MD5 |
a0de3d453b89ba8ae30c3d6fd9fe1977
|
|
| BLAKE2b-256 |
95a20291d74f60908d43fa2312dafc1cf1f2ea269015b7b86a3ced2650b40f8c
|
File details
Details for the file dnnr-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dnnr-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbaee1ce75b99f047aa188ad94e8e90c3c1e1e9fdfae19e09969652d0e9c76fb
|
|
| MD5 |
ed12bd2f08b3c7fb29e6fc0083587b1b
|
|
| BLAKE2b-256 |
c36876f23eb4f6cf23be0a59baff77547936b4ee53ec028f56882c0e43532885
|