Exemple #1
0
  public static void main(String[] argv) throws Exception {
    RSmo rsmo;
    Data data = null;

    double C = 100.0;
    double tau = 1E-8;
    double eps = 0.001;

    int type = Kernel.POL;
    int degree = 3;
    double factor = 0.01;
    double bias = 0.0;
    int size = 40;

    String filename = null;
    int i;
    try {
      for (i = 0; i < argv.length; i++) {
        if (argv[i].charAt(0) != '-') {
          break;
        }
        ++i;
        switch (argv[i - 1].charAt(1)) {
          case 'k':
            type = atoi(argv[i]);
            break;
          case 'd':
            degree = atoi(argv[i]);
            break;
          case 'f':
            factor = atof(argv[i]);
            break;
          case 'g':
            factor = atof(argv[i]);
            break;
          case 'b':
            bias = atof(argv[i]);
            break;
          case 'c':
            C = atof(argv[i]);
            break;
          case 't':
            tau = atof(argv[i]);
            break;
          case 'e':
            eps = atof(argv[i]);
            break;
          case 'i':
            filename = argv[i];
            break;
          case 'o':
            break;
          case 'O':
            break;
          case 's':
            size = atoi(argv[i]);
            break;
          case 'v':
            IO.setVerbosity(atoi(argv[i]));
            break;
          default:
            System.err.print("unknown option: " + argv[i - 1].charAt(1) + "");
            System.exit(1);
        }
      }
    } catch (Exception e) {
      // System.err.print(e.toString());
      // System.exit(1);
    }

    try {
      data = SparseVector.readData(filename);
    } catch (RuntimeException e) {
      data = StepFunction.readData(filename);
    }

    Kernel kernel = new Kernel(data.point, type, degree, factor, bias, size);
    double t[];
    t = new double[data.l];
    for (i = 0; i < data.l; i++) {
      t[i] = Double.parseDouble(data.label[i]);
    }
    rsmo = new RSmo(kernel, t, C, tau, eps);

    rsmo.train();
  }