{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/evaluating-the-robustness-of-nearest-neighbor","title":"Evaluating the Robustness of Nearest Neighbor Classifiers: A Primal-Dual Perspective","arxiv_id":"1906.03972","date":"2019-06-10","proceeding":null,"authors":["Lu Wang","Xuanqing Liu","Jin-Feng Yi","Zhi-Hua Zhou","Cho-Jui Hsieh"],"abstract":"We study the problem of computing the minimum adversarial perturbation of the Nearest Neighbor (NN) classifiers. Previous attempts either conduct attacks on continuous approximations of NN models or search for the perturbation by some heuristic methods. In this paper, we propose the first algorithm that is able to compute the minimum adversarial perturbation. The main idea is to formulate the problem as a list of convex quadratic programming (QP) problems that can be efficiently solved by the proposed algorithms for 1-NN models. Furthermore, we show that dual solutions for these QP problems could give us a valid lower bound of the adversarial perturbation that can be used for formal robustness verification, giving us a nice view of attack/verification for NN models. For $K$-NN models with larger $K$, we show that the same formulation can help us efficiently compute the upper and lower bounds of the minimum adversarial perturbation, which can be used for attack and verification.","url_abs":"https://arxiv.org/abs/1906.03972v1","url_pdf":"https://arxiv.org/pdf/1906.03972v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"evaluating-the-robustness-of-nearest-neighbor","repo_url":"https://github.com/wangwllu/knn_robustness","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":null,"task_name":"valid"}],"methods":[{"method_slug":"affine-coupling","method_name":"Affine Coupling"},{"method_slug":"normalizing-flows","method_name":"Normalizing Flows"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=1906.03972","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1906.03972"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wangwllu/knn_robustness","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":8},"by_repo_kind":{"listed":{"samples":8,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"56a44c19d84052e4","entry":"encode_labels","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/loaders.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/loaders.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"56a44c19d84052e4"}},{"code_sha256_prefix":"9a3a3e0b24aecec6","entry":"initialize_data","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/initialize_main.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/initialize_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9a3a3e0b24aecec6"}},{"code_sha256_prefix":"6f49e95895bdf451","entry":"initialize_params","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/initialize_main.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/initialize_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6f49e95895bdf451"}},{"code_sha256_prefix":"a6812e5985bf3ded","entry":"kth_max","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/sort.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/sort.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a6812e5985bf3ded"}},{"code_sha256_prefix":"77cffc40a307b80e","entry":"kth_min","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/sort.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/sort.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"77cffc40a307b80e"}},{"code_sha256_prefix":"958e24c12077e856","entry":"scale_features","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/loaders.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/loaders.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"958e24c12077e856"}},{"code_sha256_prefix":"15c1c346ada9be53","entry":"squared_distance","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/nn_only/substitute.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/nn_only/substitute.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"15c1c346ada9be53"}},{"code_sha256_prefix":"376003dac6efabed","entry":"top_k_min_indices","repo":"wangwllu/knn_robustness","repo_kind":"listed","path":"knn_robustness/utils/sort.py","file_url":"https://github.com/wangwllu/knn_robustness/blob/HEAD/knn_robustness/utils/sort.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"376003dac6efabed"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}