Github user yanboliang commented on a diff in the pull request: https://github.com/apache/spark/pull/8214#discussion_r39472282 --- Diff: python/pyspark/ml/regression.py --- @@ -117,6 +118,110 @@ def intercept(self): return self._call_java("intercept") +@inherit_doc +class IsotonicRegression(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, + HasWeightCol): + """ + Currently implemented using parallelized pool adjacent violators algorithm. + Only univariate (single feature) algorithm supported. + >>> from pyspark.mllib.linalg import Vectors + >>> df = sqlContext.createDataFrame([ + ... (1.0, Vectors.dense(1.0)), + ... (0.0, Vectors.sparse(1, [], []))], ["label", "features"]) + >>> ir = IsotonicRegression() + >>> model = ir.fit(df) + >>> test0 = sqlContext.createDataFrame([(Vectors.dense(-1.0),)], ["features"]) + >>> model.transform(test0).head().prediction + 0.5 + >>> model.boundaries + DenseVector([0.0, 1.0]) + """ + # a placeholder to make it appear in the generated doc + isotonic = \ + Param(Params._dummy(), "isotonic", + "whether the output sequence should be isotonic/increasing (true) or" + + "antitonic/decreasing (false)") + featureIndex = \ + Param(Params._dummy(), "featureIndex", + "The index of the feature if featuresCol is a vector column, no effect otherwise. " + + "(default 0)") + + @keyword_only + def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", + weightCol=None, istonic=False, featureIndex=0): + """ + __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", + weightCol=None, istonic=False, featureIndex=0): + """ + super(IsotonicRegression, self).__init__() + self._java_obj = self._new_java_obj( + "org.apache.spark.ml.regression.IsotonicRegression", self.uid) + self.isotonic = \ + Param(self, "isotonic", + "whether the output sequence should be isotonic/increasing (true) or" + + "antitonic/decreasing (false)") + self.featureIndex = \ + Param(self, "featureIndex", + "The index of the feature if featuresCol is a vector column, no effect " + + "otherwise. (default 0)") + self._setDefault(isotonic=False, featureIndex=0) + kwargs = self.__init__._input_kwargs + self.setParams(**kwargs) + + @keyword_only + def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", + weightCol=None, istonic=False, featureIndex=0): + """ + setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", + weightCol=None, istonic=false, featureIndex=0): + Set the params for IsotonicRegression + """ + kwargs = self.setParams._input_kwargs + return self._set(**kwargs) + + def _create_model(self, java_model): + return IsotonicRegressionModel(java_model) + + def setIsotonicParam(self, value): + """ + Sets the value of :py:attr:`isotonicParam`. + """ + self._paramMap[self.isotonicParam] = value + return self + + def getIsotonicParam(self): + """ + Gets the value of isotonicParam or its default value. + """ + return self.getOrDefault(self.isotonicParam) + + def setFeautreIndexParam(self, value): + """ + Sets the value of :py:attr:`featureIndexParam`. + """ + self._paramMap[self.featureIndexParam] = value + return self + + def getFeatureIndexParam(self): + """ + Gets the value of elasticNetParam or its default value. --- End diff -- typo: ```elasticNetParam`` -> ```featureIndex```
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org