예제 #1
0
파일: DMEL.java 프로젝트: RubelAhmed57/KEEL
  /**
   * It reads the data from the input files (training, validation and test) and parse all the
   * parameters from the parameters array.
   *
   * @param parameters parseParameters It contains the input files, output files and parameters
   */
  public DMEL(parseParameters parameters) {

    train = new myDataset();
    val = new myDataset();
    test = new myDataset();
    try {
      System.out.println("\nReading the training set: " + parameters.getTrainingInputFile());
      train.readClassificationSet(parameters.getTrainingInputFile(), true);
      System.out.println("\nReading the validation set: " + parameters.getValidationInputFile());
      val.readClassificationSet(parameters.getValidationInputFile(), false);
      System.out.println("\nReading the test set: " + parameters.getTestInputFile());
      test.readClassificationSet(parameters.getTestInputFile(), false);
    } catch (IOException e) {
      System.err.println("There was a problem while reading the input data-sets: " + e);
      somethingWrong = true;
    }

    // We may check if there are some numerical attributes, because our algorithm may not handle
    // them:
    somethingWrong = somethingWrong || train.hasRealAttributes();

    outputTr = parameters.getTrainingOutputFile();
    outputTst = parameters.getTestOutputFile();
    outputRule = parameters.getOutputFile(0);

    // Now we parse the parameters, for example:

    seed = Long.parseLong(parameters.getParameter(0));

    popSize = Integer.parseInt(parameters.getParameter(1));
    pCross = Double.parseDouble(parameters.getParameter(2));
    pMut = Double.parseDouble(parameters.getParameter(3));
    numGenerations = Integer.parseInt(parameters.getParameter(4));

    // ...
  }
예제 #2
0
  /**
   * It reads the data from the input files (training, validation and test) and parse all the
   * parameters from the parameters array.
   *
   * @param parameters parseParameters It contains the input files, output files and parameters
   */
  public Fuzzy_Ish(parseParameters parameters) {

    train = new myDataset();
    val = new myDataset();
    test = new myDataset();
    try {
      System.out.println("\nReading the training set: " + parameters.getTrainingInputFile());
      train.readClassificationSet(parameters.getTrainingInputFile(), true);
      System.out.println("\nReading the validation set: " + parameters.getValidationInputFile());
      val.readClassificationSet(parameters.getValidationInputFile(), false);
      System.out.println("\nReading the test set: " + parameters.getTestInputFile());
      test.readClassificationSet(parameters.getTestInputFile(), false);
    } catch (IOException e) {
      System.err.println("There was a problem while reading the input data-sets: " + e);
      somethingWrong = true;
    }

    // We may check if there are some numerical attributes, because our algorithm may not handle
    // them:
    // somethingWrong = somethingWrong || train.hasNumericalAttributes();
    // somethingWrong = somethingWrong || train.hasMissingAttributes();

    outputTr = parameters.getTrainingOutputFile();
    outputTst = parameters.getTestOutputFile();

    fileDB = parameters.getOutputFile(0);
    fileBR = parameters.getOutputFile(1);

    // Now we parse the parameters
    long seed = Long.parseLong(parameters.getParameter(0));
    // String aux = parameters.getParameter(1); //Computation of the compatibility degree
    combinationType = PRODUCT;
    /*if (aux.compareToIgnoreCase("minimum") == 0) {
      combinationType = MINIMUM;
    }
    aux = parameters.getParameter(2);*/
    ruleWeight = PCF_IV;
    /*if (aux.compareToIgnoreCase("Certainty_Factor") == 0) {
      ruleWeight = CF;
    }
    else if (aux.compareToIgnoreCase("Mansoory_Rule_Weight_System") == 0) {
      ruleWeight = MCF;
    }
    else if (aux.compareToIgnoreCase("Average_Penalized_Certainty_Factor") == 0) {
      ruleWeight = PCF_II;
    }
    aux = parameters.getParameter(3);*/
    inferenceType = WINNING_RULE;
    /*if (aux.compareToIgnoreCase("Additive_Combination") == 0) {
      inferenceType = ADDITIVE_COMBINATION;
    }*/

    nRules = Integer.parseInt(parameters.getParameter(1));
    if (nRules == 0) {
      if (train.getnInputs() < 10) {
        nRules = 5 * train.getnInputs(); // heuristic
      } else {
        nRules = 50;
      }
    }
    while (nRules % 10 != 0) {
      nRules++;
    } // In order to have no problems with "n_replace"
    if (nRules > train.getnData()) {
      nRules = train.getnInputs() / 10;
      nRules *= 10;
    }

    populationSize = Integer.parseInt(parameters.getParameter(2));
    while (populationSize % 10 != 0) {
      populationSize++;
    }

    crossProb = Double.parseDouble(parameters.getParameter(3));
    this.nGenerations = Integer.parseInt(parameters.getParameter(4));
    p_DC = Double.parseDouble(parameters.getParameter(5));
    michProb = Double.parseDouble(parameters.getParameter(6));

    Randomize.setSeed(seed);
  }