zhengruifeng opened a new pull request, #58371:
URL: https://github.com/apache/spark/pull/58371

   ### What changes were proposed in this pull request?
   
   Generate unit tree weights on demand for random forest classification and 
regression models instead
   of retaining a lazily initialized array. Cache the generated weights locally 
while saving an
   ensemble model to avoid repeated allocation in the per-tree loop.
   
   This also removes the stale comments about possibly supporting weighted 
random forests later.
   
   ### Why are the changes needed?
   
   Random forest tree weights are rarely accessed and are not used during 
prediction. Generating the
   unit weights when requested avoids retaining an otherwise unused array for 
the lifetime of the
   model.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Random forest tree weights continue to contain one unit weight for every 
tree.
   
   ### How was this patch tested?
   
   The existing classification and regression model persistence tests were run:
   
   ```
   build/sbt 'mllib/testOnly *RandomForestClassifierSuite -- -z "read/write"'
   build/sbt 'mllib/testOnly *RandomForestRegressorSuite -- -z "read/write"'
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (GPT-5)
   


-- 
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