GithubHelp home page GithubHelp logo

dhockaday / dnnr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from younader/dnnr

0.0 0.0 0.0 1.13 MB

The Python package of differential nearest neighbors regression (DNNR): Raising KNN-regression to levels of gradient boosting method. Build on-top of Numpy, Scikit-Learn, and Annoy.

Home Page: https://younader.github.io/dnnr/

License: MIT License

Python 99.11% Makefile 0.89%

dnnr's Introduction

DNNR: Differential Nearest Neighbors Regression

Build Status

[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:

KNN and DNNR Overview Image

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. Open In Colab

๐Ÿ“Š Hyperparameters

DNNR has three main hyperparameters:

  • n_neighbors: number of nearest neighbors to use. The default value of 3 is usually a good choice.
  • n_derivative_neighbors: number of neighbors used in approximating the derivatives. As a default value, we choose 3 * dim, where dim is the input dimension.
  • order: Taylor approximation order, one of 1, 2, 2diag, 3diag. The preferable option here is 1. Sometimes 2diag can deliver small improvements. 2 and 3diag are 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},
}

dnnr's People

Contributors

berleon avatar younader avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.