public static SupportVectorMachine <Gaussian> MakeDeserialization(string path) { var teacher = new SequentialMinimalOptimization <Gaussian>() { UseComplexityHeuristic = true, UseKernelEstimation = true }; double[][] inputs2 = new double[4][]; inputs2[0] = new[] { 1.0, 4 }; inputs2[1] = new[] { 6.0, 8 }; inputs2[2] = new[] { 60.0, 78 }; inputs2[3] = new[] { 60.0, 90 }; double[] outputs2 = { 1, 1, 0, 0 }; SupportVectorMachine <Gaussian> svmAfter = teacher.Learn(inputs2, outputs2); SVMGaussianData dataAfter = Deserialize <SVMGaussianData>(path); svmAfter.NumberOfInputs = dataAfter.NumberOfInputs; svmAfter.NumberOfOutputs = dataAfter.NumberOfOutputs; svmAfter.SupportVectors = dataAfter.SupportVectors; svmAfter.Threshold = dataAfter.Threshold; svmAfter.Weights = dataAfter.Weights; Gaussian g = new Gaussian(); g.Gamma = dataAfter.Gamma; g.Sigma = dataAfter.Sigma; g.SigmaSquared = dataAfter.SigmaSquared; svmAfter.Kernel = g; return(svmAfter); }
public static void MakeSerialization(SupportVectorMachine <Gaussian> svm, string path) { SVMGaussianData data = new SVMGaussianData(); data.NumberOfInputs = svm.NumberOfInputs; data.NumberOfOutputs = svm.NumberOfOutputs; data.SupportVectors = svm.SupportVectors; data.Threshold = svm.Threshold; data.Weights = svm.Weights; data.Sigma = svm.Kernel.Sigma; data.SigmaSquared = svm.Kernel.SigmaSquared; data.Gamma = svm.Kernel.Gamma; Serialize(data, path); }