Skip to content

[SPARK-62486][CONNECT][PYTHON] Delegate standard OneVsRest operations to Rust - #999

Closed
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-one-vs-rest-rust
Closed

zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-one-vs-rest-rust

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Publish OneVsRest and OneVsRestModel through pyspark.ml.classification and re-export the same classes from the compatibility module. Python parameter mutations update their native state immediately.

A fit with a built-in binary classifier uses the Rust implementation to fit one model per class. A Python subclass, a custom classifier, or a classifier with an instance-level fit override uses PySpark's fit loop so its hook sees each binary dataset. The public model composes the transforms of its current models list. Replacing or reordering those models changes its predictions.

Why are the changes needed?

After #998, OneVsRest was the remaining classifier whose standard and compatibility imports selected different implementations. The standard path can share native class fits and persistence while continuing to support Python-defined classifiers.

Does this PR introduce any user-facing change?

The import paths now resolve to the same estimator and model. The original public signatures are preserved. On the model, models remains a mutable instance attribute and is also visible as a descriptor when inspecting the class.

The native fit respects default-only classifier and column parameters and carries the base classifier's defaults into the binary submodels. The estimator and model readers restore saved defaults using the standard PySpark metadata rules.

How was this patch tested?

  • Added live tests that disable the Python fit loop for a built-in classifier, verify the binary labels passed to subclass and instance-level fit hooks, and reverse the loaded submodels to check that predictions follow their order.
  • Ran the official Spark 4.3.0 classification, regression, model-cache and OneVsRest parity suites against this package. All 34 tests passed. All 33 selected OneVsRest interaction and error cases also passed on official PySpark.
  • Loaded estimators and models saved by each client with the other and compared predictions, raw scores, UIDs and parameter defaults. The Rust-backed process ran with Python protobuf, gRPC, Py4J and SciPy imports blocked. Python pickles of estimators and unbound model wrappers also round-tripped across clients.
  • The offline ML and typing suites passed 2,614 tests (68 skipped), including mypy and Pyright. All 131 live integration tests passed. The generated-stub and vendored-source checks and Ruff passed.
  • All 864 Rust library tests passed. Compiled all integration tests with default features and with wasm-udf. Rust formatting, workspace Clippy and the binary license check passed.

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.

… to Rust

Co-authored-by: Isaac <no-reply@databricks.com>
@zhengruifeng
zhengruifeng deleted the feature/standard-one-vs-rest-rust branch December 1, 2026 02:14
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