Hello Kursat, As noted in the documentation, the SVM implementation is for binary classification only for the time being.
Regards, Theodore -- Sent from a mobile device. May contain autocorrect errors. On Oct 13, 2016 8:53 PM, "Kürşat Kurt" <kur...@kursatkurt.com> wrote: > Hi; > > > > I am trying to classify documents. > > When i try to predict (same of training set) there is only 1 and -1 > predictions. > > Accuracy is 0%. > > > > > > Can you help me please? > > > > *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(2.0, *new* SparseVector(10, Array(0, 2), Array( > 0.0, 1.0))), > > *new* LabeledVector(2.0, *new* SparseVector(10, Array(0), Array(0.0 > ))), > > *new* LabeledVector(1.0, *new* SparseVector(10, Array(0, 3), Array( > 1.0, 1.0))), > > *new* LabeledVector(0.0, *new* SparseVector(10, Array(0, 2, 3), > Array(0.0, 1.0, 1.0))), > > *new* LabeledVector(2.0, *new* SparseVector(10, Array(0, 7, 9), > Array(0.0, 1.0))), > > *new* LabeledVector(2.0, *new* SparseVector(10, Array(2,3,4), Array( > 0.0,1.0,1.0))), > > *new* LabeledVector(2.0, *new* SparseVector(10, Array(0, 3), Array( > 1.0, 1.0))), > > *new* LabeledVector(0.0, *new* SparseVector(10, Array(2, 3,9), > Array(1.0, 0.0, 1.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(); > > > > Sample output: > > > > (1.0,1.0) > > (1.0,1.0) > > (0.0,1.0) > > (0.0,-1.0) > > (2.0,1.0) > > (2.0,-1.0) > > (1.0,1.0) > > (0.0,1.0) > > (2.0,1.0) > > (2.0,1.0) > > (2.0,1.0) > > (0.0,1.0) >