pu-toolbox 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. pu_toolbox-1.0.0/.github/pull_request_template.md +37 -0
  2. pu_toolbox-1.0.0/.github/workflows/nightly.yml +44 -0
  3. pu_toolbox-1.0.0/.github/workflows/tests.yml +125 -0
  4. pu_toolbox-1.0.0/.gitignore +67 -0
  5. pu_toolbox-1.0.0/.python-version +1 -0
  6. pu_toolbox-1.0.0/CONTRIBUTING.md +125 -0
  7. pu_toolbox-1.0.0/LICENSE +21 -0
  8. pu_toolbox-1.0.0/PKG-INFO +186 -0
  9. pu_toolbox-1.0.0/README.md +123 -0
  10. pu_toolbox-1.0.0/benchmarks/__init__.py +1 -0
  11. pu_toolbox-1.0.0/benchmarks/_common.py +16 -0
  12. pu_toolbox-1.0.0/benchmarks/assigned_methods/README.md +244 -0
  13. pu_toolbox-1.0.0/benchmarks/assigned_methods/__init__.py +5 -0
  14. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/clean_room_multiseed.json +72 -0
  15. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/official/class_prior_estimation.json +34 -0
  16. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/official/dist_pu.json +67 -0
  17. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/official/lbe.json +50 -0
  18. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/official/pusb.json +86 -0
  19. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/official/recpe.json +62 -0
  20. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/official_sources.lock.json +45 -0
  21. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/pusb_official_data_feasible_multiseed.json +50 -0
  22. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/pusb_official_data_smoke.json +48 -0
  23. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/pusb_table2_datasets.json +138 -0
  24. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/pusb_table2_released_compatibility.json +44 -0
  25. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/pusb_table2_strict.json +45 -0
  26. pu_toolbox-1.0.0/benchmarks/assigned_methods/configs/scar_sar_comparison.json +42 -0
  27. pu_toolbox-1.0.0/benchmarks/assigned_methods/preflight_paper.py +280 -0
  28. pu_toolbox-1.0.0/benchmarks/assigned_methods/pusb_official_data.py +514 -0
  29. pu_toolbox-1.0.0/benchmarks/assigned_methods/pusb_table2_aggregate.py +183 -0
  30. pu_toolbox-1.0.0/benchmarks/assigned_methods/pusb_table2_benchmark.py +428 -0
  31. pu_toolbox-1.0.0/benchmarks/assigned_methods/pusb_table2_data.py +300 -0
  32. pu_toolbox-1.0.0/benchmarks/assigned_methods/pusb_table2_parallel.py +172 -0
  33. pu_toolbox-1.0.0/benchmarks/assigned_methods/pusb_table2_report.py +304 -0
  34. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/clean_room_multiseed/resolved_config.json +78 -0
  35. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/clean_room_multiseed/run_manifest.json +34 -0
  36. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/clean_room_multiseed/summary.csv +53 -0
  37. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/clean_room_multiseed/trials.csv +26 -0
  38. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/official_preflight/current_node.json +157 -0
  39. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_feasible_multiseed/resolved_config.json +79 -0
  40. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_feasible_multiseed/run_manifest.json +37 -0
  41. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_feasible_multiseed/summary.csv +4 -0
  42. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_feasible_multiseed/trials.csv +10 -0
  43. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_smoke/resolved_config.json +66 -0
  44. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_smoke/run_manifest.json +35 -0
  45. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_smoke/summary.csv +2 -0
  46. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_official_data_smoke/trials.csv +2 -0
  47. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_data_audit/current_node.json +861 -0
  48. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/REPORT.md +80 -0
  49. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/aggregation_manifest.json +332 -0
  50. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/benchmark_report.json +71 -0
  51. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/resolved_config.json +80 -0
  52. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/statistical_summary.csv +46 -0
  53. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/summary.csv +46 -0
  54. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_full/trials.csv +4501 -0
  55. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_plan/excluded_cells.csv +28 -0
  56. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_plan/execution_scope.json +4 -0
  57. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_plan/plan_manifest.json +138 -0
  58. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_plan/resolved_config.json +80 -0
  59. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/pusb_table2_strict_plan/trial_plan.csv +7201 -0
  60. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/scar_sar_comparison/resolved_config.json +57 -0
  61. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/scar_sar_comparison/run_manifest.json +30 -0
  62. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/scar_sar_comparison/summary.csv +90 -0
  63. pu_toolbox-1.0.0/benchmarks/assigned_methods/results/scar_sar_comparison/trials.csv +61 -0
  64. pu_toolbox-1.0.0/benchmarks/assigned_methods/run.py +27 -0
  65. pu_toolbox-1.0.0/benchmarks/assigned_methods/runner.py +457 -0
  66. pu_toolbox-1.0.0/benchmarks/deep_pu/README.md +139 -0
  67. pu_toolbox-1.0.0/benchmarks/deep_pu/__init__.py +1 -0
  68. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/clean_room_multiseed.json +73 -0
  69. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official/dgpu.json +41 -0
  70. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official/infomax_pu.json +56 -0
  71. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official/weighted_contrastive_pu.json +45 -0
  72. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official_data_infomax_fashion_protocol.json +78 -0
  73. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official_data_smoke_fashion_mnist.json +39 -0
  74. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official_data_wconpu_cifar10_protocol.json +87 -0
  75. pu_toolbox-1.0.0/benchmarks/deep_pu/configs/official_sources.lock.json +32 -0
  76. pu_toolbox-1.0.0/benchmarks/deep_pu/official_data.py +803 -0
  77. pu_toolbox-1.0.0/benchmarks/deep_pu/preflight_paper.py +91 -0
  78. pu_toolbox-1.0.0/benchmarks/deep_pu/run.py +27 -0
  79. pu_toolbox-1.0.0/benchmarks/deep_pu/run_official_data.py +49 -0
  80. pu_toolbox-1.0.0/benchmarks/deep_pu/runner.py +412 -0
  81. pu_toolbox-1.0.0/docs/README.md +50 -0
  82. pu_toolbox-1.0.0/docs/dev/architecture.md +303 -0
  83. pu_toolbox-1.0.0/docs/dev/architecture_audit.md +188 -0
  84. pu_toolbox-1.0.0/docs/dev/compatibility.md +67 -0
  85. pu_toolbox-1.0.0/docs/dev/project_structure.md +375 -0
  86. pu_toolbox-1.0.0/docs/dev/resources.md +61 -0
  87. pu_toolbox-1.0.0/docs/dev/roadmap.md +43 -0
  88. pu_toolbox-1.0.0/docs/project_management/cli_design.md +118 -0
  89. pu_toolbox-1.0.0/docs/project_management/decision_log.md +20 -0
  90. pu_toolbox-1.0.0/docs/project_management/process_checklist.md +90 -0
  91. pu_toolbox-1.0.0/docs/research/method_cards/Convex_Formulation_for_PU_DATA_Learning.md +765 -0
  92. pu_toolbox-1.0.0/docs/research/method_cards/DGPU.md +427 -0
  93. pu_toolbox-1.0.0/docs/research/method_cards/Dist-PU.md +369 -0
  94. pu_toolbox-1.0.0/docs/research/method_cards/Elkan_Noto.md +325 -0
  95. pu_toolbox-1.0.0/docs/research/method_cards/InfoMax-PU.md +395 -0
  96. pu_toolbox-1.0.0/docs/research/method_cards/KLDCE.md +471 -0
  97. pu_toolbox-1.0.0/docs/research/method_cards/Kernel_Mean_Class_Prior.md +182 -0
  98. pu_toolbox-1.0.0/docs/research/method_cards/LBE.md +374 -0
  99. pu_toolbox-1.0.0/docs/research/method_cards/LDCE.md +447 -0
  100. pu_toolbox-1.0.0/docs/research/method_cards/LLSVM.md +235 -0
  101. pu_toolbox-1.0.0/docs/research/method_cards/PNU.md +301 -0
  102. pu_toolbox-1.0.0/docs/research/method_cards/PUSB.md +475 -0
  103. pu_toolbox-1.0.0/docs/research/method_cards/ReCPE.md +394 -0
  104. pu_toolbox-1.0.0/docs/research/method_cards/Self-PU.md +629 -0
  105. pu_toolbox-1.0.0/docs/research/method_cards/WConPU.md +430 -0
  106. pu_toolbox-1.0.0/docs/research/method_cards/class_prior_estimation.md +391 -0
  107. pu_toolbox-1.0.0/docs/research/method_cards/nnpu.md +584 -0
  108. pu_toolbox-1.0.0/docs/user/README.md +26 -0
  109. pu_toolbox-1.0.0/docs/user/concepts/method_selection.md +103 -0
  110. pu_toolbox-1.0.0/docs/user/concepts/pu_problem.md +62 -0
  111. pu_toolbox-1.0.0/docs/user/concepts/scar_sar.md +48 -0
  112. pu_toolbox-1.0.0/docs/user/howto/cli.md +85 -0
  113. pu_toolbox-1.0.0/docs/user/howto/data_profiling.md +102 -0
  114. pu_toolbox-1.0.0/docs/user/howto/diagnostic_reports.md +143 -0
  115. pu_toolbox-1.0.0/docs/user/howto/pipeline.md +120 -0
  116. pu_toolbox-1.0.0/docs/user/howto/sar_simulation.md +116 -0
  117. pu_toolbox-1.0.0/docs/user/howto/self_pu.md +118 -0
  118. pu_toolbox-1.0.0/docs/user/howto/sensitivity_analysis.md +67 -0
  119. pu_toolbox-1.0.0/docs/user/quickstart.md +45 -0
  120. pu_toolbox-1.0.0/docs/user/reference/api.md +351 -0
  121. pu_toolbox-1.0.0/examples/minimal/01_elkan_noto.py +27 -0
  122. pu_toolbox-1.0.0/examples/minimal/02_upu.py +28 -0
  123. pu_toolbox-1.0.0/examples/minimal/03_nnpu.py +29 -0
  124. pu_toolbox-1.0.0/examples/minimal/04_pnu.py +29 -0
  125. pu_toolbox-1.0.0/examples/minimal/05_recpe_pipeline.py +34 -0
  126. pu_toolbox-1.0.0/examples/minimal/06_sar_simulation.py +35 -0
  127. pu_toolbox-1.0.0/examples/minimal/07_data_profiling.py +34 -0
  128. pu_toolbox-1.0.0/examples/minimal/08_diagnostic_report.py +46 -0
  129. pu_toolbox-1.0.0/examples/minimal/09_sensitivity_analysis.py +43 -0
  130. pu_toolbox-1.0.0/examples/minimal/10_self_pu.py +51 -0
  131. pu_toolbox-1.0.0/pu_toolbox/__init__.py +56 -0
  132. pu_toolbox-1.0.0/pu_toolbox/advisor/__init__.py +17 -0
  133. pu_toolbox-1.0.0/pu_toolbox/advisor/_types.py +130 -0
  134. pu_toolbox-1.0.0/pu_toolbox/advisor/recommender.py +195 -0
  135. pu_toolbox-1.0.0/pu_toolbox/advisor/rules.py +349 -0
  136. pu_toolbox-1.0.0/pu_toolbox/cli/__init__.py +52 -0
  137. pu_toolbox-1.0.0/pu_toolbox/cli/demo.py +62 -0
  138. pu_toolbox-1.0.0/pu_toolbox/cli/info.py +89 -0
  139. pu_toolbox-1.0.0/pu_toolbox/cli/run.py +198 -0
  140. pu_toolbox-1.0.0/pu_toolbox/core/__init__.py +46 -0
  141. pu_toolbox-1.0.0/pu_toolbox/core/base.py +320 -0
  142. pu_toolbox-1.0.0/pu_toolbox/core/config.py +19 -0
  143. pu_toolbox-1.0.0/pu_toolbox/core/exceptions.py +32 -0
  144. pu_toolbox-1.0.0/pu_toolbox/core/labels.py +185 -0
  145. pu_toolbox-1.0.0/pu_toolbox/core/random.py +44 -0
  146. pu_toolbox-1.0.0/pu_toolbox/core/tags.py +118 -0
  147. pu_toolbox-1.0.0/pu_toolbox/core/validation.py +327 -0
  148. pu_toolbox-1.0.0/pu_toolbox/diagnostics/__init__.py +29 -0
  149. pu_toolbox-1.0.0/pu_toolbox/diagnostics/report.py +522 -0
  150. pu_toolbox-1.0.0/pu_toolbox/diagnostics/sensitivity.py +340 -0
  151. pu_toolbox-1.0.0/pu_toolbox/estimators/__init__.py +0 -0
  152. pu_toolbox-1.0.0/pu_toolbox/estimators/bias_aware/__init__.py +5 -0
  153. pu_toolbox-1.0.0/pu_toolbox/estimators/bias_aware/lbe.py +117 -0
  154. pu_toolbox-1.0.0/pu_toolbox/estimators/bias_aware/pusb.py +75 -0
  155. pu_toolbox-1.0.0/pu_toolbox/estimators/bias_aware/pusb_kernel.py +295 -0
  156. pu_toolbox-1.0.0/pu_toolbox/estimators/classic/__init__.py +4 -0
  157. pu_toolbox-1.0.0/pu_toolbox/estimators/classic/elkan_noto.py +450 -0
  158. pu_toolbox-1.0.0/pu_toolbox/estimators/classic/llsvm.py +335 -0
  159. pu_toolbox-1.0.0/pu_toolbox/estimators/deep/__init__.py +17 -0
  160. pu_toolbox-1.0.0/pu_toolbox/estimators/deep/dgpu.py +417 -0
  161. pu_toolbox-1.0.0/pu_toolbox/estimators/deep/infomax_pu.py +483 -0
  162. pu_toolbox-1.0.0/pu_toolbox/estimators/deep/self_pu.py +837 -0
  163. pu_toolbox-1.0.0/pu_toolbox/estimators/deep/vision.py +209 -0
  164. pu_toolbox-1.0.0/pu_toolbox/estimators/deep/weighted_contrastive_pu.py +443 -0
  165. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/__init__.py +17 -0
  166. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/_class_prior.py +41 -0
  167. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/dist_pu.py +147 -0
  168. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/kldce.py +1093 -0
  169. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/ldce.py +563 -0
  170. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/nnpu.py +552 -0
  171. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/pnu.py +320 -0
  172. pu_toolbox-1.0.0/pu_toolbox/estimators/risk/upu.py +494 -0
  173. pu_toolbox-1.0.0/pu_toolbox/losses/__init__.py +19 -0
  174. pu_toolbox-1.0.0/pu_toolbox/losses/llsvm.py +127 -0
  175. pu_toolbox-1.0.0/pu_toolbox/losses/nnpu.py +252 -0
  176. pu_toolbox-1.0.0/pu_toolbox/losses/pnu.py +102 -0
  177. pu_toolbox-1.0.0/pu_toolbox/losses/upu.py +150 -0
  178. pu_toolbox-1.0.0/pu_toolbox/metrics/__init__.py +19 -0
  179. pu_toolbox-1.0.0/pu_toolbox/metrics/classification.py +219 -0
  180. pu_toolbox-1.0.0/pu_toolbox/model_selection/__init__.py +6 -0
  181. pu_toolbox-1.0.0/pu_toolbox/model_selection/split.py +123 -0
  182. pu_toolbox-1.0.0/pu_toolbox/preprocessing/__init__.py +85 -0
  183. pu_toolbox-1.0.0/pu_toolbox/preprocessing/data_profiler.py +481 -0
  184. pu_toolbox-1.0.0/pu_toolbox/preprocessing/profiling.py +351 -0
  185. pu_toolbox-1.0.0/pu_toolbox/preprocessing/pu_labeling.py +410 -0
  186. pu_toolbox-1.0.0/pu_toolbox/preprocessing/selection_bias.py +326 -0
  187. pu_toolbox-1.0.0/pu_toolbox/prior/__init__.py +9 -0
  188. pu_toolbox-1.0.0/pu_toolbox/prior/kernel_mean.py +263 -0
  189. pu_toolbox-1.0.0/pu_toolbox/prior/pen_l1.py +87 -0
  190. pu_toolbox-1.0.0/pu_toolbox/prior/recpe.py +171 -0
  191. pu_toolbox-1.0.0/pu_toolbox/registry/__init__.py +47 -0
  192. pu_toolbox-1.0.0/pu_toolbox/registry/builtin_methods.py +458 -0
  193. pu_toolbox-1.0.0/pu_toolbox/registry/metadata.py +117 -0
  194. pu_toolbox-1.0.0/pu_toolbox/registry/registry.py +303 -0
  195. pu_toolbox-1.0.0/pu_toolbox/utils/__init__.py +25 -0
  196. pu_toolbox-1.0.0/pu_toolbox/utils/activations.py +16 -0
  197. pu_toolbox-1.0.0/pu_toolbox/utils/basis.py +163 -0
  198. pu_toolbox-1.0.0/pu_toolbox/utils/centroid.py +104 -0
  199. pu_toolbox-1.0.0/pu_toolbox/utils/serialization.py +65 -0
  200. pu_toolbox-1.0.0/pu_toolbox/workflows/__init__.py +14 -0
  201. pu_toolbox-1.0.0/pu_toolbox/workflows/pipeline.py +1006 -0
  202. pu_toolbox-1.0.0/pu_toolbox/workflows/report.py +260 -0
  203. pu_toolbox-1.0.0/pyproject.toml +117 -0
  204. pu_toolbox-1.0.0/requirements.txt +32 -0
  205. pu_toolbox-1.0.0/scripts/check_doc_links.py +534 -0
  206. pu_toolbox-1.0.0/scripts/check_format.py +59 -0
  207. pu_toolbox-1.0.0/scripts/check_math_rendering.py +112 -0
  208. pu_toolbox-1.0.0/scripts/check_project_metadata.py +142 -0
  209. pu_toolbox-1.0.0/scripts/check_skill_sync.py +95 -0
  210. pu_toolbox-1.0.0/scripts/check_test_quality.py +403 -0
  211. pu_toolbox-1.0.0/scripts/pu_workflow/profile.py +56 -0
  212. pu_toolbox-1.0.0/scripts/pu_workflow/recommend.py +127 -0
  213. pu_toolbox-1.0.0/scripts/pu_workflow/sensitivity.py +89 -0
  214. pu_toolbox-1.0.0/tests/__init__.py +1 -0
  215. pu_toolbox-1.0.0/tests/benchmarks/test_assigned_benchmark_runner.py +203 -0
  216. pu_toolbox-1.0.0/tests/benchmarks/test_assigned_preflight.py +131 -0
  217. pu_toolbox-1.0.0/tests/benchmarks/test_deep_pu_benchmark_runner.py +190 -0
  218. pu_toolbox-1.0.0/tests/benchmarks/test_deep_pu_model_selection.py +176 -0
  219. pu_toolbox-1.0.0/tests/benchmarks/test_deep_pu_official_data.py +329 -0
  220. pu_toolbox-1.0.0/tests/benchmarks/test_pusb_official_data.py +203 -0
  221. pu_toolbox-1.0.0/tests/benchmarks/test_pusb_table2_benchmark.py +404 -0
  222. pu_toolbox-1.0.0/tests/benchmarks/test_pusb_table2_data.py +124 -0
  223. pu_toolbox-1.0.0/tests/conftest.py +32 -0
  224. pu_toolbox-1.0.0/tests/contract/test_classifier_baseline.py +460 -0
  225. pu_toolbox-1.0.0/tests/e2e/test_e2e_quickstart.py +147 -0
  226. pu_toolbox-1.0.0/tests/e2e/test_e2e_workflow_journey.py +175 -0
  227. pu_toolbox-1.0.0/tests/e2e/test_profile_script.py +95 -0
  228. pu_toolbox-1.0.0/tests/e2e/test_recommend_script.py +140 -0
  229. pu_toolbox-1.0.0/tests/e2e/test_sensitivity_script.py +117 -0
  230. pu_toolbox-1.0.0/tests/estimators/__init__.py +0 -0
  231. pu_toolbox-1.0.0/tests/estimators/risk/__init__.py +0 -0
  232. pu_toolbox-1.0.0/tests/estimators/risk/test_class_prior.py +60 -0
  233. pu_toolbox-1.0.0/tests/estimators/risk/test_kldce_math.py +546 -0
  234. pu_toolbox-1.0.0/tests/estimators/risk/test_kldce_property.py +259 -0
  235. pu_toolbox-1.0.0/tests/estimators/risk/test_ldce_api.py +315 -0
  236. pu_toolbox-1.0.0/tests/estimators/risk/test_ldce_core.py +198 -0
  237. pu_toolbox-1.0.0/tests/estimators/risk/test_ldce_math.py +177 -0
  238. pu_toolbox-1.0.0/tests/helpers.py +18 -0
  239. pu_toolbox-1.0.0/tests/integration/test_pipeline.py +212 -0
  240. pu_toolbox-1.0.0/tests/integration/test_pipeline_deep.py +247 -0
  241. pu_toolbox-1.0.0/tests/integration/test_run.py +303 -0
  242. pu_toolbox-1.0.0/tests/test_builtin_methods.py +313 -0
  243. pu_toolbox-1.0.0/tests/test_import.py +30 -0
  244. pu_toolbox-1.0.0/tests/test_labels.py +107 -0
  245. pu_toolbox-1.0.0/tests/test_registry.py +153 -0
  246. pu_toolbox-1.0.0/tests/test_validation.py +214 -0
  247. pu_toolbox-1.0.0/tests/unit/advisor/__init__.py +0 -0
  248. pu_toolbox-1.0.0/tests/unit/advisor/test_recommender.py +210 -0
  249. pu_toolbox-1.0.0/tests/unit/advisor/test_scoring_rules.py +235 -0
  250. pu_toolbox-1.0.0/tests/unit/cli/test_cli_main.py +83 -0
  251. pu_toolbox-1.0.0/tests/unit/cli/test_demo.py +90 -0
  252. pu_toolbox-1.0.0/tests/unit/cli/test_info.py +89 -0
  253. pu_toolbox-1.0.0/tests/unit/cli/test_run_deep.py +195 -0
  254. pu_toolbox-1.0.0/tests/unit/diagnostics/test_report.py +232 -0
  255. pu_toolbox-1.0.0/tests/unit/diagnostics/test_sensitivity.py +167 -0
  256. pu_toolbox-1.0.0/tests/unit/estimators/test_bias_aware.py +82 -0
  257. pu_toolbox-1.0.0/tests/unit/estimators/test_deep_pu.py +296 -0
  258. pu_toolbox-1.0.0/tests/unit/estimators/test_deep_pu_vision.py +102 -0
  259. pu_toolbox-1.0.0/tests/unit/estimators/test_dist_pu.py +77 -0
  260. pu_toolbox-1.0.0/tests/unit/estimators/test_elkan_noto.py +288 -0
  261. pu_toolbox-1.0.0/tests/unit/estimators/test_llsvm.py +250 -0
  262. pu_toolbox-1.0.0/tests/unit/estimators/test_nnpu.py +557 -0
  263. pu_toolbox-1.0.0/tests/unit/estimators/test_pusb_kernel.py +125 -0
  264. pu_toolbox-1.0.0/tests/unit/estimators/test_self_pu.py +216 -0
  265. pu_toolbox-1.0.0/tests/unit/estimators/test_upu.py +340 -0
  266. pu_toolbox-1.0.0/tests/unit/estimators/test_vision.py +67 -0
  267. pu_toolbox-1.0.0/tests/unit/losses/test_llsvm_loss.py +235 -0
  268. pu_toolbox-1.0.0/tests/unit/losses/test_nnpu_loss.py +206 -0
  269. pu_toolbox-1.0.0/tests/unit/losses/test_pnu_loss.py +278 -0
  270. pu_toolbox-1.0.0/tests/unit/losses/test_upu_loss.py +137 -0
  271. pu_toolbox-1.0.0/tests/unit/metrics/test_classification.py +188 -0
  272. pu_toolbox-1.0.0/tests/unit/model_selection/test_split.py +113 -0
  273. pu_toolbox-1.0.0/tests/unit/preprocessing/__init__.py +0 -0
  274. pu_toolbox-1.0.0/tests/unit/preprocessing/test_data_profiler.py +189 -0
  275. pu_toolbox-1.0.0/tests/unit/preprocessing/test_profiling.py +133 -0
  276. pu_toolbox-1.0.0/tests/unit/preprocessing/test_pu_labeling.py +238 -0
  277. pu_toolbox-1.0.0/tests/unit/preprocessing/test_selection_bias.py +197 -0
  278. pu_toolbox-1.0.0/tests/unit/prior/test_kernel_mean.py +73 -0
  279. pu_toolbox-1.0.0/tests/unit/prior/test_pen_l1.py +73 -0
  280. pu_toolbox-1.0.0/tests/unit/prior/test_recpe.py +177 -0
  281. pu_toolbox-1.0.0/tests/unit/scripts/test_check_doc_links.py +189 -0
  282. pu_toolbox-1.0.0/tests/unit/scripts/test_check_format.py +61 -0
  283. pu_toolbox-1.0.0/tests/unit/scripts/test_check_math_rendering.py +45 -0
  284. pu_toolbox-1.0.0/tests/unit/scripts/test_check_skill_sync.py +111 -0
  285. pu_toolbox-1.0.0/tests/unit/scripts/test_check_test_quality_exemptions.py +162 -0
  286. pu_toolbox-1.0.0/tests/unit/test_basis_single_source.py +73 -0
@@ -0,0 +1,37 @@
1
+ ## 变更目的
2
+
3
+ <!-- 说明问题、用户影响和本 PR 的边界。 -->
4
+
5
+ ## 主要修改
6
+
7
+ <!-- 列出公共 API、算法、测试、文档或 benchmark 的关键变化。 -->
8
+
9
+ ## 验证
10
+
11
+ - [ ] `python -m pytest -q`
12
+ - [ ] `python scripts/check_format.py`(ruff check + format --check)
13
+ - [ ] `python scripts/check_test_quality.py`
14
+ - [ ] `python scripts/check_doc_links.py`
15
+ - [ ] `python scripts/check_project_metadata.py`
16
+ - [ ] `python scripts/check_math_rendering.py`
17
+ - [ ] `python scripts/check_skill_sync.py`
18
+ - [ ] `uv build`
19
+ - [ ] `git diff --check`
20
+
21
+ ## 论文与实验边界
22
+
23
+ - [ ] 不涉及论文算法或 benchmark
24
+ - [ ] 已说明 official / clean-room / paper-like 状态
25
+ - [ ] 配置、seed、数据来源和生成命令可以追溯
26
+ - [ ] 未使用测试真值选择超参数、类先验或阈值
27
+
28
+ ## 兼容性与管理
29
+
30
+ - [ ] 公共 API 和 registry metadata 已同步
31
+ - [ ] 可选依赖缺失时基础导入仍可用
32
+ - [ ] README、架构、目录结构和进度清单按需更新
33
+ - [ ] 未提交凭据、本地环境文件或无关生成产物
34
+
35
+ ## 剩余风险
36
+
37
+ <!-- 写明未覆盖的平台、依赖、数据、GPU 或复现风险。 -->
@@ -0,0 +1,44 @@
1
+ name: nightly
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "23 3 * * 1" # every Monday 03:23 UTC (off-round minute)
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ slow-tests:
13
+ name: Slow tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ matrix:
17
+ os: [ubuntu-latest, windows-latest, macos-latest]
18
+ python-version: ["3.10", "3.11", "3.12"]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v5.1.0
22
+
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v9.0.0
25
+ with:
26
+ enable-cache: true
27
+ cache-dependency-glob: pyproject.toml
28
+
29
+ - name: Set up Python ${{ matrix.python-version }}
30
+ uses: actions/setup-python@v6.3.0
31
+ with:
32
+ python-version: ${{ matrix.python-version }}
33
+
34
+ - name: Install dependencies
35
+ shell: bash
36
+ run: uv sync --python "${{ matrix.python-version }}" --extra dev --extra torch
37
+
38
+ - name: Verify matrix interpreter
39
+ shell: bash
40
+ run: uv run --python "${{ matrix.python-version }}" python -c "import sys; assert sys.version_info[:2] == tuple(map(int, '${{ matrix.python-version }}'.split('.')))"
41
+
42
+ - name: Run slow + e2e tests
43
+ shell: bash
44
+ run: uv run --python "${{ matrix.python-version }}" pytest tests/ -m "slow or e2e" -v
@@ -0,0 +1,125 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ concurrency:
13
+ group: ci-${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ tests:
18
+ name: Tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
19
+ runs-on: ${{ matrix.os }}
20
+ strategy:
21
+ matrix:
22
+ os: [ubuntu-latest, windows-latest, macos-latest]
23
+ python-version: ["3.10", "3.11", "3.12"]
24
+
25
+ steps:
26
+ - uses: actions/checkout@v5.1.0
27
+
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@v9.0.0
30
+ with:
31
+ enable-cache: true
32
+ cache-dependency-glob: pyproject.toml
33
+
34
+ - name: Set up Python ${{ matrix.python-version }}
35
+ uses: actions/setup-python@v6.3.0
36
+ with:
37
+ python-version: ${{ matrix.python-version }}
38
+
39
+ - name: Install dependencies
40
+ shell: bash
41
+ run: uv sync --python "${{ matrix.python-version }}" --extra dev --extra torch
42
+
43
+ - name: Verify matrix interpreter
44
+ shell: bash
45
+ run: uv run --python "${{ matrix.python-version }}" python -c "import sys; assert sys.version_info[:2] == tuple(map(int, '${{ matrix.python-version }}'.split('.')))"
46
+
47
+ - name: Run fast tests (unit + integration; e2e runs nightly)
48
+ shell: bash
49
+ run: uv run --python "${{ matrix.python-version }}" pytest tests/ -m "not slow and not e2e"
50
+
51
+ quality:
52
+ name: Static quality gates
53
+ runs-on: ubuntu-latest
54
+
55
+ steps:
56
+ - uses: actions/checkout@v5.1.0
57
+
58
+ - name: Install uv
59
+ uses: astral-sh/setup-uv@v9.0.0
60
+ with:
61
+ enable-cache: true
62
+ cache-dependency-glob: pyproject.toml
63
+
64
+ - name: Set up Python 3.11
65
+ uses: actions/setup-python@v6.3.0
66
+ with:
67
+ python-version: "3.11"
68
+
69
+ - name: Install development dependencies
70
+ run: uv sync --python "3.11" --extra dev
71
+
72
+ - name: Format gate (ruff check + format --check)
73
+ run: uv run --python "3.11" python scripts/check_format.py
74
+
75
+ - name: Test quality gate
76
+ run: uv run --python "3.11" python scripts/check_test_quality.py
77
+
78
+ - name: Doc consistency check
79
+ run: uv run --python "3.11" python scripts/check_doc_links.py
80
+
81
+ - name: Project metadata consistency check
82
+ run: uv run --python "3.11" python scripts/check_project_metadata.py
83
+
84
+ - name: Method card MathJax rendering check
85
+ run: uv run --python "3.11" python scripts/check_math_rendering.py
86
+
87
+ - name: Skill sync check
88
+ run: uv run --python "3.11" python scripts/check_skill_sync.py
89
+
90
+ package:
91
+ name: Build and install wheel
92
+ runs-on: ubuntu-latest
93
+
94
+ steps:
95
+ - uses: actions/checkout@v5.1.0
96
+
97
+ - name: Install uv
98
+ uses: astral-sh/setup-uv@v9.0.0
99
+ with:
100
+ enable-cache: true
101
+ cache-dependency-glob: pyproject.toml
102
+
103
+ - name: Set up Python 3.11
104
+ uses: actions/setup-python@v6.3.0
105
+ with:
106
+ python-version: "3.11"
107
+
108
+ - name: Build source and wheel distributions
109
+ run: uv build
110
+
111
+ - name: Install wheel in an isolated environment
112
+ run: |
113
+ uv venv --python "3.11" .wheel-venv
114
+ uv pip install --python .wheel-venv/bin/python dist/*.whl
115
+
116
+ - name: Smoke-test installed wheel outside the checkout
117
+ run: |
118
+ cd /tmp
119
+ "$GITHUB_WORKSPACE/.wheel-venv/bin/python" -c "import pu_toolbox; from pu_toolbox.diagnostics import build_diagnostic_report; from pu_toolbox.registry import register_all_builtin_methods, list_algorithms; register_all_builtin_methods(); assert len(list_algorithms()) > 0; assert pu_toolbox.__version__"
120
+
121
+ - name: Smoke-test console script entry point
122
+ run: |
123
+ cd /tmp
124
+ "$GITHUB_WORKSPACE/.wheel-venv/bin/pu-toolbox" list-methods >/dev/null
125
+ "$GITHUB_WORKSPACE/.wheel-venv/bin/pu-toolbox" list-priors >/dev/null
@@ -0,0 +1,67 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ *.egg
8
+ .eggs/
9
+ *.whl
10
+
11
+ # Virtual environments
12
+ .venv/
13
+ .wheel-venv/
14
+ venv/
15
+
16
+ # Local environment and credentials
17
+ .env
18
+ .env.*
19
+ !.env.example
20
+ id_rsa
21
+ id_rsa.pub
22
+ id_ed25519
23
+ id_ed25519.pub
24
+ *.pem
25
+ *.key
26
+
27
+ # IDE
28
+ .idea/
29
+ .vscode/
30
+ *.swp
31
+ *.swo
32
+ *~
33
+
34
+ # Testing
35
+ .pytest_cache/
36
+ .coverage
37
+ htmlcov/
38
+ .tox/
39
+
40
+ # OS
41
+ .DS_Store
42
+ Thumbs.db
43
+
44
+ # Jupyter
45
+ .ipynb_checkpoints/
46
+
47
+ # Project-specific Claude Code config (not for distribution)
48
+ CLAUDE.md
49
+
50
+ # UV
51
+ uv.lock
52
+ .claude/*
53
+ !.claude/skills/
54
+ !.claude/skills/pu-workflow/
55
+ .claude/skills/dev-workflow/
56
+
57
+ # CLI demo / run artifacts (intermediate outputs)
58
+ demo_data/
59
+ results*/
60
+ !benchmarks/assigned_methods/results/
61
+ !benchmarks/assigned_methods/results/**
62
+
63
+ # Local one-off plans (never for distribution)
64
+ .superpowers/
65
+
66
+ # 本地开发参考(不共享远程)
67
+ docs/superpowers/
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,125 @@
1
+ # Contributing
2
+
3
+ 本文档定义 PU Learning Toolbox 的代码、论文方法、benchmark 和项目状态管理流程。
4
+
5
+ ## 1. 权威来源
6
+
7
+ 发生冲突时按以下顺序处理:
8
+
9
+ 1. `pyproject.toml`:Python、运行依赖、可选依赖和工具配置。
10
+ 2. `docs/project_management/process_checklist.md`:当前任务完成状态。
11
+ 3. `docs/dev/project_structure.md`:目录结构。
12
+ 4. `docs/dev/architecture.md`:公共 API、依赖方向和数据流。
13
+ 5. `docs/dev/roadmap.md`:高层版本路线,不覆盖进度清单。
14
+ 6. `requirements.txt`:开发环境快照,仅用于问题复查,不是安装规范。
15
+
16
+ Method Card 描述论文、公式、实现边界和复现规格,但不能单独证明算法或论文复现已经完成。
17
+
18
+ ## 2. 开发环境
19
+
20
+ 项目支持 Python 3.10、3.11 和 3.12,推荐使用 3.11。
21
+
22
+ ```bash
23
+ uv venv --python 3.11
24
+ uv sync --python 3.11 --extra dev --extra torch
25
+ ```
26
+
27
+ 不使用 uv 时:
28
+
29
+ ```bash
30
+ python -m venv .venv
31
+ source .venv/bin/activate
32
+ python -m pip install -e ".[dev,torch]"
33
+ ```
34
+
35
+ 依赖策略:
36
+
37
+ - 可安装依赖只在 `pyproject.toml` 维护。
38
+ - 本项目是 library,CI 需要验证声明范围内的最新可解析依赖,因此不提交 `uv.lock`。
39
+ - `requirements.txt` 是一次开发环境的精确快照,不用于 CI,也不要与 `pyproject.toml` 手工双向同步。
40
+ - 新增仅开发期工具放入 `dev`;模型运行依赖放入对应 runtime extra。
41
+
42
+ ## 3. 分支与提交
43
+
44
+ 不要直接在 `main` 上开发。每个独立变更使用一个分支:
45
+
46
+ ```bash
47
+ git switch main
48
+ git pull --ff-only origin main
49
+ git switch -c feature/<short-name>
50
+ ```
51
+
52
+ 推荐提交前缀:`feat:`、`fix:`、`test:`、`docs:`、`ci:`、`refactor:`、`chore:`。
53
+
54
+ 一个 PR 应只处理一个清晰主题。不要混入无关重构、生成文件或本地配置;不得提交 SSH 私钥、token、`.env` 或数据访问凭据。
55
+
56
+ ## 4. 公共 API 规则
57
+
58
+ - 标签必须通过公共规范化/校验接口处理,PU 公共表示为 `{1, 0}`。
59
+ - 分类器遵循 `BasePUClassifier`;类先验估计器遵循 `BasePriorEstimator`。
60
+ - 新增方法必须登记 registry metadata,并明确 assumption、scenario、backend、source status 和 implementation status。
61
+ - 可选依赖不得让基础包导入失败;缺少依赖时应延迟导入并给出可行动错误。
62
+ - `api_only` 不得伪装成可训练实现;clean-room 核心不得标为官方数值复现。
63
+ - 破坏性 API 修改必须更新架构、示例、测试和版本说明。
64
+
65
+ ## 5. 测试与质量门禁
66
+
67
+ 提交前运行:
68
+
69
+ ```bash
70
+ python -m pytest -q
71
+ python scripts/check_format.py # ruff check + ruff format --check(全目录)
72
+ python scripts/check_test_quality.py
73
+ python scripts/check_doc_links.py
74
+ python scripts/check_project_metadata.py
75
+ python scripts/check_math_rendering.py
76
+ python scripts/check_skill_sync.py
77
+ uv build
78
+ git diff --check
79
+ ```
80
+
81
+ 测试应按风险选择 marker:
82
+
83
+ - `unit`:局部行为、参数和边界。
84
+ - `math`:手工可计算的公式 golden test。
85
+ - `property`:数学不变量。
86
+ - `contract`:所有 native estimator 共享的 API 契约。
87
+ - `paper`:依赖论文数据、源码或配置的复现实验。
88
+ - `slow`:不适合每次本地反馈的测试。
89
+
90
+ 每个普通测试文件最多 15 个测试方法,并覆盖 basic、param、edge、deterministic 全部四类(缺任一分类即门禁失败,严格模式为本地与 CI 共同默认);具体规则由 `scripts/check_test_quality.py` 执行。
91
+
92
+ ## 6. 论文方法和 benchmark
93
+
94
+ 状态必须严格区分:
95
+
96
+ - **Method Card 完成**:论文内容和接口规格已整理。
97
+ - **native/clean-room 完成**:本项目独立实现可运行,并通过代码测试。
98
+ - **paper-like 完成**:按论文规格设计实验,但可能使用替代数据或现代环境。
99
+ - **官方复现完成**:官方数据、源码/配置、历史环境和统计协议均已锁定并实际运行。
100
+
101
+ Benchmark runner、配置、来源锁和结果应一起更新。提交结果 CSV/manifest 时必须能够由仓库内配置和命令重新生成,并在 README 中说明 seed 数、数据来源和环境限制。
102
+
103
+ 禁止使用测试集真值选择类先验、阈值或超参数。合成数据中的 `y_true` 和 propensity 只用于评价或明确标记的 oracle sensitivity。
104
+
105
+ ## 7. 文档与进度
106
+
107
+ 完成任务时至少检查:
108
+
109
+ - `README.md` 的用户入口和测试数量。
110
+ - `docs/README.md` 的文档索引。
111
+ - `docs/dev/architecture.md` 的 API 和依赖方向。
112
+ - `docs/dev/project_structure.md` 的真实文件结构。
113
+ - `docs/project_management/process_checklist.md` 的勾选与发布状态。
114
+
115
+ 不要一次性把所有待办标记完成。只有代码、测试、文档和要求的实际实验都完成后才能勾选对应任务。
116
+
117
+ ## 8. Pull Request
118
+
119
+ 推送功能分支后创建 PR:
120
+
121
+ ```bash
122
+ git push -u origin feature/<short-name>
123
+ ```
124
+
125
+ PR 描述应包含问题、实现边界、验证命令、实验产物和未解决风险。CI 的 Python 矩阵、静态质量门禁及 wheel 安装冒烟全部通过后再合并。
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 shuidisjtu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECT WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: pu-toolbox
3
+ Version: 1.0.0
4
+ Summary: Positive-Unlabeled Learning Python Toolbox — sklearn-compatible
5
+ Project-URL: Repository, https://github.com/shuidisjtu/pu-learning-toolbox
6
+ Author: shuidisjtu
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 shuidisjtu
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECT WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ License-File: LICENSE
29
+ Keywords: machine-learning,positive-unlabeled,pu-learning,scikit-learn
30
+ Classifier: Development Status :: 5 - Production/Stable
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
37
+ Requires-Python: >=3.10
38
+ Requires-Dist: numpy>=1.24
39
+ Requires-Dist: pandas>=2.0
40
+ Requires-Dist: scikit-learn>=1.3
41
+ Requires-Dist: scipy>=1.10
42
+ Provides-Extra: all
43
+ Requires-Dist: densratio==0.3.0; extra == 'all'
44
+ Requires-Dist: lightning>=2.0; extra == 'all'
45
+ Requires-Dist: torch>=2.0; extra == 'all'
46
+ Requires-Dist: torchvision>=0.15; extra == 'all'
47
+ Requires-Dist: tqdm>=4.0; extra == 'all'
48
+ Provides-Extra: dev
49
+ Requires-Dist: build>=1.2; extra == 'dev'
50
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
51
+ Requires-Dist: pytest>=7.0; extra == 'dev'
52
+ Requires-Dist: ruff>=0.3; extra == 'dev'
53
+ Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'dev'
54
+ Provides-Extra: research
55
+ Requires-Dist: densratio==0.3.0; extra == 'research'
56
+ Requires-Dist: lightning>=2.0; extra == 'research'
57
+ Requires-Dist: torch>=2.0; extra == 'research'
58
+ Requires-Dist: torchvision>=0.15; extra == 'research'
59
+ Requires-Dist: tqdm>=4.0; extra == 'research'
60
+ Provides-Extra: torch
61
+ Requires-Dist: torch>=2.0; extra == 'torch'
62
+ Description-Content-Type: text/markdown
63
+
64
+ [English](README.md) | [中文](README.zh-CN.md)
65
+
66
+ # PU Learning Toolbox
67
+
68
+ **Positive-Unlabeled learning in Python** -- sklearn-compatible API, 17 research paper methods, SCAR & SAR support.
69
+
70
+ ![Python](https://img.shields.io/badge/python-%3E%3D3.10-blue)
71
+ ![Status](https://img.shields.io/badge/status-1.0.0-blue)
72
+ ![License](https://img.shields.io/badge/license-MIT-green)
73
+
74
+ ## Features
75
+
76
+ - **17 algorithms** from recent PU learning research, all native clean-room implementations ([method cards](docs/research/method_cards/))
77
+ - **sklearn-compatible API** -- `fit(X, y)` / `predict(X)` / `decision_function(X)`, works with pipelines and cross-validation
78
+ - **SCAR & SAR** -- constant and instance-dependent labeling mechanisms, with a data simulator
79
+ - **Data profiling + recommender** -- automatic quality checks, SCAR/SAR evidence, and a 7-dimension scoring recommender that picks the method for your data
80
+ - **Auditable pipeline** -- one-call `PUPipeline` (profile -> prior -> train -> PU-stratified CV -> evaluate) plus structured diagnostic reports and prior/propensity sensitivity analysis
81
+ - **CLI** -- `pu-toolbox` turns the whole pipeline into terminal commands
82
+
83
+ ## Quick Start
84
+
85
+ > **Note**: Not yet published on PyPI. Install from source.
86
+
87
+ ```bash
88
+ git clone https://github.com/shuidisjtu/pu-learning-toolbox.git
89
+ cd pu-learning-toolbox
90
+ pip install -e . # core dependencies
91
+ pip install -e ".[torch]" # + PyTorch-based methods (nnPU, Dist-PU, Self-PU, ...)
92
+ ```
93
+
94
+ ### Installation environments
95
+
96
+ Any Python interpreter >= 3.10 works: the package is a pure-Python universal
97
+ wheel with no compiled extensions, so the interpreter source does not matter.
98
+ Notes per environment:
99
+
100
+ - **venv / uv** (recommended): standard isolated environments, nothing special.
101
+ - **System Python** (python.org / Ubuntu / Homebrew): must be >= 3.10.
102
+ Ubuntu 22.04+ and Debian 12+ block `pip install` into the system environment
103
+ (PEP 668) -- create a venv instead.
104
+ - **Anaconda / Miniconda**: `pip install pu-toolbox` inside a conda env
105
+ (the package is PyPI-only; `conda install` will not find it). If you already
106
+ installed torch via conda, a plain `pip install pu-toolbox` (without the
107
+ `[torch]` extra) still enables the PyTorch-based methods -- torch is an
108
+ optional dependency loaded lazily.
109
+
110
+ ### Hello World
111
+
112
+ ```python
113
+ import numpy as np
114
+ from pu_toolbox.preprocessing import make_sar_dataset
115
+ from pu_toolbox import PUPipeline
116
+
117
+ # Synthetic PU data: some positives are labeled (1), rest are unlabeled (0)
118
+ X, y_pu, y_true, _ = make_sar_dataset(
119
+ n_samples=1000, n_features=8, class_prior=0.3, random_state=42,
120
+ )
121
+
122
+ # One call: profile -> class prior -> train -> PU-stratified CV -> evaluate
123
+ report = PUPipeline().fit_evaluate(X, y_pu, y_true=y_true)
124
+ print(report.summary())
125
+ ```
126
+
127
+ Full docs (Chinese): [docs/README.md](docs/README.md). More runnable examples: [`examples/minimal/`](examples/minimal/).
128
+
129
+ ## Command Line
130
+
131
+ The `pu-toolbox` console command wraps the full pipeline. Full guide: [`docs/user/howto/cli.md`](docs/user/howto/cli.md).
132
+
133
+ ```bash
134
+ # 1. Generate SCAR demo data (X.csv / y_pu.csv / y_true.csv)
135
+ pu-toolbox make-demo-data --out-dir demo/ --n 200 --seed 42
136
+
137
+ # 2. One-shot full pipeline run (auto mode picks the algorithm)
138
+ pu-toolbox run --data demo/X.csv --labels demo/y_pu.csv --out-dir results/
139
+
140
+ # 3. Inspect results
141
+ # results/report.md full Markdown report
142
+ # results/report.json strict JSON (no NaN), machine-readable
143
+ ```
144
+
145
+ ## Documentation
146
+
147
+ Docs are split by audience; the full index is [`docs/README.md`](docs/README.md).
148
+
149
+ | Entry | Content |
150
+ |----------|---------|
151
+ | [`docs/user/quickstart.md`](docs/user/quickstart.md) | 5-minute start (CLI + Python) |
152
+ | [`docs/user/concepts/`](docs/user/concepts/) | PU problem, SCAR/SAR, method selection |
153
+ | [`docs/user/howto/`](docs/user/howto/) | Task guides: simulation, profiling, pipeline, CLI, reports, sensitivity |
154
+ | [`docs/user/reference/api.md`](docs/user/reference/api.md) | Precise API contract |
155
+ | [`docs/dev/`](docs/dev/) | Contributor docs: architecture, structure, roadmap, compatibility |
156
+ | [`docs/research/method_cards/`](docs/research/method_cards/) | Per-paper research cards |
157
+
158
+ ## AI workflow skill
159
+
160
+ `pu-workflow` (Agent Skills open standard) drives the full PU analysis
161
+ workflow — profiling, assumption diagnosis, method recommendation,
162
+ training, and result interpretation — from natural language. Loaded
163
+ natively by Claude Code / Cursor (`.claude/skills/`) and Codex / Gemini
164
+ CLI / Windsurf (`.agents/skills/`).
165
+
166
+ ## Development
167
+
168
+ ```bash
169
+ uv run pytest tests/ -v -m "not slow and not e2e" # fast tests (e2e runs nightly)
170
+ uv run ruff check pu_toolbox/ # lint
171
+ uv run ruff format --check pu_toolbox/ # format check
172
+
173
+ # Quality gates
174
+ uv run python scripts/check_test_quality.py
175
+ uv run python scripts/check_doc_links.py
176
+ uv run python scripts/check_project_metadata.py
177
+ uv run python scripts/check_math_rendering.py
178
+ uv run python scripts/check_skill_sync.py
179
+ uv run python scripts/check_format.py # ruff check + format --check (full scope)
180
+ ```
181
+
182
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for contribution guidelines.
183
+
184
+ ## License
185
+
186
+ MIT