/** 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; }