{"id":18923997,"url":"https://github.com/younader/dnnr","last_synced_at":"2025-04-15T12:32:17.836Z","repository":{"id":50492696,"uuid":"493243312","full_name":"younader/dnnr","owner":"younader","description":"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.","archived":false,"fork":false,"pushed_at":"2022-08-04T10:03:22.000Z","size":1162,"stargazers_count":18,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-13T05:04:18.776Z","etag":null,"topics":["annoy","knn","machine-learning","machine-learning-algorithms","numpy","python3","scikit-learn","tabular-data"],"latest_commit_sha":null,"homepage":"https://younader.github.io/dnnr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/younader.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-17T12:33:51.000Z","updated_at":"2025-04-09T01:45:03.000Z","dependencies_parsed_at":"2022-08-02T16:15:53.035Z","dependency_job_id":null,"html_url":"https://github.com/younader/dnnr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younader%2Fdnnr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younader%2Fdnnr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younader%2Fdnnr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younader%2Fdnnr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/younader","download_url":"https://codeload.github.com/younader/dnnr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249072404,"owners_count":21208182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annoy","knn","machine-learning","machine-learning-algorithms","numpy","python3","scikit-learn","tabular-data"],"created_at":"2024-11-08T11:05:13.095Z","updated_at":"2025-04-15T12:32:17.539Z","avatar_url":"https://github.com/younader.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DNNR: Differential Nearest Neighbors Regression\n\n[![Build Status](https://github.com/younader/dnnr/actions/workflows/dev.yml/badge.svg)](https://github.com/younader/dnnr/actions/workflows/dev.yml)\n\n[[Paper](https://proceedings.mlr.press/v162/nader22a.html)]\n[[Documentation](https://younader.github.io/dnnr/)]\n\nThe Python package of [differential nearest neighbors regression (DNNR)](https://proceedings.mlr.press/v162/nader22a.html): **Raising KNN-regression to levels of gradient boosting methods.**\n\nWhereas KNN regression only uses the averaged value, DNNR also uses the gradient or even higher-order derivatives:\n\n![KNN and DNNR Overview Image](knn_dnnr_overview.png)\n\nOur implementation uses `numpy`, `sklearn`, and the [`annoy`](https://github.com/spotify/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.\n\n\n# 🚀 Quickstart\n\n\nTo install this project, run:\n\n```bash\npip install dnnr\n```\n\n\n# 🎉 Example\n\n```python\nimport numpy as np\nfrom dnnr import DNNR\n\nX = np.array([[0], [1], [2], [3]])\ny = np.array([0, 0, 1, 1])\n\nmodel = DNNR(n_neighbors=1, n_derivative_neighbors=3)\nmodel.fit(X, y)\nmodel.predict([[1.5]])\n# Will output: 0.25\n```\n\nAlso check out our [Jupiter Notebook](./examples/dnnr_tutorial.ipynb) on how to use DNNR. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/younader/dnnr/blob/main/examples/dnnr_tutorial.ipynb)\n\n\n# 📊 Hyperparameters\n\nDNNR has three main hyperparameters:\n\n* `n_neighbors`: number of nearest neighbors to use. The default value of\n      `3` is usually a good choice.\n* `n_derivative_neighbors`: number of neighbors used in approximating the\n      derivatives. As a default value, we choose `3 * dim`, where `dim` is\n      the input dimension.\n* `order`: Taylor approximation order, one of `1`, `2`, `2diag`, `3diag`.\n      The preferable option here is `1`. Sometimes `2diag` can deliver\n      small improvements. `2` and `3diag` are implemented but usually do\n      not yield significant improvements.\n\nWe recommend a hyperparameter search over the `n_derivative_neighbors` variable to archive the best performance.\n\nFor all options, see the [documentation of the DNNR class](https://younader.github.io/dnnr/api/#dnnr.dnnr.DNNR).\n\n#  🛠 Development Installation\n\n```bash\npython3 -m venv venv      # create a virtual environment\nsource venv/bin/activate  # and load it\ngit clone https://github.com/younader/dnnr.git\ncd dnnr\npip install -U pip wheel poetry\npoetry install\nmake test                 # to run the tests\n```\n\n\n# 📄 Citation\n\nIf you use this library for a scientific publication, please use the following BibTex entry to cite our work:\n\n```bibtex\n@InProceedings{pmlr-v162-nader22a,\n  title = \t {{DNNR}: Differential Nearest Neighbors Regression},\n  author =       {Nader, Youssef and Sixt, Leon and Landgraf, Tim},\n  booktitle = \t {Proceedings of the 39th International Conference on Machine Learning},\n  pages = \t {16296--16317},\n  year = \t {2022},\n  editor = \t {Chaudhuri, Kamalika and Jegelka, Stefanie and Song, Le and Szepesvari, Csaba and Niu, Gang and Sabato, Sivan},\n  volume = \t {162},\n  series = \t {Proceedings of Machine Learning Research},\n  month = \t {17--23 Jul},\n  publisher =    {PMLR},\n  pdf = \t {https://proceedings.mlr.press/v162/nader22a/nader22a.pdf},\n  url = \t {https://proceedings.mlr.press/v162/nader22a.html},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounader%2Fdnnr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyounader%2Fdnnr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounader%2Fdnnr/lists"}