Accord.net에서 SVM을 사용하여 시계열 모델링을하고 있습니다. 나는 그것을 사용할 수있는 데이터 (예를 들어 5000)로 한 번 훈련시킨다. 그 후에 매 초마다 새로운 데이터를 얻습니다. 매 초마다 하나의 데이터를 사용하여 SVM 머신을 점차적으로 업데이트하고 싶습니다.accord.net svm incremental training
1
A
답변
1
Accord.NET에서 SVM을 점진적으로 배울 수는 있지만,이 기능은 선형 기계에서만 사용할 수 있습니다. 당신이 시계열로 작업하고 있기 때문에 나는 Dynamic Time Warping 커널을 사용하여 커널 SVM으로 작업하고 있다고 가정하고 있습니다.
당신이 당신의 순서에서 고정 길이 특징을 추출 할 수 있다면, 당신은 대신 선형 시스템에 이러한 기능을 먹이고 확률 그라데이션 하강 또는 Averaged Stochastic Gradient Descent를 사용하여 훈련하면 아래 그림과 같이 당신은 할 수 있습니다 무엇을 물어 :
// In this example, we will learn a multi-class SVM using the one-vs-one (OvO)
// approach. The OvO approacbh can decompose decision problems involving multiple
// classes into a series of binary ones, which can then be solved using SVMs.
// Ensure we have reproducible results
Accord.Math.Random.Generator.Seed = 0;
// We will try to learn a classifier
// for the Fisher Iris Flower dataset
var iris = new Iris();
double[][] inputs = iris.Instances; // get the flower characteristics
int[] outputs = iris.ClassLabels; // get the expected flower classes
// We will use mini-batches of size 32 to learn a SVM using SGD
var batches = MiniBatches.Create(batchSize: 32, maxIterations: 1000,
shuffle: ShuffleMethod.EveryEpoch, input: inputs, output: outputs);
// Now, we can create a multi-class teaching algorithm for the SVMs
var teacher = new MulticlassSupportVectorLearning<Linear, double[]>
{
// We will use SGD to learn each of the binary problems in the multi-class problem
Learner = (p) => new StochasticGradientDescent<Linear, double[], LogisticLoss>()
{
LearningRate = 1e-3,
MaxIterations = 1 // so the gradient is only updated once after each mini-batch
}
};
// The following line is only needed to ensure reproducible results. Please remove it to enable full parallelization
teacher.ParallelOptions.MaxDegreeOfParallelism = 1; // (Remove, comment, or change this line to enable full parallelism)
// Now, we can start training the model on mini-batches:
foreach (var batch in batches)
{
teacher.Learn(batch.Inputs, batch.Outputs);
}
// Get the final model:
var svm = teacher.Model;
// Now, we should be able to use the model to predict
// the classes of all flowers in Fisher's Iris dataset:
int[] prediction = svm.Decide(inputs);
// And from those predictions, we can compute the model accuracy:
var cm = new GeneralConfusionMatrix(expected: outputs, predicted: prediction);
double accuracy = cm.Accuracy; // should be approximately 0.973