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

   > Stacked on #691: its commit is the first one here, so until #691 lands, 
review the commits after it.
   
   ### What changes were proposed in this pull request?
   
   Part of the native ML parity work. This PR builds the native clustering 
classes of `pyspark.ml.connect.clustering` on the PyO3 base of #681, which 
already converted KMeans, so that they follow PySpark 4.3.0's 
`pyspark.ml.clustering` over Spark Connect.
   
   - **Estimators**: BisectingKMeans, GaussianMixture and LDA are 
`native_pymethods!`, built from their golden params. Each has PySpark's Params 
API, the setters that PySpark has, `fitMultiple`, and a fit that returns the 
typed model.
   - **BisectingKMeansModel and GaussianMixtureModel**:
     - BisectingKMeansModel has `clusterCenters`, `computeCost` and `predict`.
     - GaussianMixtureModel has `weights`, `gaussiansDF`, `predict` and 
`predictProbability`, plus `gaussians`: PySpark's `MultivariateGaussian` of 
each collected row of `gaussiansDF`.
     - Both have their training summary, BisectingKMeansSummary and 
GaussianMixtureSummary. It is made at the fit, from the model's transform of 
the training dataset, the default `_summary_dataset`.
   - **LDA**: the fit returns a DistributedLDAModel for the em optimizer and a 
LocalLDAModel for the online one, as PySpark's `LDA._create_model` does.
     - Both have the LDA model members: `describeTopics`, `topicsMatrix`, 
`logLikelihood`, `logPerplexity`, and so on.
     - A distributed model also has `trainingLogLikelihood`, `logPrior`, 
`getCheckpointFiles`, and `toLocal`. `toLocal` returns a LocalLDAModel of the 
server's object, the same object on every call on a model, as PySpark's 
`functools.cache` does (via the base's `cached_methods`).
   - **PowerIterationClustering**: it has its uid and the Params API, and saves 
and loads as PySpark's does, as the params of the server's 
`PowerIterationClusteringWrapper` transformer.
   - **Core**: the core clustering models now build their summary dataset with 
the base's `summary_transform`.
   - **Not exported**: LDAModel, the base class of the two LDA models. The 
native classes cannot subclass yet; this is tracked with the summary 
hierarchies as a base follow-up.
   - **Docs**: the clustering sections of `docs/compatibility.md` describe what 
the native Python classes now have, in place of "the native Python model does 
not have them yet".
   - **Tests**:
     - The FULL member test of `test_ml_api_offline.py` covers the classes.
     - New live behavior cases (`_clustering_api_cases.py`, with 
`tests/golden/clustering_api_cases.json` captured from official PySpark 4.3.0 
by `scripts/capture_clustering_api_cases_golden.py`) run in 
`test_clustering_api_e2e.py`.
   
   ### Why are the changes needed?
   
   So that the native clustering classes have the API of `pyspark.ml`: the 
Params API, typed models and their members, summaries, single-vector prediction 
and persistence.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, in the native classes, which are unreleased. Their fit returns 
PySpark's typed model rather than the common `MLModel`, with its members, its 
summary and its persistence.
   
   ### How was this patch tested?
   
   All of the following runs against a Spark 4.3.0 Connect server.
   - Ours and the official `pyspark-client` 4.3.0 both pass 
`test_ml_api_offline.py` (60 passed, 11 skipped) and 
`test_clustering_api_e2e.py` (4 passed).
   - In the order of CI, `test_ml_api_e2e.py` and then 
`test_clustering_api_e2e.py`, ours passed 6, here and also merged with master 
at f3f2de5a.
   - The offline list of the coverage job passed 4718, with 19 skipped, here 
and also merged with master at f3f2de5a.
   - The Rust live tests passed: `e2e_ml_clustering_api` (4), `e2e_kmeans` (5), 
`e2e_bisecting_kmeans` (5) and `e2e_gaussian_mixture` (5).
   - Clippy (`-D warnings`), fmt and ruff are clean.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   
   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