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

   > 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 regression 
classes of `pyspark.ml.connect.regression` on the PyO3 base of #681, so that 
they follow PySpark 4.3.0's `pyspark.ml.regression` over Spark Connect.
   
   - **Estimators**: LinearRegression, GeneralizedLinearRegression, 
AFTSurvivalRegression, IsotonicRegression, FMRegressor, DecisionTreeRegressor, 
RandomForestRegressor and GBTRegressor 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.
   - **Models** (`native_model!`), with the members of PySpark's model classes:
     - the params, plus only the setters that the model class has;
     - `coefficients`/`intercept`/`scale`, `predict`, `predictQuantiles`;
     - `boundaries`/`predictions`, `linear`/`factors`;
     - the tree members: `depth`, `numNodes`, `featureImportances`, 
`toDebugString`, `predictLeaf`.
   - **Ensembles**: RandomForestRegressionModel and GBTRegressionModel also 
have `trees`, `treeWeights`, `getNumTrees` (a property), `totalNumNodes`, and 
GBT's `evaluateEachIteration`.
     - The `trees` are DecisionTreeRegressionModels. They are fetched at the 
fit and at a load, as PySpark's `_resetUid` fetches them, and a copy shares 
them.
     - The DecisionTreeRegressionModel class is its own commit here, since 
GBTClassificationModel's trees are this class too.
   - **Summaries**: LinearRegressionModel and GeneralizedLinearRegressionModel 
have their training summary, `hasSummary` and `evaluate`.
     - The training summary is made at the fit, from the training dataset, 
since both classes' `_summary_dataset` returns it.
     - The summaries are `native_summary!`s: LinearRegressionSummary, 
LinearRegressionTrainingSummary, GeneralizedLinearRegressionSummary (with 
`residuals` of a type) and GeneralizedLinearRegressionTrainingSummary.
   - **Persistence**: every estimator and model saves and loads, as PySpark's 
do.
   - **Docs**: the regression 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 behavior cases (`_regression_api_cases.py`, with 
`tests/golden/regression_api_cases.json` captured from official PySpark 4.3.0 
by `scripts/capture_regression_api_cases_golden.py`) run offline and live.
     - Two `test_ml_offline.py` tests now accept the trees Fetch that a random 
forest or gradient-boosted fit sends after its Fit, as PySpark's does.
   
   ### Why are the changes needed?
   
   So that the native regression 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 each pass 110 tests, with 17 
skipped, over `test_ml_api_offline.py`, `test_regression_api_offline.py` and 
`test_regression_api_e2e.py`.
   - In the order of CI, `test_ml_api_e2e.py` and then 
`test_regression_api_e2e.py`, ours passed 10, here and also merged with master 
at f3f2de5a.
   - The offline list of the coverage job passed 4760, with 25 skipped, here 
and also merged with master at f3f2de5a.
   - 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