コード例 #1
0
ファイル: Tritrainer.java プロジェクト: xuleiboy1234/HyREX
  // 构造一个tri-trainer分类器。
  public Tritrainer(
      String classifier, String trainingIns_File, String testIns_File, double precentage) {
    try {
      this.classifier1 = (Classifier) Class.forName(classifier).newInstance();
      this.classifier2 = (Classifier) Class.forName(classifier).newInstance();
      this.classifier3 = (Classifier) Class.forName(classifier).newInstance();

      Instances trainingInstances = Util.getInstances(trainingIns_File);

      // 将trainIns_File按照precentage和(1-precentage)的比例切割成labeledIns和unlabeledIns;
      int length = trainingInstances.numInstances();
      int i = new Double(length * precentage).intValue();
      labeledIns = new Instances(trainingInstances, 0);
      for (int j = 0; j < i; j++) {
        labeledIns.add(trainingInstances.firstInstance());
        trainingInstances.delete(0);
      }
      unlabeledIns = trainingInstances;
      testIns = Util.getInstances(testIns_File);

      Init();
    } catch (Exception e) {

    }
  }
コード例 #2
0
ファイル: DataIO.java プロジェクト: qxiao001/FYP-Project
  public static Connection getDBConn() {
    try {
      Class.forName("org.postgresql.Driver");

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    Connection connection = null;

    try {
      connection =
          DriverManager.getConnection(Config.connString, Config.connUser, Config.connPassword);
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return connection;
  }