Hi;

 

I am trying to train and predict with the same set. I expect that accuracy
shuld be %100, am i wrong?

If i try to predict with the same set; it is failing, also it classifies
like "-1" which is not in the training set.

What is wrong with this code?

 

Code:

def main(args: Array[String]): Unit = {

    val env = ExecutionEnvironment.getExecutionEnvironment

    val training = Seq(

      new LabeledVector(1.0, new SparseVector(10, Array(0, 2, 3), Array(1.0,
1.0, 1.0))),

      new LabeledVector(1.0, new SparseVector(10, Array(0, 1, 5, 9),
Array(1.0, 1.0, 1.0, 1.0))),

      new LabeledVector(0.0, new SparseVector(10, Array(0, 2), Array(0.0,
1.0))),

      new LabeledVector(0.0, new SparseVector(10, Array(0), Array(0.0))),

      new LabeledVector(0.0, new SparseVector(10, Array(0, 2), Array(0.0,
1.0))),

      new LabeledVector(0.0, new SparseVector(10, Array(0), Array(0.0))))

 

    val trainingDS = env.fromCollection(training)

    val testingDS = env.fromCollection(training)

    val svm = new SVM().setBlocks(env.getParallelism)

    svm.fit(trainingDS)

    val predictions = svm.evaluate(testingDS.map(x => (x.vector, x.label)))

    predictions.print()

    

  }

 

Output:

(1.0,1.0)

(1.0,1.0)

(0.0,1.0)

(0.0,-1.0)

(0.0,1.0)

(0.0,-1.0)

Reply via email to