1818package org .apache .spark .mllib .regression
1919
2020import org .apache .spark .mllib .linalg .Vector
21- import org .apache .spark .mllib .regression .MonotonicityConstraint .MonotonicityConstraint .{ Isotonic , MonotonicityConstraint }
21+ import org .apache .spark .mllib .regression .MonotonicityConstraint .MonotonicityConstraint ._
2222import org .apache .spark .rdd .RDD
2323
2424/**
@@ -31,7 +31,9 @@ object MonotonicityConstraint {
3131 object MonotonicityConstraint {
3232
3333 sealed trait MonotonicityConstraint {
34- private [regression] def holds (current : WeightedLabeledPoint , next : WeightedLabeledPoint ): Boolean
34+ private [regression] def holds (
35+ current : WeightedLabeledPoint ,
36+ next : WeightedLabeledPoint ): Boolean
3537 }
3638
3739 /**
@@ -72,7 +74,7 @@ class IsotonicRegressionModel(
7274 testData.map(predict)
7375
7476 override def predict (testData : Vector ): Double = {
75- // take the highest of data points smaller than our feature or data point with lowest feature
77+ // Take the highest of data points smaller than our feature or data point with lowest feature
7678 (predictions.head +:
7779 predictions.filter(y => y.features.toArray.head <= testData.toArray.head)).last.label
7880 }
@@ -87,7 +89,8 @@ trait IsotonicRegressionAlgorithm
8789 /**
8890 * Creates isotonic regression model with given parameters
8991 *
90- * @param predictions labels estimated using isotonic regression algorithm. Used for predictions on new data points.
92+ * @param predictions labels estimated using isotonic regression algorithm.
93+ * Used for predictions on new data points.
9194 * @param monotonicityConstraint isotonic or antitonic
9295 * @return isotonic regression model
9396 */
@@ -142,7 +145,7 @@ class PoolAdjacentViolators private [mllib]
142145 in : Array [WeightedLabeledPoint ],
143146 monotonicityConstraint : MonotonicityConstraint ): Array [WeightedLabeledPoint ] = {
144147
145- // Pools sub array within given bounds assigning weighted average value to all elements
148+ // Pools sub array within given bounds assigning weighted average value to all elements
146149 def pool (in : Array [WeightedLabeledPoint ], start : Int , end : Int ): Unit = {
147150 val poolSubArray = in.slice(start, end + 1 )
148151
@@ -159,17 +162,17 @@ class PoolAdjacentViolators private [mllib]
159162 while (i < in.length) {
160163 var j = i
161164
162- // find monotonicity violating sequence, if any
165+ // Find monotonicity violating sequence, if any
163166 while (j < in.length - 1 && ! monotonicityConstraint.holds(in(j), in(j + 1 ))) {
164167 j = j + 1
165168 }
166169
167- // if monotonicity was not violated, move to next data point
170+ // If monotonicity was not violated, move to next data point
168171 if (i == j) {
169172 i = i + 1
170173 } else {
171- // otherwise pool the violating sequence
172- // and check if pooling caused monotonicity violation in previously processed points
174+ // Otherwise pool the violating sequence
175+ // And check if pooling caused monotonicity violation in previously processed points
173176 while (i >= 0 && ! monotonicityConstraint.holds(in(i), in(i + 1 ))) {
174177 pool(in, i, j)
175178 i = i - 1
@@ -214,10 +217,11 @@ object IsotonicRegression {
214217 * Label is the dependent y value
215218 * Weight of the data point is the number of measurements. Default is 1
216219 *
217- * @param input RDD of (label, array of features, weight). Each point describes a row of the data
218- * matrix A as well as the corresponding right hand side label y
219- * and weight as number of measurements
220- * @param monotonicityConstraint
220+ * @param input RDD of (label, array of features, weight).
221+ * Each point describes a row of the data
222+ * matrix A as well as the corresponding right hand side label y
223+ * and weight as number of measurements
224+ * @param monotonicityConstraint Isotonic (increasing) or Antitonic (decreasing) sequence
221225 */
222226 def train (
223227 input : RDD [WeightedLabeledPoint ],
0 commit comments