Skip to content

【代码贡献】QKMeans 提前拒绝不可能的聚类数量 - #66

Open
tokenjunkielabs wants to merge 1 commit into
OriginQ:developfrom
woahwhattheheck:origin-cup/qkmeans-impossible-k-20260920
Open

tokenjunkielabs wants to merge 1 commit into
OriginQ:developfrom
woahwhattheheck:origin-cup/qkmeans-impossible-k-20260920

Conversation

@tokenjunkielabs

Copy link
Copy Markdown

Related to #13.

Summary

QuantumKmeans.fit() can retry forever when k > n_samples: the empty-cluster recovery path can never reach len(set(clusters)) == K, so it repeatedly reinitializes centers. This contribution rejects impossible/invalid cluster counts before any quantum-distance work while leaving valid-input algorithm behavior unchanged.

Changes

  • require k to be a positive integral value (excluding bool);
  • reject k > number_of_samples before quantum-distance execution;
  • preserve the existing QuantumKmeans class and valid-input implementation by guarding the public fit() entry point;
  • add focused regressions for zero/negative/fractional/bool k and the impossible k=3 / 2-sample case;
  • add QKmeans to the repository pytest collection list so the regression is not silently omitted.

Validation

Sponsor branch: 156c25b25fe92ae1ed0a7d40d9b1cff4b2953009, rebuilt directly on current develop@5f973efccb84bc193157d1ccebe32137e307293b; exact diff is one commit / three paths / +53/-0. The same semantic source/test payload previously completed the repository's installed-wheel PyQPanda Algorithm CI/CD Pipeline successfully on owner PR #11, run 34750195853, before merge. No sponsor-head hosted-green claim is made.

Original defect/implementation lineage: Z-Helix-94. Test-collection defect: MAL-Z57. Current-main integration: Z-Quine-913519-R8V.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants