zhengruifeng opened a new pull request, #412:
URL: https://github.com/apache/spark-connect-rust/pull/412

   ### What changes were proposed in this pull request?
   
   Add native KMeans training and prediction for Rust callers through Spark 
Connect. Fit sends the dataset and parameters to Spark's JVM KMeans estimator; 
transform uses the returned cached model reference and existing 
session/ownership handling.
   
   Expose typed Rust setters for all 12 constructor parameters and native 
Python bindings at `pyspark.ml.connect.clustering.KMeans` and 
`pyspark.ml.connect.KMeans`. The Python constructor follows the upstream 
keyword-only parameters and defaults; setters mutate and return the estimator. 
Capture official PySpark parameter goldens, including seed integer boundaries, 
and add the live Rust test target to CI.
   
   ### Why are the changes needed?
   
   The native Rust API has classification and regression estimators but no 
clustering estimator. KMeans adds clustering with configurable initialization, 
distances, weights and solver selection using the existing ML protocol.
   
   [SPARK-61229](https://issues.apache.org/jira/browse/SPARK-61229)
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Native Rust and Python callers can fit KMeans with ML vector features 
and transform new DataFrames in the fitting session. Models, clones and 
transformed DataFrames retain the server model until the last owner is dropped. 
Invalid inputs and parameters fail during fitting.
   
   The native API added here exposes fit and DataFrame transform. 
Cluster-center access, training summaries, single-vector prediction and 
persistence are not exposed by this addition; the compatibility documentation 
records these limits. The existing vendored `pyspark.ml.clustering` API is 
unchanged. Cluster numbers are arbitrary; the tests compare membership 
independently of label permutations.
   
   ### How was this patch tested?
   
   - Five live Rust tests passed against Spark 4.3.0: held-out memberships from 
distinct training datasets, separate cached models, seeded repeatability, 
cloning/lazy execution, session isolation, weight-dependent cluster boundaries, 
three clusters, random initialization, row/block solvers, cosine distance and 
invalid data/parameters.
   - Four Python cases passed with both the native binding and official JVM 
PySpark as reference. Eleven selected native Python integration tests passed 
across KMeans, LinearRegression, LogisticRegression and LinearSVC.
   - Golden parameters match official PySpark for all 12 setters, including 
seeds on both sides of the signed 32-bit boundary. Added offline 
fitted-reference and model-metadata validation. Verified all constructor names, 
defaults and keyword-only arguments against the reference.
   - Rust: 523 library tests passed; the full run without SPARK_REMOTE passed 
802 tests, with 26 ignored (server-gated test bodies return early without a 
server). All integration targets compile with and without wasm-udf. Formatting 
and Clippy for the library and both new test targets passed.
   - Python offline suite: 1,535 passed, 8 skipped. The existing 12 core 
wrapper classes have no method-name gaps under the documented transport 
exclusions.
   - Workspace/all-target Clippy reports existing errors; comparison with the 
exact base commit found no new errors.
   - Official Connect single-node suite through the Rust transport: all 87 
files passed, 2,638 tests passed, 589 skipped, zero unexpected failures (the 
same three local-cluster exclusions used by CI).
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Codex (GPT-6)
   
   This pull request and its description were written by Isaac.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to