Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/14109#discussion_r73646330
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala ---
@@ -862,27 +873,30 @@ class LinearRegressionSummary private[regression] (
* $$
* </blockquote></p>
*
- * @param coefficients The coefficients corresponding to the features.
+ * @param bcCoefficients The broadcast coefficients corresponding to the
features.
* @param labelStd The standard deviation value of the label.
* @param labelMean The mean value of the label.
* @param fitIntercept Whether to fit an intercept term.
- * @param featuresStd The standard deviation values of the features.
- * @param featuresMean The mean values of the features.
+ * @param bcFeaturesStd The broadcast standard deviation values of the
features.
+ * @param bcFeaturesMean The broadcast mean values of the features.
*/
private class LeastSquaresAggregator(
- coefficients: Vector,
+ bcCoefficients: Broadcast[Vector],
labelStd: Double,
labelMean: Double,
fitIntercept: Boolean,
- featuresStd: Array[Double],
- featuresMean: Array[Double]) extends Serializable {
+ bcFeaturesStd: Broadcast[Array[Double]],
+ bcFeaturesMean: Broadcast[Array[Double]]) extends Serializable {
private var totalCnt: Long = 0L
private var weightSum: Double = 0.0
private var lossSum = 0.0
- private val (effectiveCoefficientsArray: Array[Double], offset: Double,
dim: Int) = {
- val coefficientsArray = coefficients.toArray.clone()
+ private val dim = bcCoefficients.value.size
+ @transient private lazy val featuresStd = bcFeaturesStd.value
+ @transient private lazy val effectiveCoefAndOffset = {
--- End diff --
Oh, this is indeed obscure. I like the fact that using `@transient` will
tell those fields are not being serialized. However, this can be difficulty to
debug. How about have the documentation written in the code? Or we can do `def
initializeEffectiveCoefficientsVectorAndOffset`, and call it in the `add`
method for the first time? I don't have strong opinion about this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]