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

   ### What changes were proposed in this pull request?
   
   This completes four native classification families of the Python binding 
(`pyspark.ml.connect.classification`) to the `pyspark.ml` 4.3.0 API, on the 
PyO3 base of #681: NaiveBayes, MultilayerPerceptron, FM and OneVsRest. The code 
is in the families' files under `crates/pyspark-rs/src/ml/classification_api/` 
and their estimators' regions of `crates/pyspark-rs/src/ml.rs`.
   
   - **NaiveBayes / NaiveBayesModel**:
     - the estimator is a `native_pymethods!` class with PySpark's Params API, 
`copy`, persistence, `fitMultiple` and all of its setters;
     - the model has `pi`, `theta`, `sigma`, `numClasses`, `numFeatures`, 
`predict`, `predictRaw` and `predictProbability` of a vector, the model 
setters, and save and load;
     - as in PySpark, it has no training summary.
   - **MultilayerPerceptronClassifier / FMClassifier and their models**:
     - MLP has `weights`; FM has `factors`, `linear` and `intercept`;
     - both have the prediction and classification members and `evaluate`;
     - `summary()` returns the training summary made at the fit (a method, as 
in PySpark 4.3.0), with every member of PySpark's summary classes. FM's 
summaries are binary, with the ROC, PR and by-threshold DataFrames.
   - **OneVsRest / OneVsRestModel**:
     - OneVsRest is a Params class of PySpark's: its `clear` removes a value, 
as PySpark's pure-Python OneVsRest does, and its `classifier` param holds the 
estimator object.
     - Its fit returns the typed `OneVsRestModel`, whose `models` are each 
class's typed submodel, made by the fit: the classifier's uid, its params with 
labelCol `mc2b$<i>`, and the binary training set as the summary dataset.
     - Typed submodels: LogisticRegression (whose fit reads `numClasses` as 
PySpark's does), LinearSVC, NaiveBayes, FM and MLP. The tree classifiers' 
submodels stay generic until their typed classes land.
     - OneVsRest persistence is not in this PR. PySpark writes it with 
client-side writers, which come in a follow-up on the persistence base of the 
native Pipeline.
   - **Tests**:
     - `python/tests/_misc_api_cases.py` holds the cases of the Params API, the 
models, summaries, evaluations, transforms, persistence and the OneVsRest 
submodels. `tests/golden/misc_api_cases.json` holds their results on official 
PySpark 4.3.0, from `scripts/capture_misc_api_cases_golden.py`.
     - `test_misc_api_offline.py` and `test_misc_api_e2e.py` run the cases on 
the native classes and compare with the golden. The classes are in `FULL` of 
`test_ml_api_offline.py`.
     - The DataFrame cases with floats round them to 9 digits, as the recorder 
rounds a float, against the platforms' last-bit drift.
   
   `docs/compatibility.md` describes the four families. One request difference 
remains, and it's documented. For a OneVsRest of LogisticRegression, PySpark 
reads each submodel's `numClasses` right after that class's fit. This client 
sends the same reads after all the class fits.
   
   ### Why are the changes needed?
   
   Before this PR, the native classes of these families fit and transformed but 
returned the common `MLModel`, without model members, summaries or typed 
OneVsRest submodels. This is part of completing the native ML classes before 
the 4.3.0 release.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, in the Python binding. The native NaiveBayes, MultilayerPerceptron, FM 
and OneVsRest classes and their models and summaries now have the API of 
`pyspark.ml`'s.
   
   ### How was this patch tested?
   
   - The new cases pass on the native classes and on official PySpark 4.3.0, 
offline and live. The golden is captured on official, and two captures are 
identical.
   - The offline Python suite of the coverage job passes, and so do the live ML 
suites against a Spark 4.3.0 Connect server.
   - `cargo fmt --check`, `cargo +1.100.0 clippy --workspace --all-targets -- 
-D warnings` 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