Exemple #1
0
  /** Method interface for Automatic Branch and Bound */
  public void ejecutar() {
    String resultado;
    int i, numFeatures;
    Date d;

    d = new Date();
    resultado =
        "RESULTS generated at "
            + String.valueOf((Date) d)
            + " \n--------------------------------------------------\n";
    resultado += "Algorithm Name: " + params.nameAlgorithm + "\n";

    /* call of ABB algorithm */
    runABB();

    resultado += "\nPARTITION Filename: " + params.trainFileNameInput + "\n---------------\n\n";
    resultado += "Features selected: \n";

    for (i = numFeatures = 0; i < features.length; i++)
      if (features[i] == true) {
        resultado += Attributes.getInputAttribute(i).getName() + " - ";
        numFeatures++;
      }

    resultado +=
        "\n\n"
            + String.valueOf(numFeatures)
            + " features of "
            + Attributes.getInputNumAttributes()
            + "\n\n";

    resultado +=
        "Error in test (using train for prediction): "
            + String.valueOf(data.validacionCruzada(features))
            + "\n";
    resultado +=
        "Error in test (using test for prediction): "
            + String.valueOf(data.LVOTest(features))
            + "\n";

    resultado += "---------------\n";

    System.out.println("Experiment completed successfully");

    /* creates the new training and test datasets only with the selected features */
    Files.writeFile(params.extraFileNameOutput, resultado);
    data.generarFicherosSalida(params.trainFileNameOutput, params.testFileNameOutput, features);
  }
Exemple #2
0
  /**
   * It does remove an attribute. To remove an attribute, the train and the test sets have to be
   * passed to mantain the coherence of the system. Otherwise, only the attribute of the train set
   * would be removed, leaving inconsistent the instances of the test set, because of having one
   * extra attribute inexistent anymore.
   *
   * @param tSet is the test set.
   * @param inputAtt is a boolean that is true when the attribute that is wanted to be removed is an
   *     input attribute.
   * @param whichAtt is a integer that indicate the position of the attriubte to be deleted.
   * @return a boolean indicating if the attribute has been deleted
   */
  public boolean removeAttribute(InstanceSet tSet, boolean inputAtt, int whichAtt) {
    Attribute attToDel = null;
    // Getting a reference to the attribute to del
    if (inputAtt) {
      if (storeAttributesAsNonStatic && attributes != null)
        attToDel = (Attribute) attributes.getInputAttribute(whichAtt);
      else attToDel = (Attribute) Attributes.getInputAttribute(whichAtt);
    } else {
      if (storeAttributesAsNonStatic && attributes != null)
        attToDel = (Attribute) attributes.getOutputAttribute(whichAtt);
      else attToDel = (Attribute) Attributes.getOutputAttribute(whichAtt);
    }

    if (storeAttributesAsNonStatic && attributes != null) {
      System.out.println("Removing the attribute");
      if (!attributes.removeAttribute(inputAtt, whichAtt)
          || !tSet.attributes.removeAttribute(inputAtt, whichAtt)) return false;
    } else {
      if (!Attributes.removeAttribute(inputAtt, whichAtt)) return false;
    }

    for (int i = 0; i < instanceSet.length; i++) {
      if (storeAttributesAsNonStatic && attributes != null) {
        instanceSet[i].removeAttribute(attributes, attToDel, inputAtt, whichAtt);
      } else {
        instanceSet[i].removeAttribute(attToDel, inputAtt, whichAtt);
      }
    }

    if (tSet != null)
      for (int i = 0; i < tSet.instanceSet.length; i++) {
        if (storeAttributesAsNonStatic && attributes != null)
          tSet.instanceSet[i].removeAttribute(attributes, attToDel, inputAtt, whichAtt);
        else tSet.instanceSet[i].removeAttribute(attToDel, inputAtt, whichAtt);
      }
    return true;
  } // end removeAttribute