-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-28985][PYTHON][ML][FOLLOW-UP] Add _IsotonicRegressionBase #26023
Closed
zero323
wants to merge
1
commit into
apache:master
from
zero323:SPARK-28985-FOLLOW-UP-isotonic-regression
Closed
[SPARK-28985][PYTHON][ML][FOLLOW-UP] Add _IsotonicRegressionBase #26023
zero323
wants to merge
1
commit into
apache:master
from
zero323:SPARK-28985-FOLLOW-UP-isotonic-regression
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test build #111774 has finished for PR 26023 at commit
|
LGTM |
zhengruifeng
approved these changes
Oct 4, 2019
srowen
approved these changes
Oct 4, 2019
srowen
pushed a commit
that referenced
this pull request
Oct 4, 2019
### What changes were proposed in this pull request? Adds ```python _AFTSurvivalRegressionParams(HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter, HasTol, HasFitIntercept, HasAggregationDepth): ... ``` with related Params and uses it to replace `HasFitIntercept`, `HasMaxIter`, `HasTol` and `HasAggregationDepth` in `AFTSurvivalRegression` base classes and `JavaPredictionModel,` in `AFTSurvivalRegressionModel` base classes. ### Why are the changes needed? Previous work (#25776) on [SPARK-28985](https://issues.apache.org/jira/browse/SPARK-28985) replaced `JavaEstimator`, `HasFeaturesCol`, `HasLabelCol`, `HasPredictionCol` in `AFTSurvivalRegression` and `JavaModel` in `AFTSurvivalRegressionModel` with newly added `JavaPredictor`: https://github.com/apache/spark/blob/e97b55d32285052a1f76cca35377c4b21eb2e7d7/python/pyspark/ml/wrapper.py#L377 and `JavaPredictionModel` https://github.com/apache/spark/blob/e97b55d32285052a1f76cca35377c4b21eb2e7d7/python/pyspark/ml/wrapper.py#L405 respectively. This however is inconsistent with Scala counterpart where both classes extend private `AFTSurvivalRegressionBase` https://github.com/apache/spark/blob/eb037a8180be4ab7570eda1fa9cbf3c84b92c3f7/mllib/src/main/scala/org/apache/spark/ml/regression/AFTSurvivalRegression.scala#L48-L50 This preserves some of the existing inconsistencies (variables as defined in [the official example](https://github.com/apache/spark/blob/master/examples/src/main/python/ml/aft_survival_regression.p)) ``` from pyspark.ml.regression import AFTSurvivalRegression, AFTSurvivalRegressionModel from pyspark.ml.param.shared import HasMaxIter, HasTol, HasFitIntercept, HasAggregationDepth from pyspark.ml.param import Param issubclass(AFTSurvivalRegressionModel, HasMaxIter) # False hasattr(model, "maxIter") and isinstance(model.maxIter, Param) # True issubclass(AFTSurvivalRegressionModel, HasTol) # False hasattr(model, "tol") and isinstance(model.tol, Param) # True ``` and can cause problems in the future, if Predictor / PredictionModel API changes (unlike [`IsotonicRegression`](#26023), current implementation is technically speaking correct, though incomplete). ### Does this PR introduce any user-facing change? Yes, it adds a number of base classes to `AFTSurvivalRegressionModel`. These change purely additive and have negligible potential for breaking existing code (and none, compared to changes already made in #25776). Additionally affected API hasn't been released in the current form yet. ### How was this patch tested? - Existing unit tests. - Manual testing. CC huaxingao, zhengruifeng Closes #26024 from zero323/SPARK-28985-FOLLOW-UP-aftsurival-regression. Authored-by: zero323 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
Merged to master |
Thanks @srowen, @zhengruifeng! |
zero323
added a commit
to zero323/pyspark-stubs
that referenced
this pull request
Oct 5, 2019
* Reflect changes introduced with SPARK-28985 * Add _IsotonicRegressionBase - apache/spark#26023 * Add _AFTSurvivalRegressionParams - apache/spark#26024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Adds
with related
Params
and uses it to replaceJavaPredictor
andHasWeightCol
inIsotonicRegression
base classes andJavaPredictionModel,
inIsotonicRegressionModel
base classes.Why are the changes needed?
Previous work (#25776) on SPARK-28985 replaced
JavaEstimator
,HasFeaturesCol
,HasLabelCol
,HasPredictionCol
inIsotonicRegression
andJavaModel
inIsotonicRegressionModel
with newly addedJavaPredictor
:spark/python/pyspark/ml/wrapper.py
Line 377 in e97b55d
and
JavaPredictionModel
spark/python/pyspark/ml/wrapper.py
Line 405 in e97b55d
respectively.
This however is inconsistent with Scala counterpart where both classes extend private
IsotonicRegressionBase
spark/mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala
Lines 42 to 43 in 3cb1b57
This preserves some of the existing inconsistencies (
model
as defined in the official example), i.e.as well as introduces a bug, by adding unsupported
predict
method:Furthermore existing implementation can cause further problems in the future, if
Predictor
/PredictionModel
API changes.Does this PR introduce any user-facing change?
Yes. It:
IsotonicRegressionModel.predict
method.HasWeightColumn
toIsotonicRegressionModel
.however the faulty implementation hasn't been released yet, and proposed additions have negligible potential for breaking existing code (and none, compared to changes already made in #25776).
How was this patch tested?
CC @huaxingao, @zhengruifeng