如何在 svm 多标签中进行文件训练和测试?

how make files training and testing in svm multi label?

如何在svm多标签中进行文件训练和测试? 我的问题是 https://www.quora.com/Can-anyone-give-me-some-pointers-for-using-SVM-for-user-recognition-using-keystroke-timing/answer/Chomba-Bupe?snid3=364610243&nsrc=1&filter=all

我的项目是动态键盘,一个用户与所有用户进行训练 例如,如果您有三个 类 A、B 和 C,那么您将拥有 3 个 SVM,每个 SVM 都有自己的参数,即权重和偏差,以及分别对应于 3 类 的 3 个独立输出。在训练 SVM-A 时,另外两个 类 B 和 C 作为负训练集,而 A 作为正训练集,那么在训练 SVM-B 时 A 和 C 是负训练集,对于 SVM-C A 和 B 是负训练集.这就是所谓的one vs all训练过程。

我试了但是结果不对

我的训练文件是 .csv,包含:

65 134,+1

70 98,+1

73 69,+1

82 122,+1

82 95,+1

83 127,+1

84 7,+1

85 64,+1

65 123,-1

71 115,-1

73 154,-1

73 156,-1

77 164,-1

77 144,-1

79 112,-1

83 91,-1

and my file to testing is .csv and contents is:

65 111

68 88

70 103

73 89

82 111

82 79

83 112

84 36

85 71

我的密码是

    'use strict';

var so = require('stringify-object');
var Q = require('q');
var svm = require('../lib');
var trainingFile = './archivos/training/340.txt';
var testingFile = './archivos/present/340.txt';

var clf = new svm.CSVC({
    gamma: 0.25,
    c: 1, // allow you to evaluate several values during training
    normalize: false,
    reduce: false,
    kFold: 1 // disable k-fold cross-validation
});

Q.all([
    svm.read(trainingFile),
    svm.read(testingFile)
]).spread(function (trainingSet, testingSet) {
    return clf.train(trainingSet)
        .progress(function(progress){
            console.log('training progress: %d%', Math.round(progress*100));
        })
        .then(function () {
            return clf.evaluate(testingSet);
        });
}).done(function (evaluationReport) {
    console.log('Accuracy against the testset:\n', so(evaluationReport));
});

enter code here

你的标签是1和-1吗?如果是这样,您还需要知道那些 类 用于您的测试数据。测试你的分类器的目的是看它能多好地预测看不见的数据。

举个小例子,您可以使用训练数据构建分类器: x_train = [65, 134], [70,98]....... [79, 112], [83, 91] y_train = [ 1, 1, ....-1, -1]

然后通过传入测试数据来测试分类器。假设您在测试数据中传递了前三个示例,它会做出以下预测。 [65, 111] --> 1 [68, 88] -->-1 [70,103] -->-1 然后计算它预测正确的测试数据的数量,但为了做到这一点,您首先需要知道测试数据的 类。如果你没有,也许你想尝试对你的训练数据进行交叉验证。