You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by vectorijk <gi...@git.apache.org> on 2015/10/01 01:10:43 UTC

[GitHub] spark pull request: [SPARK-10688][ML][PySpark] Python API for AFTS...

Github user vectorijk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8926#discussion_r40864215
  
    --- Diff: python/pyspark/ml/regression.py ---
    @@ -609,6 +611,150 @@ class GBTRegressionModel(TreeEnsembleModels):
         """
     
     
    +@inherit_doc
    +class AFTSurvivalRegression(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol,
    +                            HasFitIntercept, HasMaxIter, HasTol):
    +    """
    +    Accelerated Failure Time (AFT) Model Survival Regression
    +
    +    Fit a parametric AFT survival regression model based on the Weibull distribution
    +    of the survival time.
    +
    +    .. seealso:: `AFT Model <https://en.wikipedia.org/wiki/Accelerated_failure_time_model>`_
    +
    +    >>> from pyspark.mllib.linalg import Vectors
    +    >>> df = sqlContext.createDataFrame([
    +    ...     (1.0, Vectors.dense(1.0), 1.0),
    +    ...     (0.0, Vectors.sparse(1, [], []), 0.0)], ["label", "features", "censor"])
    +    >>> aftsr = AFTSurvivalRegression()
    +    >>> model = aftsr.fit(df)
    +    >>> model.transform(df).show()
    +    +-----+---------+------+----------+
    +    |label| features|censor|prediction|
    +    +-----+---------+------+----------+
    +    |  1.0|    [1.0]|   1.0|       1.0|
    +    |  0.0|(1,[],[])|   0.0|       1.0|
    +    +-----+---------+------+----------+
    +    ...
    +
    +    .. versionadded:: 1.6.0
    +    """
    +
    +    # a placeholder to make it appear in the generated doc
    +    censorCol = Param(Params._dummy(), "censorCol",
    +                      "censor column name. The value of this column could be 0 or 1. " +
    +                      "If the value is 1, it means the event has occurred i.e. " +
    +                      "uncensored; otherwise censored.")
    +    quantileProbabilities = \
    +        Param(Params._dummy(), "quantileProbabilities",
    +              "quantile probabilities array. Values of the quantile probabilities array " +
    +              "should be in the range [0, 1] and the array should be non-empty.")
    +    quantilesCol = Param(Params._dummy(), "quantilesCol",
    +                         "quantiles column name. This column will output quantiles of " +
    +                         "corresponding quantileProbabilities if it is set.")
    +
    +    @keyword_only
    +    def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction",
    +                 fitIntercept=True, maxIter=100, tol=1E-6, censorCol="censor",
    +                 quantileProbabilities=None, quantilesCol=None):
    +        """
    +        __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \
    +                 fitIntercept=True, maxIter=100, tol=1E-6, censorCol="censor", \
    +                 quantileProbabilities=[0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99], \
    +                 quantilesCol=None):
    +        """
    +        super(AFTSurvivalRegression, self).__init__()
    +        self._java_obj = self._new_java_obj(
    +            "org.apache.spark.ml.regression.AFTSurvivalRegression", self.uid)
    +        #: Param for censor column name
    +        self.censorCol = Param(self,  "censorCol",
    +                               "censor column name. The value of this column could be 0 or 1. " +
    +                               "If the value is 1, it means the event has occurred i.e. " +
    +                               "uncensored; otherwise censored.")
    +        #: Param for quantile probabilities array
    +        self.quantileProbabilities = \
    +            Param(self, "quantileProbabilities",
    +                  "quantile probabilities array. Values of the quantile probabilities array " +
    +                  "should be in the range [0, 1] and the array should be non-empty.")
    +        #: Param for quantiles column name
    +        self.quantilesCol = Param(self, "quantilesCol",
    +                                  "quantiles column name. This column will output quantiles of " +
    +                                  "corresponding quantileProbabilities if it is set.")
    +        self._setDefault(censorCol="censor",
    +                         quantileProbabilities=[0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99])
    +        kwargs = self.__init__._input_kwargs
    +        self.setParams(**kwargs)
    +
    +    @keyword_only
    +    @since("1.6.0")
    +    def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction",
    +                  fitIntercept=True, maxIter=100, tol=1E-6, censorCol="censor",
    +                  quantileProbabilities=None, quantilesCol=None):
    +        """
    +        setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \
    +                  fitIntercept=True, maxIter=100, tol=1E-6, censorCol="censor", \
    +                  quantileProbabilities=[0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99], \
    +                  quantilesCol=None):
    +        """
    +        kwargs = self.__init__._input_kwargs
    --- End diff --
    
    @mengxr @yanboliang changed that.
    Plus, I added two methods in AFTSurvivalRegressionModel.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org