Exemplo n.º 1
0
  public PassiveTest() {
    String url = "jdbc:mysql://localhost:8889/";
    String dbName = "openML";
    String driver = "com.mysql.jdbc.Driver";
    String userName = "******";
    String password = "******";

    List<String> algorithms = createSimpleClassifierList();

    HashMap<String, Classifier> classifiers = ClassifierUtils.createClassifiers(algorithms);

    List<String> algorithmNames = createSimpleAlgorithmNameList();

    IDataAccessObject dao =
        new MysqlMetaDataAccessObject(url, dbName, driver, userName, password, algorithmNames);

    //		int[] ids = createIds(100, 1, 1, dao);
    //		int[] ids = createSimpleIds();
    int[] ids = OpenMLUtils.getIds(100000);

    HashMap<String, IDataAccessObject> datasets = new HashMap<String, IDataAccessObject>();
    data = new HashMap<String, Instance>();

    System.out.println("Getting Data Access Objects for each id");
    for (int id : ids) {
      String s = String.valueOf(id);

      if (StringUtils.isNullOrWhiteSpace(s)) continue;

      ArffDataAccessObject arffDAO = OpenMLUtils.getArffDAO(s);

      if (arffDAO != null) {
        data.put(s, dao.getInstance(s));
        datasets.put(s, arffDAO);
      }
    }

    IOracle oracle = new MetaDataOracle(dao, classifiers, datasets);

    AInstanceSelecter instanceSelecter = new RandomInstanceSelecter();

    learner = new PoolLearner(oracle, instanceSelecter);
  }
Exemplo n.º 2
0
  public static int[] createIds(int size, int start, int offset, IDataAccessObject dao) {
    System.out.println("Creating Test ids");

    if (size < 1) size = 1;
    if (size > 500) size = 500;
    if (start < 1 || start > 500) start = 1;
    if (offset < 1 || offset * size > 500) offset = 1;

    int[] ids = new int[size];

    for (int i = 0; i < size; ++i) {
      ids[i] = start;

      String label = (String) dao.getLabel(String.valueOf(start));
      if (StringUtils.isNullOrWhiteSpace(label)) {
        i--;
      }

      start += offset;
    }
    System.out.println("#####Successfully created Test ids");
    return ids;
  }