Пример #1
0
  // Call when these models are runnable but not logged in the current assignment
  // e.g., have been loaded from a saved project.
  // TODO: MUST SAVE MODEL LOADER HERE TOO!
  private void logFirstRunInAssignmentWithNewModels(Wekinator w) throws IOException {
    List<Path> paths = w.getSupervisedLearningManager().getPaths();
    Long t = ts();
    pw.println(
        t
            + ","
            + w.getID()
            + ",FIRST_ASSIGNMENT_MODEL_LOG,NUM_MODELS="
            + paths.size()
            + ",MODEL_SET="
            + modelSetID);
    String baseName = "model_" + modelSetID + "_";
    int i = 0;
    int numInputs = w.getInputManager().getNumInputs();
    int numOutputs = w.getOutputManager().getOutputGroup().getNumOutputs();
    int numMetaData = w.getDataManager().getNumMetaData();
    for (Path p : paths) {
      String f = currentAssignmentDir + baseName + i + ".xml";
      pw.println(
          t
              + ","
              + w.getID()
              + ",MODEL_NUM="
              + i
              + ","
              + baseName
              + i
              + ".xml,"
              + p.getModelBuilder().toLogString());
      p.writeToFile(f);

      // Write to another file:
      // int numInputs, int numOutputs, int numMetaData, Instances dummyInstances, Filter
      // outputFilter) {
      Instances dummyInstances = w.getDataManager().getDummyInstances();
      String outputFilterString = w.getDataManager().getOutputFilterString(i);
      LoadableInstanceMaker m;
      try {
        m =
            new LoadableInstanceMaker(
                numInputs, numOutputs, numMetaData, dummyInstances, outputFilterString);
        String f2 = currentAssignmentDir + baseName + i + "_m.xml";
        m.writeToFile(f2);
      } catch (Exception ex) {
        Logger.getLogger(Assignment12Logger.class.getName()).log(Level.SEVERE, null, ex);
      }
      i++;
    }
    GlobalSettings.getInstance().setIntValue("modelSetID", modelSetID);
    modelSetID++;
    hasLoggedModelsInThisAssignment = true;
  }
Пример #2
0
 private void doAssignmentSetup(KadenzeAssignmentType a) {
   GlobalSettings gs = GlobalSettings.getInstance();
   int lastModelSetID = gs.getIntValue("modelSetID", 0);
   modelSetID = lastModelSetID + 1;
 }
Пример #3
0
  @Override
  public void supervisedTrainFinished(Wekinator w) throws IOException {
    // Make sure we're getting info about feature selection too
    // Need: Serialized models (1 per timestamped file is fine), with training data for each model
    // Probably want good way of storing binary serialization data into XML as well
    // Want info about which models are currently run-enabled.
    List<Path> paths = w.getSupervisedLearningManager().getPaths();
    Long t = ts();
    pw.println(
        t
            + ","
            + w.getID()
            + ",TRAIN_FINISHED,NUM_MODELS="
            + paths.size()
            + ",MODEL_SET="
            + modelSetID);
    String baseName = "model_" + modelSetID + "_";
    int i = 0;
    int numInputs = w.getInputManager().getNumInputs();
    int numOutputs = w.getOutputManager().getOutputGroup().getNumOutputs();
    int numMetaData = w.getDataManager().getNumMetaData();
    for (Path p : paths) {
      String f = currentAssignmentDir + baseName + i + ".xml";
      // pw.println(t + "," + w.getID() + ",MODEL_NUM=" + i + "," + baseName + i + ".xml");
      pw.println(
          t
              + ","
              + w.getID()
              + ",MODEL_NUM="
              + i
              + ","
              + baseName
              + i
              + ".xml,"
              + p.getModelBuilder().toLogString());

      p.writeToFile(f);

      // Write to another file:
      // int numInputs, int numOutputs, int numMetaData, Instances dummyInstances, Filter
      // outputFilter) {
      Instances dummyInstances = w.getDataManager().getDummyInstances();
      String outputFilterString = w.getDataManager().getOutputFilterString(i);
      LoadableInstanceMaker m;
      try {
        m =
            new LoadableInstanceMaker(
                numInputs, numOutputs, numMetaData, dummyInstances, outputFilterString);
        String f2 = currentAssignmentDir + baseName + i + "_m.xml";
        m.writeToFile(f2);
      } catch (Exception ex) {
        Logger.getLogger(Assignment12Logger.class.getName()).log(Level.SEVERE, null, ex);
      }

      i++;
    }

    GlobalSettings.getInstance().setIntValue("modelSetID", modelSetID);
    modelSetID++;
    hasLoggedModelsInThisAssignment = true;
  }