static private void SVMExample() { SVMLearn svmLearn = new SVMLearn(); svmLearn.ExecuteLearner("svm_learn.exe", "example/train.dat", "example/model.txt", "example/learnLog.txt", false); SVMClassify svmClassify = new SVMClassify(); svmClassify.ExecuteClassifier("svm_classify.exe", "example/test.dat", "example/model.txt", "example/output.txt", "example/clasifylog.txt", false); }
public double[] distributionForInstances(Instances instances) { double[] ret = new double[instances.numInstances()]; if (m_mustValue.HasValue) { for (int i = 0; i < ret.Length; ++i) { ret[i] = m_mustValue == 0 ? m_delta.Value - 1 : m_delta.Value + 1; } return(ret); } if (System.IO.File.Exists(m_testFile)) { System.IO.File.Delete(m_testFile); } libsvmSaver.setInstances(instances); libsvmSaver.setFile(new java.io.File(m_testFile)); libsvmSaver.writeBatch(); //ConvertNorminalToString(m_testFile); if (System.IO.File.Exists(m_testOutputFile)) { System.IO.File.Delete(m_testOutputFile); } classifier.ExecuteClassifier(s_classifierPath, m_testFile, m_modelFile, m_testOutputFile); if (!System.IO.File.Exists(m_testOutputFile)) { throw new InvalidOperationException(classifier.Output); } using (System.IO.StreamReader sr = new System.IO.StreamReader(m_testOutputFile)) { for (int i = 0; i < ret.Length; ++i) { string s = sr.ReadLine(); ret[i] = Double.Parse(s); } } if (System.IO.File.Exists(m_testFile)) { System.IO.File.Delete(m_testFile); } if (System.IO.File.Exists(m_testOutputFile)) { System.IO.File.Delete(m_testOutputFile); } return(ret); }