From 1017908205b7690dc0b0ed4753b36fab5641f7ac Mon Sep 17 00:00:00 2001 From: Rekha Joshi Date: Fri, 17 Jul 2015 20:02:05 -0700 Subject: [PATCH] [SPARK-9118] [ML] Implement IntArrayParam in mllib Implement IntArrayParam in mllib Author: Rekha Joshi Author: Joshi Closes #7481 from rekhajoshm/SPARK-9118 and squashes the following commits: d3b1766 [Joshi] Implement IntArrayParam 0be142d [Rekha Joshi] Merge pull request #3 from apache/master 106fd8e [Rekha Joshi] Merge pull request #2 from apache/master e3677c9 [Rekha Joshi] Merge pull request #1 from apache/master --- .../scala/org/apache/spark/ml/param/params.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/params.scala b/mllib/src/main/scala/org/apache/spark/ml/param/params.scala index d034d7ec6b60e..824efa5ed4b28 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/param/params.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/param/params.scala @@ -295,6 +295,22 @@ class DoubleArrayParam(parent: Params, name: String, doc: String, isValid: Array w(value.asScala.map(_.asInstanceOf[Double]).toArray) } +/** + * :: DeveloperApi :: + * Specialized version of [[Param[Array[Int]]]] for Java. + */ +@DeveloperApi +class IntArrayParam(parent: Params, name: String, doc: String, isValid: Array[Int] => Boolean) + extends Param[Array[Int]](parent, name, doc, isValid) { + + def this(parent: Params, name: String, doc: String) = + this(parent, name, doc, ParamValidators.alwaysTrue) + + /** Creates a param pair with a [[java.util.List]] of values (for Java and Python). */ + def w(value: java.util.List[java.lang.Integer]): ParamPair[Array[Int]] = + w(value.asScala.map(_.asInstanceOf[Int]).toArray) +} + /** * :: Experimental :: * A param and its value.