HyukjinKwon opened a new pull request, #738:
URL: https://github.com/apache/spark-connect-rust/pull/738
### What changes were proposed in this pull request?
This is a follow-up of #706 (SPARK-61721) and #605 (SPARK-61612), found
while reviewing the last 50 commits. A reviewer probed the native OneVsRest
classes against official PySpark 4.3.0 and found five differences. This PR
fixes them.
1. **The transform read the wrong columns.** PySpark's
`OneVsRestModel._transform` composes the transforms of `self.models` with the
submodels' own params, and selects the model's `rawPredictionCol` from their
output. The native transform used the Rust core's composite, which used the
model's own columns:
- `m.copy().setFeaturesCol("f2").transform(df)` works on official, and
failed here with `FIELD_NOT_FOUND`;
- a model `rawPredictionCol` that the submodels don't produce fails on
official with `UNRESOLVED_COLUMN`, and succeeded here.
The native transform is dropped. Since #718 the public class is a
subclass of PySpark's, so PySpark's own `Transformer.transform` and
`OneVsRestModel._transform` now run over `models`. Through a recording proxy, a
transform now sends the same requests as official, apart from uids and
LocalRelation sizes.
2. **No constructor.** `OneVsRestModel(models)` is PySpark's public
constructor, and here it raised `cannot create ... instances`. It now makes a
model of the given models, of a new uid and the class's defaults, with no set
params, as PySpark's does.
3. **`models` wasn't assignable.** PySpark's `models` is a plain attribute
that can be assigned; here it was read-only. A copy still has copies of the
models, each with `extra`, as PySpark's `copy` does.
4. **The warning text.** The warning for a classifier without `weightCol`
now has PySpark's text: `weightCol is ignored, as it is not supported by
<classifier's str> now.`
5. **FMClassifier's weights.** PySpark passes `weightCol` to each per-class
fit when the classifier is a `HasWeightCol`. FMClassifier is one, so it now
gets the weight and no warning, as in PySpark. The perceptron is the only
classifier without it.
`docs/compatibility.md`'s OneVsRest section describes this.
### Why are the changes needed?
To match PySpark 4.3.0.
### Does this PR introduce _any_ user-facing change?
Yes, the five behaviors above. The native OneVsRest classes are new in this
release.
### How was this patch tested?
- New live cases in `python/tests/_misc_api_cases.py`:
- the transform after `setFeaturesCol`, and of a rawPredictionCol the
submodels don't produce;
- the constructor;
- the assignment of `models`;
- the warning;
- FMClassifier's weights.
Their golden in `tests/golden/misc_api_cases.json` is captured on official
PySpark 4.3.0, twice and byte-identical. It only adds 26 keys and changes none.
On a build without the change, 25 of the recorded values differ.
- On this client:
- `test_misc_api_offline.py`, `test_misc_api_e2e.py` and
`test_ml_classification_classes_e2e.py` pass;
- so does the CI-order offline suite (5669 passed);
- `test_ml_api_offline.py`'s test of the public members now counts
OneVsRestModel's `transform` as PySpark's own code of the class's own members.
- `cargo fmt --check`, `cargo +1.100.0 clippy --workspace --all-targets --
-D warnings`, `scripts/audit_no_stubs.sh`, `ruff check` and `ruff format
--check` 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]