Hi Sean,

I did not understand,
I created a KMeansModel with 3 dimensions and then I am calling predict
method on this model with a 3 dimension vector ?
I am not sre what is wrong in this approach. i am missing a point ?

Tony

On Wed, Aug 3, 2016 at 11:22 PM, Sean Owen <so...@cloudera.com> wrote:

> You declare that the vector has 3 dimensions, but then refer to its
> 4th dimension (at index 3). That is the error.
>
> On Wed, Aug 3, 2016 at 10:43 AM, Tony Lane <tonylane....@gmail.com> wrote:
> > I am using the following vector definition in java
> >
> > Vectors.sparse(3, new int[] { 1, 2, 3 }, new double[] { 1.1, 1.1, 1.1 }))
> >
> > However when I run the predict method on this vector it leads to
> >
> > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
> > at org.apache.spark.mllib.linalg.BLAS$.dot(BLAS.scala:143)
> > at org.apache.spark.mllib.linalg.BLAS$.dot(BLAS.scala:115)
> > at
> >
> org.apache.spark.mllib.util.MLUtils$.fastSquaredDistance(MLUtils.scala:298)
> > at
> >
> org.apache.spark.mllib.clustering.KMeans$.fastSquaredDistance(KMeans.scala:606)
> > at
> >
> org.apache.spark.mllib.clustering.KMeans$$anonfun$findClosest$1.apply(KMeans.scala:580)
> > at
> >
> org.apache.spark.mllib.clustering.KMeans$$anonfun$findClosest$1.apply(KMeans.scala:574)
> > at scala.collection.mutable.ArraySeq.foreach(ArraySeq.scala:74)
> > at
> org.apache.spark.mllib.clustering.KMeans$.findClosest(KMeans.scala:574)
> > at
> >
> org.apache.spark.mllib.clustering.KMeansModel.predict(KMeansModel.scala:59)
> > at org.apache.spark.ml.clustering.KMeansModel.predict(KMeans.scala:130)
>

Reply via email to