Skip to content

Commit d3b1766

Browse files
committed
Implement IntArrayParam
1 parent 0be142d commit d3b1766

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mllib/src/main/scala/org/apache/spark/ml/param/params.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,22 @@ class DoubleArrayParam(parent: Params, name: String, doc: String, isValid: Array
295295
w(value.asScala.map(_.asInstanceOf[Double]).toArray)
296296
}
297297

298+
/**
299+
* :: DeveloperApi ::
300+
* Specialized version of [[Param[Array[Int]]]] for Java.
301+
*/
302+
@DeveloperApi
303+
class IntArrayParam(parent: Params, name: String, doc: String, isValid: Array[Int] => Boolean)
304+
extends Param[Array[Int]](parent, name, doc, isValid) {
305+
306+
def this(parent: Params, name: String, doc: String) =
307+
this(parent, name, doc, ParamValidators.alwaysTrue)
308+
309+
/** Creates a param pair with a [[java.util.List]] of values (for Java and Python). */
310+
def w(value: java.util.List[java.lang.Integer]): ParamPair[Array[Int]] =
311+
w(value.asScala.map(_.asInstanceOf[Int]).toArray)
312+
}
313+
298314
/**
299315
* :: Experimental ::
300316
* A param and its value.

0 commit comments

Comments
 (0)