Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Minor] [ML] When trainingSummary is None, it should throw RuntimeException. #11784

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,8 @@ class LogisticRegressionModel private[spark] (
* thrown if `trainingSummary == None`.
*/
@Since("1.5.0")
def summary: LogisticRegressionTrainingSummary = trainingSummary match {
case Some(summ) => summ
case None =>
throw new SparkException(
"No training summary available for this LogisticRegressionModel",
new NullPointerException())
def summary: LogisticRegressionTrainingSummary = trainingSummary.getOrElse {
throw new SparkException("No training summary available for this LogisticRegressionModel")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,9 @@ class KMeansModel private[ml] (
* thrown if `trainingSummary == None`.
*/
@Since("2.0.0")
def summary: KMeansSummary = trainingSummary match {
case Some(summ) => summ
case None =>
throw new SparkException(
s"No training summary available for the ${this.getClass.getSimpleName}",
new NullPointerException())
def summary: KMeansSummary = trainingSummary.getOrElse {
throw new SparkException(
s"No training summary available for the ${this.getClass.getSimpleName}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,7 @@ class GeneralizedLinearRegressionModel private[ml] (
@Since("2.0.0")
def summary: GeneralizedLinearRegressionSummary = trainingSummary.getOrElse {
throw new SparkException(
"No training summary available for this GeneralizedLinearRegressionModel",
new RuntimeException())
"No training summary available for this GeneralizedLinearRegressionModel")
}

private[regression] def setSummary(summary: GeneralizedLinearRegressionSummary): this.type = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,8 @@ class LinearRegressionModel private[ml] (
* thrown if `trainingSummary == None`.
*/
@Since("1.5.0")
def summary: LinearRegressionTrainingSummary = trainingSummary match {
case Some(summ) => summ
case None =>
throw new SparkException(
"No training summary available for this LinearRegressionModel",
new NullPointerException())
def summary: LinearRegressionTrainingSummary = trainingSummary.getOrElse {
throw new SparkException("No training summary available for this LinearRegressionModel")
}

private[regression] def setSummary(summary: LinearRegressionTrainingSummary): this.type = {
Expand Down