This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git
The following commit(s) were added to refs/heads/master by this push:
new d8d8760d [SPARK-61453][CONNECT][FOLLOWUP] Describe the seed of the
native DecisionTreeRegressor as Spark uses it
d8d8760d is described below
commit d8d8760d3b94f87923b67290caa016160777b467
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Thu Nov 12 17:02:41 2026 +0900
[SPARK-61453][CONNECT][FOLLOWUP] Describe the seed of the native
DecisionTreeRegressor as Spark uses it
### What changes were proposed in this pull request?
A follow-up of #515 (SPARK-61453), from a review of it. The Rust API docs
of `DecisionTreeRegressor` said that the seed breaks ties between equally good
splits ("set a seed to change tie-breaking", and "Random seed for breaking ties
between equally good splits" on `set_seed`). #515 took them from
`DecisionTreeClassifier`, whose docs #530 (SPARK-61477) has since corrected.
Spark has no such tie-breaking. A single decision tree (no bagging, all
features) uses its seed only to sample the rows from which it finds the split
candidates of continuous features. It samples only when the input has more rows
than `max(maxBins^2, 10000)`, and reads a smaller input whole
(`RandomForest.findSplits` and `samplesFractionForFindSplits` of Spark 4.3.0).
The struct docs and the docs of `set_seed` of `DecisionTreeRegressor` now say
that, with the words of the classifier's docs.
### Why are the changes needed?
The docs described an effect of the seed that does not exist. They also
suggested that setting the seed changes a fit, which it does not for an input
under the sample size.
### Does this PR introduce _any_ user-facing change?
No. Documentation only.
### How was this patch tested?
`cargo fmt --all -- --check` and `scripts/audit_no_stubs.sh`. Checked
against `mllib/src/main/scala/org/apache/spark/ml/tree/impl/RandomForest.scala`
of Spark v4.3.0.
### 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.
Closes #551 from HyukjinKwon/SPARK-61453-followup-seed-docs.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
crates/spark-connect/src/ml.rs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/crates/spark-connect/src/ml.rs b/crates/spark-connect/src/ml.rs
index 3d527aee..29b243a3 100644
--- a/crates/spark-connect/src/ml.rs
+++ b/crates/spark-connect/src/ml.rs
@@ -2566,9 +2566,11 @@ impl Model for RandomForestClassificationModel {
/// Decision tree regression using Spark's JVM implementation and ML vector
features.
///
-/// Supports continuous numeric labels. Unset parameters use Spark's defaults.
Without a
-/// seed, tie-breaking uses Spark's default seed (the hash of the class name),
as with
-/// PySpark, so fits are reproducible either way; set a seed to change
tie-breaking.
+/// Supports continuous numeric labels. Unset parameters use Spark's defaults.
A single tree
+/// samples its rows to find split candidates only when there are more than
+/// max(maxBins^2, 10000) rows; the seed picks that sample, or else Spark's
default seed (the
+/// hash of the class name), as with PySpark, so fits are reproducible either
way. Equal-gain
+/// splits are chosen deterministically, so the seed does not break ties.
#[derive(Debug, Clone)]
pub struct DecisionTreeRegressor {
operator: MlOperator,
@@ -2658,7 +2660,7 @@ impl DecisionTreeRegressor {
self
}
- /// Random seed for breaking ties between equally good splits.
+ /// Random seed for sampling the rows that find the split candidates, on
large inputs.
pub fn set_seed(mut self, value: i64) -> Self {
self.params = self.params.set_param_int_narrow("seed", value);
self
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]