Ejemplo n.º 1
0
 /** Prints the classifier. */
 public void print() {
   System.out.print("  Act: " + action + "   Conf:  ");
   for (int i = 0; i < rep.length; i++) {
     rep[i].print();
   }
   if (parameters != null) parameters.print();
 } // end print
Ejemplo n.º 2
0
 /**
  * Prints the classifier to the specified file.
  *
  * @param fout is the file output where the classifier has to be printed.
  */
 public void print(PrintWriter fout) {
   fout.print(" ");
   for (int i = 0; i < rep.length; i++) {
     rep[i].print(fout);
   }
   fout.print("  " + action + "  ");
   if (parameters != null) parameters.print(fout);
 }
Ejemplo n.º 3
0
  /**
   * Returns if the classifier of the class subsumes the classifier passed as a parameter.
   *
   * @param cl is the subsumed classifier.
   * @return a boolean indicating if it subsumes
   */
  public boolean doesSubsume(Classifier cl) {

    if (rep.getAction() != cl.rep.getAction()) return false;

    if (parameters.couldSubsume()) {
      if (rep.isMoreGeneral(cl.rep)) {
        return true;
      }
    }
    return false;
  } // end doesSubsume
Ejemplo n.º 4
0
  /**
   * Returns if the classifier of the class subsumes the classifier passed as a parameter.
   *
   * @param cl is the subsumed classifier.
   * @return a boolean indicating if it subsumes
   */
  public boolean doesSubsume(Classifier cl) {
    int i;

    // First, check if the condition is the same
    if (action != cl.getAction()) return false;

    // Then, check that is more general
    if (parameters.couldSubsume()) {
      for (i = 0; i < rep.length; i++) {
        if (!rep[i].isMoreGeneral(cl.rep[i])) return false;
      }
      return true;
    }
    return false;
  } // end doesSubsume
Ejemplo n.º 5
0
  /**
   * Prints the desnormalized classifier to the specified file.
   *
   * @param fout is the file output where the classifier has to be printed.
   */
  public void printNotNorm(PrintWriter fout) {
    int i = 0;
    fout.print(" ");
    try {
      for (i = 0; i < rep.length; i++) {
        if (Config.typeOfAttributes[i].equals("ternary")) {
          rep[i].print(fout);
        } else if (Config.typeOfAttributes[i].equals("integer")) {
          rep[i].printNotNorm(fout, Config.attBounds[i][0]);
        } else if (Config.typeOfAttributes[i].equals("real")) {
          rep[i].printNotNorm(fout, Config.attBounds[i][0], Config.attBounds[i][1]);
        }
      }
    } catch (Exception e) {
      System.out.println("Exception when printing the attribute: " + i);
      e.printStackTrace();
    }
    fout.print("\t " + (String) Config.classConv.elementAt(action));

    if (parameters != null) parameters.print(fout);
  }
Ejemplo n.º 6
0
 /**
  * Returns the numerosity of the classifier.
  *
  * @return an integer with the numerosity
  */
 public int getNumerosity() {
   return parameters.getNumerosity();
 } // end getNumerosity
Ejemplo n.º 7
0
 /**
  * Returns the time stamp of the classifier.
  *
  * @return an integer with the time stamp of the classifier.
  */
 public int getTime() {
   return parameters.getTime();
 } // end getTime
Ejemplo n.º 8
0
 /**
  * Sets the prediction error
  *
  * @param predErr is the prediction error value.
  */
 public void setPredError(double predErr) {
   parameters.setPredError(predErr);
 } // end setPredError
Ejemplo n.º 9
0
 /**
  * Increases the number of matches
  *
  * @param num is the number of matches to be increased.
  */
 public void increaseNumberMatches(int num) {
   parameters.increaseNumberMatches(num);
 } // end increaseNumberMatches
Ejemplo n.º 10
0
 /**
  * Computes the generality of the classifier and stores it in it corresponding parameter in the
  * class Parameters.
  */
 public void calculateGenerality() {
   parameters.setGenerality(getGenerality());
 } // end calculateGenerality
Ejemplo n.º 11
0
 /**
  * Returns if the classifier can subsume. The classifier has to be sufficiently accurate and
  * sufficiently experienced to subsume another classifier.
  *
  * @return a boolean indicating if the classifier can subsume.
  */
 public boolean couldSubsume() {
   return parameters.couldSubsume();
 } // end couldSubsume
Ejemplo n.º 12
0
 /**
  * Updates the parameters of a classifier.
  *
  * @param microClSum is the numerosity of the action set (all the action set.).
  * @param classOfExample is the class of the example.
  */
 public void updateParameters(double microClInC, int classOfExample) {
   parameters.updateParameters(microClInC, action, classOfExample);
 } // end updateParameters
Ejemplo n.º 13
0
 /**
  * Sets the time stamp for this classifier.
  *
  * @param tStamp is the time stamp
  */
 public void setTime(int tStamp) {
   parameters.setTime(tStamp);
 } // end setTime
Ejemplo n.º 14
0
 /** Prints the classifier. */
 public void print() {
   rep.print();
   if (parameters != null) parameters.print();
 }
Ejemplo n.º 15
0
 /**
  * Prints the desnormalized classifier to the specified file.
  *
  * @param fout is the file output where the classifier has to be printed.
  */
 public void printNotNorm(PrintWriter fout) {
   rep.printNotNorm(fout);
   if (parameters != null) parameters.print(fout);
 }
Ejemplo n.º 16
0
 public boolean couldComp() {
   return parameters.couldComp();
 }
Ejemplo n.º 17
0
 /**
  * Adds the value passed to the usefulTimes parameter of the classifier
  *
  * @param num is the value that has to be added
  */
 public void addUsefulTimes(int num) {
   parameters.addUsefulTimes(num);
 }
Ejemplo n.º 18
0
 /**
  * Returns if the classifier is experienced, and accurate enough to be in the reduction set.
  * Otherwise, the classifier will not be included in the reduction
  *
  * @param maxReward is the maximum reward of the environment.
  * @return a boolean indicating if the classifier can be in the reduction set.
  */
 public boolean couldReduce(double maxReward) {
   return parameters.couldReduce(maxReward);
 }
Ejemplo n.º 19
0
 /**
  * Returns the estimated action set size.
  *
  * @return an integer with the estimated action set size.
  */
 public double getCSize() {
   return parameters.getCSize();
 } // end getASize
Ejemplo n.º 20
0
 /**
  * Updates the fitness of a classifier
  *
  * @param kSum is the sum of all accuracies.
  * @param k is the accuracy of the classifier.
  */
 public void updateFitness(double kSum, double k) {
   parameters.updateFitness(kSum, k);
 } // end updateFitness
Ejemplo n.º 21
0
 /**
  * Returns the experience of the classifier.
  *
  * @return an integer with the experience of the classifier.
  */
 public int getExperience() {
   return parameters.getExperience();
 } // end getExperience
Ejemplo n.º 22
0
 /**
  * Sets the useful parameter
  *
  * @param value is the value that the useful param has to be set.
  */
 public void setUseful(boolean value) {
   parameters.setUseful(value);
 } // end setUseful
Ejemplo n.º 23
0
 /** Sets the numerosity of the classifier. */
 public void setNumerosity(int num) {
   parameters.setNumerosity(num);
 } // end setNumerosity
Ejemplo n.º 24
0
 /**
  * Sets the prediction value.
  *
  * @param pred is the prediction to be set
  */
 public void setPrediction(double pred) {
   parameters.setPrediction(pred);
 } // end setPrediction
Ejemplo n.º 25
0
 /**
  * Increases the numerosity of the classifier.
  *
  * @param num is the number to increase the numerosity of the classifier.
  */
 public void increaseNumerosity(int num) {
   parameters.increaseNumerosity(num);
 } // end increaseNumerosity
Ejemplo n.º 26
0
 /**
  * Returns the accuracy of the classifier.
  *
  * @return a double with the accuracy
  */
 public double getAccuracy() {
   return parameters.getAccuracy();
 } // end getAccuracy
Ejemplo n.º 27
0
 /**
  * Sets the number of matches
  *
  * @param num is the number of matches to be set.
  */
 public void setNumberMatches(int num) {
   parameters.setNumberMatches(num);
 } // end setNumberMatches
Ejemplo n.º 28
0
 /**
  * Returns the fitness of the "micro-classifier"
  *
  * @return a double with the micro-classifier fitness
  */
 public double getMicroClFitness() {
   return parameters.getMicroClFitness();
 } // end getMicroClFitness
Ejemplo n.º 29
0
 /**
  * Returns the probability of a classifier to be deleted.
  *
  * @return a double with the probability of being deleted.
  * @param avFitness is the average fitness of the set.
  */
 public double deletionVote(double avFitness) {
   return parameters.deletionVote(avFitness);
 } // end deletionVote
Ejemplo n.º 30
0
 /**
  * Sets the usefulTimes parameter
  *
  * @param value is the value that the useful param has to be set.
  */
 public void setUseful(int value) {
   parameters.setUsefulTimes(value);
 } // end setUseful