spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yaroslav <yar...@gmail.com>
Subject Equivalent of "predict" function from LogisticRegressionWithLBFGS in OneVsRest with LogisticRegression classifier (Spark 2.0)
Date Sun, 28 Aug 2016 09:06:24 GMT
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-unsubscribe@spark.apache.org


Mime
View raw message