1

我有一个后缀为 .data 和 .dat 的文件作为我的数据集,我需要将其转换为 .idx 和 .arrf 以将其用作输入。我的java项目需要它,我会很感激你的帮助。这是我的数据样本: lib.stat.cmu.edu/datasets/NO2.dat

  BufferedReader r = new BufferedReader(new FileReader("data.arff"));
  Instances data = new Instances(r);
  data.setClassIndex(data.numAttributes() - 1);
  normalize(data);
  r.close();

  /* The data.idx must contain 3 serialized integer array obects.
   * They contain the instance indeies in the data file that belong to, respectively,
   * the labeled set, the unlabeled set and the test set
   */
  ObjectInputStream objin = new ObjectInputStream(new FileInputStream("data.idx"));
  int[] labeledIdx = (int[]) objin.readObject();
  int[] unlabeledIdx = (int[]) objin.readObject();
  int[] testIdx = (int[]) objin.readObject();

  Instances labeled = new Instances(data, 0);
  Instances unlabeled = new Instances(data, 0);
  Instances test = new Instances(data, 0);
4

0 回答 0