• libsvm使用


    先挖个坑,有空重写svm_scale, svm_train, svm_predict几个代码,给的实在写的不敢恭维

    package org.ml.svm;
    
    import java.io.File;
    import java.io.FileDescriptor;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.PrintStream;
    
    public class SVMTest {
        
        public static void main(String[] args) throws IOException {
    //        BufferedReader bf = new BufferedReader(new FileReader("data\train.1"));
    //        String line;
    //        while((line = bf.readLine()) != null) System.out.println(line);
            
            //设置scale的参数,把输出重定向到文件中
            String[] scale_train_ops = 
                {"-l", "-1", "-u", "1", "-s", "data\range1", "data\train.1"};
            String[] scale_test_ops = {"-r", "data\range1", "data\test.1"};
            svm_scale s = new svm_scale();
            System.setOut(new PrintStream(new File("data\train.1.scale")));
            s.main(scale_train_ops);
            System.setOut(new PrintStream(new File("data\test.1.scale")));
            s.main(scale_test_ops);
            
            //把输出重定向会console上
            System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
            
            //设置训练和测试的参数
            String[] train_ops = {"data\train.1.scale", "data\train.1.model"};
            String[] test_ops = {"data\test.1.scale", "data\train.1.model", "data\out.1"};
            
            System.out.println("SVM start:");
            svm_train t = new svm_train();
            svm_predict p = new svm_predict();
            t.main(train_ops);
            p.main(test_ops);
            
        }
    }
  • 相关阅读:
    【Gym
    [matlab工具箱] 曲线拟合Curve Fitting
    数学建模 常用
    “这么多人给我作证,我不怕”
    超星尔雅刷课辅助
    细思《都挺好》
    P5173 传球
    [ICPC 北京 2017 J题]HihoCoder 1636 Pangu and Stones
    CF 1131C Birthday
    CF 634A Island Puzzle
  • 原文地址:https://www.cnblogs.com/549294286/p/3309080.html
Copyright © 2020-2023  润新知