Try this:

val df = spark.createDataFrame(Seq(Vectors.dense(Array(10, 590, 190,
700))).map(Tuple1.apply)).toDF("features")

On Sun, 28 Aug 2016 at 11:06 yaroslav <yar...@gmail.com> wrote:

> Hi,
>
> We use such kind of logic for training our model
>
>     val model = new LogisticRegressionWithLBFGS()
>       .setNumClasses(3)
>       .run(train)
>
> Next, during spark streaming, we load model and apply incoming data to this
> model to get specific class, for example:
>
>    model.predict(Vectors.dense(10, 590, 190, 700))
>
> How we could achieve the same logic for OneVsRest classification:
>
>     val classifier = new LogisticRegression()
>       .setMaxIter(10)
>       .setTol(1E-6)
>       .setFitIntercept(true)
>
>     val ovr = new OneVsRest().setClassifier(classifier)
>     val model = ovr.fit(train)
>
> How call "predict" for this model with vector Vectors.dense(10, 590, 190,
> 700) and get class ?
>
> We try play with this:
>
>     val df = spark.createDataFrame(Array((10, 590, 190, 700)))
>     val pr_class = model.transform(df)
>
> but get error.
>
> Thank you.
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/Equivalent-of-predict-function-from-LogisticRegressionWithLBFGS-in-OneVsRest-with-LogisticRegression-tp27611.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: user-unsubscr...@spark.apache.org
>
>

Reply via email to