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

[SPARK-30377][ML] Make Regressors extend abstract class Regressor #27168

Closed
wants to merge 2 commits into from

Conversation

huaxingao
Copy link
Contributor

What changes were proposed in this pull request?

Make Regressors extend abstract class Regressor:

AFTSurvivalRegression extends Estimator => extends Regressor
DecisionTreeRegressor extends Predictor => extends Regressor
FMRegressor extends Predictor => extends Regressor
GBTRegressor extends Predictor => extends Regressor
RandomForestRegressor extends Predictor => extends Regressor

We will not make IsotonicRegression extend Regressor because it is tricky to handle both DoubleType and VectorType.

Why are the changes needed?

Make class hierarchy consistent for all Regressors

Does this PR introduce any user-facing change?

No

How was this patch tested?

existing tests

ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegressionModel.setPredictionCol"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setFeaturesCol"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setLabelCol"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setPredictionCol")
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing hierarchy of AFTSurvivalRegression/AFTSurvivalRegressionModelfrom extending Estimator/Model to Regressor/RegressionModel caused the following MiMa errors:

[error]  * method setFeaturesCol(java.lang.String)org.apache.spark.ml.regression.AFTSurvivalRegressionModel in class org.apache.spark.ml.regression.AFTSurvivalRegressionModel has a different result type in current version, where it is org.apache.spark.ml.PredictionModel rather than org.apache.spark.ml.regression.AFTSurvivalRegressionModel
[error]    filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegressionModel.setFeaturesCol")
[error]  * method setPredictionCol(java.lang.String)org.apache.spark.ml.regression.AFTSurvivalRegressionModel in class org.apache.spark.ml.regression.AFTSurvivalRegressionModel has a different result type in current version, where it is org.apache.spark.ml.PredictionModel rather than org.apache.spark.ml.regression.AFTSurvivalRegressionModel
[error]    filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegressionModel.setPredictionCol")
[error]  * method fit(org.apache.spark.sql.Dataset)org.apache.spark.ml.regression.AFTSurvivalRegressionModel in class org.apache.spark.ml.regression.AFTSurvivalRegression has a different result type in current version, where it is org.apache.spark.ml.Model rather than org.apache.spark.ml.regression.AFTSurvivalRegressionModel
[error]    filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.fit")
[error]  * method setFeaturesCol(java.lang.String)org.apache.spark.ml.regression.AFTSurvivalRegression in class org.apache.spark.ml.regression.AFTSurvivalRegression has a different result type in current version, where it is org.apache.spark.ml.Predictor rather than org.apache.spark.ml.regression.AFTSurvivalRegression
[error]    filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setFeaturesCol")
[error]  * method setLabelCol(java.lang.String)org.apache.spark.ml.regression.AFTSurvivalRegression in class org.apache.spark.ml.regression.AFTSurvivalRegression has a different result type in current version, where it is org.apache.spark.ml.Predictor rather than org.apache.spark.ml.regression.AFTSurvivalRegression
[error]    filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setLabelCol")
[error]  * method setPredictionCol(java.lang.String)org.apache.spark.ml.regression.AFTSurvivalRegression in class org.apache.spark.ml.regression.AFTSurvivalRegression has a different result type in current version, where it is org.apache.spark.ml.Predictor rather than org.apache.spark.ml.regression.AFTSurvivalRegression
[error]    filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setPredictionCol")

There is not any API change, though.

Changing the hierarchy of extending Predictor/PredictionModel to Regressor/RegressionModel doesn't cause MiMa problem.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah same story as last time eh, the type should be identical but it's not super obvious to Mima that this.type is the same as type T = [the model type].

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

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

Looks OK pending tests

ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegressionModel.setPredictionCol"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setFeaturesCol"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setLabelCol"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.spark.ml.regression.AFTSurvivalRegression.setPredictionCol")
)
Copy link
Member

Choose a reason for hiding this comment

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

Yeah same story as last time eh, the type should be identical but it's not super obvious to Mima that this.type is the same as type T = [the model type].

@srowen
Copy link
Member

srowen commented Jan 10, 2020

Jenkins test this please

@SparkQA
Copy link

SparkQA commented Jan 10, 2020

Test build #116499 has finished for PR 27168 at commit 66c4814.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class _AFTSurvivalRegressionParams(_JavaPredictorParams, HasMaxIter, HasTol, HasFitIntercept,
  • class AFTSurvivalRegression(JavaPredictor, _AFTSurvivalRegressionParams,
  • class AFTSurvivalRegressionModel(JavaPredictionModel, _AFTSurvivalRegressionParams,

@SparkQA
Copy link

SparkQA commented Jan 10, 2020

Test build #116502 has finished for PR 27168 at commit 66c4814.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class _AFTSurvivalRegressionParams(_JavaPredictorParams, HasMaxIter, HasTol, HasFitIntercept,
  • class AFTSurvivalRegression(JavaPredictor, _AFTSurvivalRegressionParams,
  • class AFTSurvivalRegressionModel(JavaPredictionModel, _AFTSurvivalRegressionParams,

@@ -208,8 +195,7 @@ class AFTSurvivalRegression @Since("1.6.0") (@Since("1.6.0") override val uid: S
}

@Since("2.0.0")
Copy link
Member

Choose a reason for hiding this comment

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

We change from fit to train. Strictly it is not since 2.0.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to 3.0.0. Thanks!

@SparkQA
Copy link

SparkQA commented Jan 11, 2020

Test build #116536 has finished for PR 27168 at commit c22d284.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Jan 13, 2020

Merged to master

@srowen srowen closed this in d6e28f2 Jan 13, 2020
@huaxingao
Copy link
Contributor Author

Thanks! @srowen @viirya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants