Beispiel #1
0
 /**
  * Train the classifier with this instance.
  *
  * @param fv
  * @param clazz
  */
 public void train(FeatureVector<E> fv, E clazz) {
   if (!trained.contains(fv.getId())) {
     LabeledFeatureVector<E> lfv = new LabeledFeatureVector<E>(clazz, fv.getId());
     lfv.putAll(fv);
     lfv.setQid(fv.getQid());
     lfv.setRank(fv.getRank());
     train.add(lfv);
     trained.add(fv.getId());
   }
 }
Beispiel #2
0
  /**
   * Get the training data.
   *
   * @return
   */
  public TrainRelation<E> getTrainingData(E clazz) {
    TrainRelation<E> subRelation =
        new TrainRelation<E>("sub-relation", (Metadata) train.getMetadata().clone());
    for (LabeledFeatureVector<E> lfv : train) {
      if (lfv.getLabel().equals(clazz)) {
        subRelation.add(lfv);
      }
    }

    return subRelation;
  }