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) |
Hello Kursat, As noted in the documentation, the SVM implementation is for binary classification only for the time being. Regards, -- On Oct 13, 2016 8:53 PM, "Kürşat Kurt" <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |