{"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/distributionally-robust-post-hoc-classifiers","title":"Distributionally Robust Post-hoc Classifiers under Prior Shifts","arxiv_id":"2309.08825","date":"2023-09-16","proceeding":null,"authors":["Jiaheng Wei","Harikrishna Narasimhan","Ehsan Amid","Wen-Sheng Chu","Yang Liu","Abhishek Kumar"],"abstract":"The generalization ability of machine learning models degrades significantly when the test distribution shifts away from the training distribution. We investigate the problem of training models that are robust to shifts caused by changes in the distribution of class-priors or group-priors. The presence of skewed training priors can often lead to the models overfitting to spurious features. Unlike existing methods, which optimize for either the worst or the average performance over classes or groups, our work is motivated by the need for finer control over the robustness properties of the model. We present an extremely lightweight post-hoc approach that performs scaling adjustments to predictions from a pre-trained model, with the goal of minimizing a distributionally robust loss around a chosen target distribution. These adjustments are computed by solving a constrained optimization problem on a validation set and applied to the model during test time. Our constrained optimization objective is inspired by a natural notion of robustness to controlled distribution shifts. Our method comes with provable guarantees and empirically makes a strong case for distributional robust post-hoc classifiers. An empirical implementation is available at https://github.com/weijiaheng/Drops.","url_abs":"https://arxiv.org/abs/2309.08825v1","url_pdf":"https://arxiv.org/pdf/2309.08825v1.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":"distributionally-robust-post-hoc-classifiers","repo_url":"https://github.com/weijiaheng/drops","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"tf","reach":{"status":"ok"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2309.08825","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2309.08825"}},"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":"deterministic:regex_extraction","url":"https://github.com/weijiaheng/Drops","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/weijiaheng/drops","reach":{"status":"ok"}}],"summary":{"ran":5,"ran_fixture":2,"ran_violates":1,"unverified":5},"by_repo_kind":{"official":{"samples":13,"ran":8,"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":13,"samples":[{"code_sha256_prefix":"96db750723fc8d0b","entry":"CBLoss","repo":"weijiaheng/Drops","repo_kind":"official","path":"losses_lt.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/losses_lt.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"96db750723fc8d0b"}},{"code_sha256_prefix":"92265b9bb25c6cfc","entry":"CELoss","repo":"weijiaheng/Drops","repo_kind":"official","path":"losses_lt.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/losses_lt.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"92265b9bb25c6cfc"}},{"code_sha256_prefix":"e19d0c3f75393ec1","entry":"evaluate","repo":"weijiaheng/Drops","repo_kind":"official","path":"utils.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e19d0c3f75393ec1"}},{"code_sha256_prefix":"99e0fd44f2945184","entry":"get_cls_idx","repo":"weijiaheng/drops","repo_kind":"official","path":"main_lt.py","file_url":"https://github.com/weijiaheng/drops/blob/HEAD/main_lt.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"99e0fd44f2945184"}},{"code_sha256_prefix":"5875084978e41075","entry":"get_cls_num","repo":"weijiaheng/drops","repo_kind":"official","path":"main_lt.py","file_url":"https://github.com/weijiaheng/drops/blob/HEAD/main_lt.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5875084978e41075"}},{"code_sha256_prefix":"58b9298579ed4235","entry":"get_results","repo":"weijiaheng/Drops","repo_kind":"official","path":"utils.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"58b9298579ed4235"}},{"code_sha256_prefix":"d2ae9d5fc68a3253","entry":"get_y_p","repo":"weijiaheng/Drops","repo_kind":"official","path":"utils.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d2ae9d5fc68a3253"}},{"code_sha256_prefix":"c76410a2e5a019a8","entry":"maybe_one_hot","repo":"weijiaheng/drops","repo_kind":"official","path":"drops_test_time.py","file_url":"https://github.com/weijiaheng/drops/blob/HEAD/drops_test_time.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c76410a2e5a019a8"}},{"code_sha256_prefix":"7ad316cb77932b5f","entry":"MakeLossFunc","repo":"weijiaheng/Drops","repo_kind":"official","path":"losses_lt.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/losses_lt.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7ad316cb77932b5f"}},{"code_sha256_prefix":"92a081d68735c144","entry":"MakeLossFunc","repo":"weijiaheng/Drops","repo_kind":"official","path":"losses_lt_new.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/losses_lt_new.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"92a081d68735c144"}},{"code_sha256_prefix":"6ec9e8d6c9981483","entry":"calibrate_shifts","repo":"weijiaheng/drops","repo_kind":"official","path":"drops_test_time.py","file_url":"https://github.com/weijiaheng/drops/blob/HEAD/drops_test_time.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6ec9e8d6c9981483"}},{"code_sha256_prefix":"0bf7d139457b5de7","entry":"calibrate_temp","repo":"weijiaheng/Drops","repo_kind":"official","path":"drops_test_time.py","file_url":"https://github.com/weijiaheng/Drops/blob/HEAD/drops_test_time.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0bf7d139457b5de7"}},{"code_sha256_prefix":"a85f3df5207d6bdf","entry":"ce_loss","repo":"weijiaheng/drops","repo_kind":"official","path":"drops_test_time.py","file_url":"https://github.com/weijiaheng/drops/blob/HEAD/drops_test_time.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a85f3df5207d6bdf"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}