Java 类weka.core.PartitionGenerator 实例源码

项目:seqcode-core    文件:AttributeBagging.java   
/**
 * Computes an array that indicates leaf membership
 */
@Override
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    ArrayList<double[]> al = new ArrayList<double[]>();
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      double[] r = ((PartitionGenerator)m_Classifiers[i]).
        getMembershipValues(inst);
      size += r.length;
      al.add(r);
    }
    double[] values = new double[size];
    int pos = 0;
    for (double[] v: al) {
      System.arraycopy(v, 0, values, pos, v.length);
      pos += v.length;
    }
    return values;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:RandomCommittee.java   
/**
 * Computes an array that indicates leaf membership
 */
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    ArrayList<double[]> al = new ArrayList<double[]>();
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      double[] r = ((PartitionGenerator)m_Classifiers[i]).
        getMembershipValues(inst);
      size += r.length;
      al.add(r);
    }
    double[] values = new double[size];
    int pos = 0;
    for (double[] v: al) {
      System.arraycopy(v, 0, values, pos, v.length);
      pos += v.length;
    }
    return values;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:Bagging.java   
/**
 * Computes an array that indicates leaf membership
 */
@Override
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    ArrayList<double[]> al = new ArrayList<double[]>();
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      double[] r = ((PartitionGenerator)m_Classifiers[i]).
        getMembershipValues(inst);
      size += r.length;
      al.add(r);
    }
    double[] values = new double[size];
    int pos = 0;
    for (double[] v: al) {
      System.arraycopy(v, 0, values, pos, v.length);
      pos += v.length;
    }
    return values;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:FilteredClassifier.java   
/**
 * Computes an array that has a value for each element in the partition. (If
 * the base classifier supports this.)
 */
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    Instance newInstance = filterInstance(inst);
    if (newInstance == null) {
      double[] unclassified = new double[numElements()];
      for (int i = 0; i < unclassified.length; i++) {
        unclassified[i] = Utils.missingValue();
      }
      return unclassified;
    } else {
      return ((PartitionGenerator) m_Classifier)
        .getMembershipValues(newInstance);
    }
  } else
    throw new Exception("Classifier: " + getClassifierSpec()
      + " cannot generate a partition");
}
项目:umple    文件:RandomCommittee.java   
/**
 * Computes an array that indicates leaf membership
 */
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    ArrayList<double[]> al = new ArrayList<double[]>();
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      double[] r = ((PartitionGenerator)m_Classifiers[i]).
        getMembershipValues(inst);
      size += r.length;
      al.add(r);
    }
    double[] values = new double[size];
    int pos = 0;
    for (double[] v: al) {
      System.arraycopy(v, 0, values, pos, v.length);
      pos += v.length;
    }
    return values;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:umple    文件:Bagging.java   
/**
 * Computes an array that indicates leaf membership
 */
@Override
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    ArrayList<double[]> al = new ArrayList<double[]>();
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      double[] r = ((PartitionGenerator)m_Classifiers[i]).
        getMembershipValues(inst);
      size += r.length;
      al.add(r);
    }
    double[] values = new double[size];
    int pos = 0;
    for (double[] v: al) {
      System.arraycopy(v, 0, values, pos, v.length);
      pos += v.length;
    }
    return values;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:umple    文件:FilteredClassifier.java   
/**
 * Computes an array that has a value for each element in the partition.
 * (If the base classifier supports this.)
 */
public double[] getMembershipValues(Instance inst) throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    Instance newInstance = filterInstance(inst);
    if (newInstance == null) {
      double[] unclassified = new double[numElements()];
      for (int i = 0; i < unclassified.length; i++) {
        unclassified[i] = Utils.missingValue();
      }
      return unclassified;
    } else {
      return ((PartitionGenerator)m_Classifier).getMembershipValues(newInstance);
    }
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:seqcode-core    文件:AttributeBagging.java   
/**
 * Builds the classifier to generate a partition.
 */
@Override
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:seqcode-core    文件:AttributeBagging.java   
/**
 * Returns the number of elements in the partition.
 */
@Override
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      size += ((PartitionGenerator)m_Classifiers[i]).numElements();
    }
    return size;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:RandomCommittee.java   
/**
 * Builds the classifier to generate a partition.
 */
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:RandomCommittee.java   
/**
 * Returns the number of elements in the partition.
 */
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      size += ((PartitionGenerator)m_Classifiers[i]).numElements();
    }
    return size;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:Bagging.java   
/**
 * Builds the classifier to generate a partition.
 */
@Override
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:Bagging.java   
/**
 * Returns the number of elements in the partition.
 */
@Override
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      size += ((PartitionGenerator)m_Classifiers[i]).numElements();
    }
    return size;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:FilteredClassifier.java   
/**
 * Builds the classifier to generate a partition. (If the base classifier
 * supports this.)
 */
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else
    throw new Exception("Classifier: " + getClassifierSpec()
      + " cannot generate a partition");
}
项目:repo.kmeanspp.silhouette_score    文件:FilteredClassifier.java   
/**
 * Returns the number of elements in the partition. (If the base classifier
 * supports this.)
 */
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    return ((PartitionGenerator) m_Classifier).numElements();
  else
    throw new Exception("Classifier: " + getClassifierSpec()
      + " cannot generate a partition");
}
项目:umple    文件:RandomCommittee.java   
/**
 * Builds the classifier to generate a partition.
 */
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:umple    文件:RandomCommittee.java   
/**
 * Returns the number of elements in the partition.
 */
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      size += ((PartitionGenerator)m_Classifiers[i]).numElements();
    }
    return size;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:umple    文件:Bagging.java   
/**
 * Builds the classifier to generate a partition.
 */
@Override
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:umple    文件:Bagging.java   
/**
 * Returns the number of elements in the partition.
 */
@Override
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator) {
    int size = 0;
    for (int i = 0; i < m_Classifiers.length; i++) {
      size += ((PartitionGenerator)m_Classifiers[i]).numElements();
    }
    return size;
  } else throw new Exception("Classifier: " + getClassifierSpec()
                             + " cannot generate a partition");
}
项目:umple    文件:FilteredClassifier.java   
/**
 * Builds the classifier to generate a partition.
 * (If the base classifier supports this.)
 */
public void generatePartition(Instances data) throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    buildClassifier(data);
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:umple    文件:FilteredClassifier.java   
/**
 * Returns the number of elements in the partition.
 * (If the base classifier supports this.)
 */
public int numElements() throws Exception {

  if (m_Classifier instanceof PartitionGenerator)
    return ((PartitionGenerator)m_Classifier).numElements();
  else throw new Exception("Classifier: " + getClassifierSpec()
         + " cannot generate a partition");
}
项目:umple    文件:PartitionMembership.java   
/**
 * Parses a given list of options.
 * <p/>
 * 
 * <!-- options-start --> Valid options are:
 * <p/>
 * 
 * <pre>
 * -W &lt;name of partition generator&gt;
 *  Full name of partition generator to use, e.g.:
 *   weka.classifiers.trees.J48
 *  Additional options after the '--'.
 *  (default: weka.classifiers.trees.J48)
 * </pre>
 * 
 * <!-- options-end -->
 * 
 * Options after the -- are passed on to the clusterer.
 * 
 * @param options the list of options as an array of strings
 * @throws Exception if an option is not supported
 */
@Override
public void setOptions(String[] options) throws Exception {

  String generatorString = Utils.getOption('W', options);
  if (generatorString.length() == 0) {
    generatorString = J48.class.getName();
  }
  setPartitionGenerator((PartitionGenerator) Utils.forName(
    PartitionGenerator.class, generatorString,
    Utils.partitionOptions(options)));

  Utils.checkForRemainingOptions(options);
}
项目:umple    文件:PartitionMembership.java   
/**
 * Set the generator for use in filtering
 * 
 * @param newPartitionGenerator the generator to use
 */
public void setPartitionGenerator(PartitionGenerator newPartitionGenerator) {
  m_partitionGenerator = newPartitionGenerator;
}
项目:umple    文件:PartitionMembership.java   
/**
 * Get the generator used by this filter
 * 
 * @return the generator used
 */
public PartitionGenerator getPartitionGenerator() {
  return m_partitionGenerator;
}