Skip to content

[SPARK-62493][CONNECT][PYTHON] Delegate standard BisectingKMeans operations to Rust - #1001

Closed
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-bisecting-kmeans-rust
Closed

zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-bisecting-kmeans-rust

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Delegate pyspark.ml.clustering.BisectingKMeans fit, transform, prediction, cost, training summaries and persistence to the existing Rust implementation. Python keeps its setters, parameter maps, copying and subclass hooks. Changes to estimator and model parameters reach Rust as soon as the setter returns.

The standard and compatibility imports share the estimator, model and summary classes. The native computeCost method uses the original PySpark warning location so filters for pyspark.ml.clustering and the warn-once behavior still work.

Why are the changes needed?

The standard Python estimator previously built its own ML requests. This lets Spark’s existing BisectingKMeans tests exercise the same implementation as Rust callers and continues the clustering migration started with KMeans. SPARK-62493 · KMeans PR #1000

Does this PR introduce any user-facing change?

The three compatibility classes now report pyspark.ml.clustering as their public module. The standard signatures and persistence format match PySpark 4.3.0.

How was this patch tested?

  • Ran Spark 4.3.0’s official clustering, cache, pipeline and tuning suites against the Rust-backed package and a live Spark Connect server. All eight clustering tests passed. The four suites had 25 passes and four upstream pipeline skips.
  • Extended the weighted clustering test with Python ML request builders disabled. With four clusters requested and a minimum divisible cluster size of 75%, it verifies two fitted centers, summary sizes of [2, 2, 0, 0], weighted training cost of 15.0 and computeCost of 12.5. It also exercises prediction, save/load and a lazy transform after releasing the loaded model.
  • Verified both clients could load one another’s saved estimator and model and produce identical predictions, with optional Python transport dependencies blocked in the Rust-backed process. Compared public member signatures and kinds for the estimator, model and summary against official PySpark.
  • Ran the standard ML and native binding offline suites, mypy and Pyright stub tests, Rust library and live BisectingKMeans tests, release integration-test compilation with and without wasm-udf, Clippy, rustfmt, Ruff, and the vendoring, generated stub and binary license checks.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-6)

This pull request and its description were written by Isaac.

…ations to Rust

Co-authored-by: Isaac <no-reply@databricks.com>
@zhengruifeng
zhengruifeng deleted the feature/standard-bisecting-kmeans-rust branch December 1, 2026 05:16
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.

1 participant