Repository navigation
[SPARK-61193][CONNECT] Support native LinearRegression training and prediction - #380
Open
zhengruifeng wants to merge 1 commit into
Open
zhengruifeng wants to merge 1 commit into
zhengruifeng wants to merge 1 commit into
Conversation
…rediction Fit Spark's JVM regressor through Connect and transform using the returned cached model. Add all 15 Rust parameter setters and Python bindings, matching PySpark's parameter encoding. Cover numeric predictions, weights, iterative losses, invalid data and lazy model ownership with golden and live tests. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add native
LinearRegressionand its fitted model so Rust callers can train Spark's JVM regressor and predict on new DataFrames through Spark Connect. Fit sends the dataset and parameters throughMlCommand.Fit; transform uses the returned cached model reference and the existing model ownership/session handling.Expose typed Rust setters for all 15 constructor parameters, including elastic-net regularization, instance weights, solver selection and squared-error/Huber loss. Add a Python binding under
pyspark.ml.connect.regression.LinearRegressionandpyspark.ml.connect.LinearRegression, with the reference keyword-only constructor and mutating parameter setters. Encode the two JVM integer parameters as 32-bit literals to match PySpark.Why are the changes needed?
The native Rust API currently has no linear regression estimator. This adds regression alongside LogisticRegression and LinearSVC, using the existing ML transport and RegressionEvaluator.
SPARK-61193
Does this PR introduce any user-facing change?
Yes. Rust callers and users of the native Python binding can fit a regressor with vector features and numeric labels, then transform DataFrames in its fitting session. Models, clones and lazy transformed DataFrames retain the fitted server object until their last owner is dropped. Invalid training data or parameters fail during fit.
The native API added here covers fitting and DataFrame transformation. Coefficients/intercept access, summaries, single-vector prediction and persistence are not exposed by this addition; these limits are documented. The existing vendored
pyspark.ml.regressionmodule is unchanged.How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-6)
This pull request and its description were written by Isaac.