Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove unnecessary setter
  • Loading branch information
YY-OnCall committed Dec 14, 2018
commit ecef1d0629cf0c1edeb51832247ffe2ea1ee18f4
Original file line number Diff line number Diff line change
Expand Up @@ -1018,16 +1018,12 @@ class LogisticRegressionModel private[spark] (
@Since("1.6.0")
override val numFeatures: Int = coefficientMatrix.numCols

private var trainingSummary: Option[LogisticRegressionTrainingSummary] = None

/**
* Gets summary of model on training set. An exception is thrown
* if `trainingSummary == None`.
*/
@Since("1.5.0")
def summary: LogisticRegressionTrainingSummary = trainingSummary.getOrElse {
throw new SparkException("No training summary available for this LogisticRegressionModel")
}
override def summary: LogisticRegressionTrainingSummary = super.summary

/**
* Gets summary of model on training set. An exception is thrown
Expand Down Expand Up @@ -1062,18 +1058,6 @@ class LogisticRegressionModel private[spark] (
(model, model.getProbabilityCol, model.getPredictionCol)
}

private[classification] override def setSummary(
summary: Option[LogisticRegressionTrainingSummary]
): this.type = {
super.setSummary(summary)
}

/**
* Gets summary of model on training set. An exception is thrown if `trainingSummary == None`.
*/
@Since("1.5.0")
override def summary: LogisticRegressionTrainingSummary = super.summary

/**
* Evaluates the model on a test dataset.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ class BisectingKMeansModel private[ml] (
@Since("2.0.0")
override def write: MLWriter = new BisectingKMeansModel.BisectingKMeansModelWriter(this)

private[ml] override def setSummary(summary: Option[BisectingKMeansSummary]): this.type =
super.setSummary(summary)

/**
* Gets summary of model on training set. An exception is
* thrown if `trainingSummary == None`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ class GaussianMixtureModel private[ml] (
@Since("2.0.0")
override def write: MLWriter = new GaussianMixtureModel.GaussianMixtureModelWriter(this)

private[ml] override def setSummary(summary: Option[GaussianMixtureSummary]): this.type =
super.setSummary(summary)

/**
* Gets summary of model on training set. An exception is
* thrown if `trainingSummary == None`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ class KMeansModel private[ml] (
@Since("1.6.0")
override def write: GeneralMLWriter = new GeneralMLWriter(this)

private[ml] override def setSummary(summary: Option[KMeansSummary]): this.type =
super.setSummary(summary)

/**
* Gets summary of model on training set. An exception is
* thrown if `trainingSummary == None`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,6 @@ class GeneralizedLinearRegressionModel private[ml] (
output.toDF()
}

private[ml]
override def setSummary(summary: Option[GeneralizedLinearRegressionTrainingSummary]): this.type =
super.setSummary(summary)

/**
* Gets R-like summary of model on training set. An exception is
* thrown if there is no summary available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,8 @@ class LinearRegressionModel private[ml] (
private[ml] def this(uid: String, coefficients: Vector, intercept: Double) =
this(uid, coefficients, intercept, 1.0)

private var trainingSummary: Option[LinearRegressionTrainingSummary] = None

override val numFeatures: Int = coefficients.size

private[ml]
override def setSummary(summary: Option[LinearRegressionTrainingSummary]): this.type =
super.setSummary(summary)

/**
* Gets summary (e.g. residuals, mse, r-squared ) of model on training set. An exception is
* thrown if `trainingSummary == None`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ import org.apache.spark.annotation.Since
*
* @tparam T Summary instance type
*/
@Since("2.3.0")
@Since("3.0.0")
private[ml] trait HasTrainingSummary[T] {

private[ml] final var trainingSummary: Option[T] = None

/** Indicates whether a training summary exists for this model instance. */
@Since("2.3.0")
@Since("3.0.0")
def hasSummary: Boolean = trainingSummary.isDefined

/**
* Gets summary of model on training set. An exception is
* thrown if `trainingSummary == None`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: from the callers perspective they don't know what trainingSummary is. "if hasSummary is false"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more nit @hhbyyh - can we change this one too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Thanks for checking.

*/
@Since("2.3.0")
@Since("3.0.0")
def summary: T = trainingSummary.getOrElse {
throw new SparkException(
s"No training summary available for this ${this.getClass.getSimpleName}")
Expand Down