HyukjinKwon opened a new pull request, #446: URL: https://github.com/apache/spark-connect-rust/pull/446
### What changes were proposed in this pull request? [SPARK-61324](https://issues.apache.org/jira/browse/SPARK-61324): Send the native ML list params as arrays and score the native BinaryClassificationEvaluator on rawPredictionCol, as PySpark does. - `VectorAssembler` `inputCols` and `Pipeline` `stages` are sent as an array literal of `string` elements, the encoding PySpark gives a Python list, instead of the Rust `Debug` text. Official `pyspark.ml.feature.VectorAssembler` on `x, y` gives `[[1.0, 2.0], [4.0, 5.0]]`; the native `VectorAssembler` (Rust and `pyspark.ml.connect.feature`) now gives the same. - `BinaryClassificationEvaluator` takes `rawPredictionCol` (default `rawPrediction`, the JVM default) instead of the `scoreCol` the JVM does not have. Rust: `set_raw_prediction_col` / `raw_prediction_col`. PyO3: the `rawPredictionCol=` keyword and `setRawPredictionCol`, as official names them. The scores 0.1, 0.4 (label 0) and 0.35, 0.8 (label 1) give AUC 0.75, and PR-AUC 0.7916666666666666, as official gives. - The Int params `maxIter` (LogisticRegression, LinearSVC), `aggregationDepth` (LinearSVC) and `numFolds`, `parallelism` (CrossValidator) are sent as `Integer` literals when they fit 32 bits, as PySpark sends a Python int and as the JVM `IntParam` expects. The Rust signatures do not change. - Public Rust API: `BinaryClassificationEvaluator::set_score_col` and `score_col` are removed and replaced by `set_raw_prediction_col` and `raw_prediction_col`. There is no deprecated alias, because the old name never worked: the server rejects `scoreCol` for every value. Callers in the workspace are updated. - The `e2e_coverage` checks that hid both failures with `let _ = ...` now assert the assembled vectors and the AUC. Pipeline `fit` and `transform` still fail on the server with the known `AssertionError` (the Pipeline follow-up); this PR changes only the encoding of `stages`. ### Why are the changes needed? - `VectorAssembler(inputCols=["x", "y"]).transform(df)` fails on every call, in `pyspark.ml.connect.feature` and in the Rust `VectorAssembler::set_input_cols(...).transform(...)`, with `IllegalArgumentException: Argument is not an array`. The server needs an array of strings for `inputCols`. - `BinaryClassificationEvaluator(scoreCol="rawPrediction").evaluate(df)` fails with `Param scoreCol does not exist`, so the score column cannot be chosen at all. The Rust default `prediction` was never used by the server either. ### Does this PR introduce _any_ user-facing change? Yes. `VectorAssembler` and `Pipeline` work with the server (the list params are accepted). The native `BinaryClassificationEvaluator` takes `rawPredictionCol` / `setRawPredictionCol` instead of `scoreCol` / `setScoreCol`, and its default score column is `rawPrediction`. The Rust `BinaryClassificationEvaluator::set_score_col` and `score_col` are removed (replaced by `set_raw_prediction_col` and `raw_prediction_col`). ### How was this patch tested? - `e2e_coverage::ml_estimators_and_transformers` (live): the `VectorAssembler` output is `[i, 2i]` for each row, and the evaluator AUC on `rawPrediction` is `0.75`. Both fail with the master encodings (`Argument is not an array`, `Param scoreCol does not exist`); I checked each by temporarily restoring its master encoding. - `ml::tests::list_and_int_params_use_the_jvm_literal_types` (offline, placed before `params_int_and_proto_roundtrip`): the `inputCols` and `stages` params are `Array` literals of `string` elements, and `maxIter` and `numFolds` are `Integer` literals. It fails on master. - `test_ml_connect_vector_assembler_and_evaluator_as_pyspark` in `python/tests/test_ml_e2e.py` (live, placed before `test_ml_statistics_as_pyspark`): the drop-in `VectorAssembler` and the native evaluator with `rawPredictionCol`, with the values official PySpark 4.3.0 gives (`[[1.0, 2.0], [4.0, 5.0]]`, AUC 0.75, PR-AUC 0.7916666666666666). It fails on master. - The offline tests that asserted the old encodings are updated: `linear_svc_parameters_use_the_spark_names_and_literal_types` (`Integer` for `maxIter` and `aggregationDepth`), and the `score_col` callers in `coverage_ml_extra`, `ml_coverage` and `ml_extra_golden`. - The lib tests (533 passed) and the transport crate's tests, the build of all tests (also with `RUSTFLAGS=-D warnings`), the offline Python suites (2937 passed, 8 skipped) with the rebuilt extension, the live Rust tests `e2e_coverage` (25 passed), `e2e_kmeans` (5), `ml_coverage` (1), `coverage_ml_extra` (4) and `ml_extra_golden` (13), and `tests/test_ml_e2e.py` (14 passed; the new test also under pytest 9.2) against a local Spark 4.3.0 server. ### 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]
