Esempio n. 1
0
  /**
   * Indicates how many different combinations of data processor, feature-selection algorithm, and
   * classification algorithm there are in this experiment.
   *
   * @param includeNumFeaturesOptions Whether to count each number of features options as separate
   *     classification algorithm
   * @return Number of unique combinations
   * @throws Exception
   */
  private static int GetNumberClassificationCombinations(boolean includeNumFeaturesOptions)
      throws Exception {
    int count = 0;

    for (AbstractDataProcessor processor :
        Singletons.ProcessorVault.IndependentVariableDataProcessors)
      for (FeatureSelectionAlgorithm fsAlgorithm :
          Singletons.Config.GetFeatureSelectionAlgorithms(processor))
        for (ClassificationAlgorithm classificationAlgorithm :
            Singletons.Config.GetMainClassificationAlgorithms())
          count +=
              (includeNumFeaturesOptions
                  ? Singletons.Config.GetNumFeaturesOptions(processor, fsAlgorithm).size()
                  : 1);

    return count;
  }
Esempio n. 2
0
  /**
   * Depending on the settings for the experiment and the current iteration, this method returns a
   * path to where the settings files should be saved.
   *
   * @param appendIterationIfMoreThanOne Whether to append the iteration number if more than one
   *     iteration is being executed
   * @return Path to where the settings files should be saved
   * @throws Exception
   */
  public static String GetOutputSettingsDir(boolean appendIterationIfMoreThanOne) throws Exception {
    String dirPath = Settings.OUTPUT_DIR + "Settings/";

    if (Singletons.Config.GetNumIterations() > 1 && appendIterationIfMoreThanOne)
      dirPath += "Iteration" + Singletons.Iteration + "/";

    return FileUtilities.CreateDirectoryIfNotExists(dirPath);
  }
Esempio n. 3
0
  /**
   * Indicates whether feature selection needs to be performed at all for this experiment.
   *
   * @return Wheter feature selection needs to be performed at all for this experiment
   * @throws Exception
   */
  public static boolean NeedToSelectFeatures() throws Exception {
    for (AbstractDataProcessor processor :
        Singletons.ProcessorVault.IndependentVariableDataProcessors)
      for (FeatureSelectionAlgorithm fsAlgorithm :
          Singletons.Config.GetFeatureSelectionAlgorithms(processor))
        if (FeatureSelectionEvaluator.NeedToSelectFeatures(processor, fsAlgorithm)) return true;

    return false;
  }
Esempio n. 4
0
  /**
   * Depending on the settings for the experiment and the current iteration, this method returns a
   * path to where the results files should be saved.
   *
   * @param subDirectoryPath Sub directory under results
   * @param appendIterationIfMoreThanOne Whether to append the iteration number if more than one
   *     iteration is being executed
   * @return Path to where the results files should be saved
   * @throws Exception
   */
  public static String GetOutputResultsDir(
      String subDirectoryPath, boolean appendIterationIfMoreThanOne) throws Exception {
    String dir = Settings.OUTPUT_DIR + "Results/" + subDirectoryPath;

    if (Singletons.Config.GetNumIterations() > 1 && appendIterationIfMoreThanOne)
      dir += "Iteration" + Singletons.Iteration + "/";

    return dir;
  }
  /**
   * This method saves various description files to the output. These tasks are quick to execute, so
   * they are grouped together rather than parallelized.
   *
   * @throws Exception
   */
  public void SaveExperimentDescriptionFiles() throws Exception {
    // Save the version file in output so people know which version was used
    FileUtilities.CopyFile(
        Settings.VERSION_FILE, Settings.GetOutputSettingsDir(false) + Settings.VERSION_FILE);

    // Copy the experiment file
    FileUtilities.WriteLineToFile(
        Settings.GetOutputSettingsDir(false) + "Experiment_Settings.txt",
        "# All settings used in this experiment, whether explicitly set or used by default in the absence of an explicit setting");
    FileUtilities.AppendTextToFile(
        Settings.GetOutputSettingsDir(false) + "Experiment_Settings.txt",
        Singletons.Config.toString());

    if (Settings.NeedToClassify()) {
      // Copy the algorithm configuration files
      FileUtilities.CopyFile(
          Settings.LEARNER_TEMPLATES_FILE,
          Settings.GetOutputSettingsDir(false)
              + new File(Settings.LEARNER_TEMPLATES_FILE).getName());

      // Copy the algorithm configuration files
      FileUtilities.CopyFile(
          Settings.CLASSIFICATION_ALGORITHMS_FILE,
          Settings.GetOutputSettingsDir(false)
              + new File(Settings.CLASSIFICATION_ALGORITHMS_FILE).getName());

      if (Settings.NeedToSelectFeatures())
        FileUtilities.CopyFile(
            Settings.FEATURE_SELECTION_ALGORITHMS_FILE,
            Settings.GetOutputSettingsDir(false)
                + new File(Settings.FEATURE_SELECTION_ALGORITHMS_FILE).getName());

      SaveExcludedTrainingIDInfo();
      SaveCrossValidationAssignments();
    }
  }
Esempio n. 6
0
 /**
  * Indicates whether this is a training/testing experiment.
  *
  * @return Whether this is a training/testing experiment
  * @throws Exception
  */
 public static boolean IsTrainTestExperiment() throws Exception {
   return Singletons.Config.GetNumOuterCrossValidationFolds() == 1
       || (Singletons.Config.GetTrainingInstanceIDs().size() > 0
           && Singletons.Config.GetTestInstanceIDs().size() > 0);
 }