Пример #1
0
  /** Returns True if the rule is perfect for the data set. */
  public boolean perfectRule(Complejo regla, Dataset train) {
    ConjDatos datosTrain;
    datosTrain = new ConjDatos();
    datosTrain = creaConjunto(train);
    boolean perfecta = false;

    /*Muestra m = datosTrain.getDato(3);//la primera instancia basicamente
    System.out.println(m.getClase());*/

    Muestra m;
    ConjDatos cubiertas;
    cubiertas = new ConjDatos();

    /*todas las instancias que cubra la regla las metemos en un conjunto*/
    for (int i = 0; i < train.getndatos(); i++) {
      m = datosTrain.getDato(i);
      if (regla.cubre(m)) {
        cubiertas.addDato(m);
      }
    }
    /*perfecta sera true si todos los ejemplos del conjunto 'cubiertas' tienen la misma clase que predice la regla*/
    for (int i = 0; i < cubiertas.size(); i++) {
      if (cubiertas.getDato(i).getClase() != regla.getClase()) {
        perfecta = false;
        return perfecta;
      } else perfecta = true;
    }
    return perfecta;
  }
Пример #2
0
  /**
   * Evaluation of the complex over the example's set for see witch match all the class
   *
   * @param c Complex to evaluate
   * @param e Set of data
   */
  private void evaluarComplejo(Complejo c, ConjDatos e) {
    c.borraDistrib();
    for (int i = 0; i < e.size(); i++) {
      int cl = e.getDato(i).getClase();

      if (c.cubre(e.getDato(i))) {
        c.incrementaDistrib(cl);
      }
    }
    c.calculaLaplaciano();
  }