Java 类weka.core.OptionHandler 实例源码

项目:emr-nlp-server    文件:CertSVMPredictor.java   
public double[] predictInstanceDistribution(Reader reader) throws Exception {
    // assume that the file contains only 1 instance
    // load instances
    Instances data = new Instances(reader);
    // remove reportID attribute
    String[] options = weka.core.Utils.splitOptions("-R 1");  // removes the first attribute in instances (should be the document id?)
    String filterName = "weka.filters.unsupervised.attribute.Remove";
    Filter filter = (Filter) Class.forName(filterName).newInstance();
    if (filter instanceof OptionHandler) {
        ((OptionHandler) filter).setOptions(options);
    }
    filter.setInputFormat(data);
    // make the instances
    Instances unlabeled = Filter.useFilter(data, filter);

    double[][] dist = this.predictDataDistribution(unlabeled);
    return dist[0];
}
项目:emr-nlp-server    文件:CertSVMPredictor.java   
public void trainModelFromFile(String fnTrainData) throws Exception {
    // load instances
    Instances data = new Instances(new BufferedReader(new FileReader(fnTrainData)));
    // preprocess instances
    String[] options = weka.core.Utils.splitOptions("-R 1");
    String filterName = "weka.filters.unsupervised.attribute.Remove";
    Filter filter = (Filter) Class.forName(filterName).newInstance();
    if (filter instanceof OptionHandler) {
        ((OptionHandler) filter).setOptions(options);
    }
    filter.setInputFormat(data);
    // make the instances
    Instances unlabeled = Filter.useFilter(data, filter);
    // train model
    this.trainModel(unlabeled);
}
项目:repo.kmeanspp.silhouette_score    文件:WekaScoringHadoopJob.java   
/**
 * Loads the user-supplied model and sets the job name based on the classifier
 * and its options.
 * 
 * @param is InputStream to read the model from
 * @throws IOException if a problem occurs
 */
protected void loadClassifierAndSetJobName(InputStream is) throws IOException {
  ObjectInputStream ois = null;

  try {
    ois = new ObjectInputStream(new BufferedInputStream(is));

    Object model = ois.readObject();

    String className = model.getClass().toString();
    String options = "";
    if (model instanceof OptionHandler) {
      options = " " + Utils.joinOptions(((OptionHandler) model).getOptions());
    }

    setJobName("Scoring job: " + className + options);
  } catch (Exception ex) {
    throw new IOException(ex);
  } finally {
    if (ois != null) {
      ois.close();
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:HDFSSaver.java   
@Override
public String[] getOptions() {
  Vector<String> result = new Vector<String>();

  result.add("-dest"); //$NON-NLS-1$
  result.add(getHDFSPath());

  if (!DistributedJobConfig.isEmpty(getDFSReplicationFactor())) {
    result.add("-dfs-replication"); //$NON-NLS-1$
    result.add(getDFSReplicationFactor());
  }

  result.add("-saver"); //$NON-NLS-1$
  String saverSpec = m_delegate.getClass().getName();
  if (m_delegate != null) {
    saverSpec += " " //$NON-NLS-1$
      + Utils.joinOptions(((OptionHandler) m_delegate).getOptions());
  }
  result.add(saverSpec);

  for (String s : m_config.getOptions()) {
    result.add(s);
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:HDFSLoader.java   
@Override
public String[] getOptions() {
  Vector<String> result = new Vector<String>();

  result.add("-source");
  result.add(getHDFSPath());

  result.add("-loader");
  String loaderSpec = m_delegate.getClass().getName();
  if (m_delegate instanceof OptionHandler) {
    loaderSpec += " "
      + Utils.joinOptions(((OptionHandler) m_delegate).getOptions());
  }
  result.add(loaderSpec);

  for (String s : m_config.getOptions()) {
    result.add(s);
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:MakePreconstructedFilter.java   
/**
 * Set the options for this filter
 * 
 * @param options the options
 * @throws Exception if a problem occurs
 */
public void setOptions(String[] options) throws Exception {
  String filterSpec = Utils.getOption("filter", options);

  if (!DistributedJobConfig.isEmpty(filterSpec)) {
    String[] spec = Utils.splitOptions(filterSpec);
    String filterClass = spec[0];
    spec[0] = "";

    Filter base = (Filter) Class.forName(filterClass).newInstance();
    if (base instanceof OptionHandler) {
      ((OptionHandler) base).setOptions(spec);
    }

    setBaseFilter(base);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:KMeansMapTask.java   
@Override
public void setOptions(String[] options) throws Exception {
  setDontReplaceMissingValues(Utils.getFlag("dont-replace-missing", options));

  m_filtersToUse = new ArrayList<Filter>();
  while (true) {
    String filterString = Utils.getOption("filter", options);
    if (DistributedJobConfig.isEmpty(filterString)) {
      break;
    }

    String[] spec = Utils.splitOptions(filterString);
    if (spec.length == 0) {
      throw new IllegalArgumentException(
        "Invalid filter specification string");
    }
    String filterClass = spec[0];
    Filter f = (Filter) Class.forName(filterClass).newInstance();
    spec[0] = "";
    if (f instanceof OptionHandler) {
      ((OptionHandler) f).setOptions(spec);
    }
    m_filtersToUse.add(f);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:MakeDensityBasedClusterer.java   
/**
 * Gets the current settings of the clusterer.
 * 
 * @return an array of strings suitable for passing to setOptions()
 */
@Override
public String[] getOptions() {

  Vector<String> options = new Vector<String>();

  options.add("-M");
  options.add("" + getMinStdDev());

  if (getClusterer() != null) {
    options.add("-W");
    options.add(getClusterer().getClass().getName());
    if (m_wrappedClusterer instanceof OptionHandler) {
      String[] clustererOptions = ((OptionHandler) m_wrappedClusterer)
        .getOptions();
      if (clustererOptions.length > 0) {
        options.add("--");
        Collections.addAll(options, clustererOptions);
      }
    }
  }

  Collections.addAll(options, super.getOptions());

  return options.toArray(new String[0]);
}
项目:repo.kmeanspp.silhouette_score    文件:SingleClustererEnhancer.java   
/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
  Vector<Option> result = new Vector<Option>();

  result.addElement(new Option("\tFull name of base clusterer.\n"
    + "\t(default: " + defaultClustererString() + ")", "W", 1, "-W"));

  result.addAll(Collections.list(super.listOptions()));

  if (m_Clusterer instanceof OptionHandler) {
    result.addElement(new Option("", "", 0,
      "\nOptions specific to clusterer " + m_Clusterer.getClass().getName()
        + ":"));

    result.addAll(Collections.list(((OptionHandler) m_Clusterer)
      .listOptions()));
  }

  return result.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:SingleClustererEnhancer.java   
/**
 * Gets the current settings of the clusterer.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  Vector<String> result = new Vector<String>();

  result.add("-W");
  result.add(getClusterer().getClass().getName());

  Collections.addAll(result, super.getOptions());

  if (getClusterer() instanceof OptionHandler) {
    String[] options = ((OptionHandler) getClusterer()).getOptions();

    if (options.length > 0) {
      result.add("--");
    }
    Collections.addAll(result, options);
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:CheckClusterer.java   
/**
 * Gets the current settings of the CheckClusterer.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  Vector<String> result = new Vector<String>();

  if (getClusterer() != null) {
    result.add("-W");
    result.add(getClusterer().getClass().getName());
  }

  Collections.addAll(result, super.getOptions());

  if ((m_Clusterer != null) && (m_Clusterer instanceof OptionHandler)) {
    String[] options = ((OptionHandler) m_Clusterer).getOptions();

    if (options.length > 0) {
      result.add("--");
      Collections.addAll(result, options);
    }
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:CheckClusterer.java   
/**
 * Checks whether the scheme can take command line options.
 * 
 * @return index 0 is true if the clusterer can take options
 */
protected boolean[] canTakeOptions() {

  boolean[] result = new boolean[2];

  print("options...");
  if (m_Clusterer instanceof OptionHandler) {
    println("yes");
    if (m_Debug) {
      println("\n=== Full report ===");
      Enumeration<Option> enu = ((OptionHandler) m_Clusterer).listOptions();
      while (enu.hasMoreElements()) {
        Option option = enu.nextElement();
        print(option.synopsis() + "\n" + option.description() + "\n");
      }
      println("\n");
    }
    result[0] = true;
  } else {
    println("no");
    result[0] = false;
  }

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:CheckAssociator.java   
/**
 * Gets the current settings of the CheckAssociator.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  Vector<String> result = new Vector<String>();

  Collections.addAll(result, super.getOptions());

  if (getAssociator() != null) {
    result.add("-W");
    result.add(getAssociator().getClass().getName());
  }

  if ((m_Associator != null) && (m_Associator instanceof OptionHandler)) {
    String[] options = ((OptionHandler) m_Associator).getOptions();

    if (options.length > 0) {
      result.add("--");
      Collections.addAll(result, options);
    }
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:CheckAssociator.java   
/**
 * Checks whether the scheme can take command line options.
 * 
 * @return index 0 is true if the associator can take options
 */
protected boolean[] canTakeOptions() {

  boolean[] result = new boolean[2];

  print("options...");
  if (m_Associator instanceof OptionHandler) {
    println("yes");
    if (m_Debug) {
      println("\n=== Full report ===");
      Enumeration<Option> enu = ((OptionHandler) m_Associator).listOptions();
      while (enu.hasMoreElements()) {
        Option option = enu.nextElement();
        print(option.synopsis() + "\n" + option.description() + "\n");
      }
      println("\n");
    }
    result[0] = true;
  } else {
    println("no");
    result[0] = false;
  }

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:SingleAssociatorEnhancer.java   
/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
  Vector<Option> result = new Vector<Option>();

  result.addElement(new Option("\tFull name of base associator.\n"
    + "\t(default: " + defaultAssociatorString() + ")", "W", 1, "-W"));

  if (m_Associator instanceof OptionHandler) {
    result.addElement(new Option("", "", 0,
      "\nOptions specific to associator " + m_Associator.getClass().getName()
        + ":"));

    result.addAll(Collections.list(((OptionHandler) m_Associator)
      .listOptions()));
  }

  return result.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:SingleAssociatorEnhancer.java   
/**
 * Gets the current settings of the associator.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  int i;
  Vector<String> result;
  String[] options;

  result = new Vector<String>();

  result.add("-W");
  result.add(getAssociator().getClass().getName());

  if (getAssociator() instanceof OptionHandler) {
    options = ((OptionHandler) getAssociator()).getOptions();
    result.add("--");
    for (i = 0; i < options.length; i++) {
      result.add(options[i]);
    }
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:FilteredClassifier.java   
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
public Enumeration<Option> listOptions() {

  Vector<Option> newVector = new Vector<Option>(1);
  newVector.addElement(new Option(
    "\tFull class name of filter to use, followed\n"
      + "\tby filter options.\n"
      + "\teg: \"weka.filters.unsupervised.attribute.Remove -V -R 1,2\"",
    "F", 1, "-F <filter specification>"));

  newVector.addAll(Collections.list(super.listOptions()));

  if (getFilter() instanceof OptionHandler) {
    newVector.addElement(new Option("", "", 0,
      "\nOptions specific to filter " + getFilter().getClass().getName()
        + ":"));
    newVector.addAll(Collections.list(((OptionHandler) getFilter())
      .listOptions()));
  }

  return newVector.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:CVParameterSelection.java   
/**
  * Gets the current settings of the Classifier.
  *
  * @return an array of strings suitable for passing to setOptions
  */
 public String [] getOptions() {

   Vector<String> options = new Vector<String>();

   if (m_InitOptions != null) {
     try {
((OptionHandler)m_Classifier).setOptions((String[])m_InitOptions.clone());
((OptionHandler)m_Classifier).setOptions((String[])m_BestClassifierOptions.clone());
     } catch (Exception e) {
throw new RuntimeException("CVParameterSelection: could not set options " +
               "in getOptions().");
     } 
   }
   for (int i = 0; i < m_CVParams.size(); i++) {
     options.add("-P"); options.add("" + getCVParameter(i));
   }
   options.add("-X"); options.add("" + getNumFolds());

   Collections.addAll(options, super.getOptions());

   return options.toArray(new String[0]);
 }
项目:repo.kmeanspp.silhouette_score    文件:Stacking.java   
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
public Enumeration<Option> listOptions() {

  Vector<Option> newVector = new Vector<Option>(2);
  newVector.addElement(new Option(
     metaOption(),
     "M", 0, "-M <scheme specification>"));
  newVector.addElement(new Option(
     "\tSets the number of cross-validation folds.",
     "X", 1, "-X <number of folds>"));

  newVector.addAll(Collections.list(super.listOptions()));

  if (getMetaClassifier() instanceof OptionHandler) {
    newVector.addElement(new Option(
      "",
      "", 0, "\nOptions specific to meta classifier "
        + getMetaClassifier().getClass().getName() + ":"));
    newVector.addAll(Collections.list(((OptionHandler)getMetaClassifier()).listOptions()));
  }
  return newVector.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:Stacking.java   
/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
public String [] getOptions() {

  String [] superOptions = super.getOptions();
  String [] options = new String [superOptions.length + 4];

  int current = 0;
  options[current++] = "-X"; options[current++] = "" + getNumFolds();
  options[current++] = "-M";
  options[current++] = getMetaClassifier().getClass().getName() + " "
    + Utils.joinOptions(((OptionHandler)getMetaClassifier()).getOptions());

  System.arraycopy(superOptions, 0, options, current, 
     superOptions.length);
  return options;
}
项目:repo.kmeanspp.silhouette_score    文件:RandomizableFilteredClassifier.java   
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
public Enumeration<Option> listOptions() {

  Vector<Option> newVector = new Vector<Option>(1);

  newVector.addElement(new Option(
        "\tRandom number seed.\n"
        + "\t(default 1)",
        "S", 1, "-S <num>"));

  newVector.addAll(Collections.list(super.listOptions()));

  if (getFilter() instanceof OptionHandler) {
    newVector.addElement(new Option(
      "",
      "", 0, "\nOptions specific to filter "
        + getFilter().getClass().getName() + ":"));
    newVector.addAll(Collections.list(((OptionHandler)getFilter()).listOptions()));
  }

  return newVector.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:RegressionSplitEvaluator.java   
/**
 * Updates the options that the current classifier is using.
 */
protected void updateOptions() {

  if (m_Template instanceof OptionHandler) {
    m_ClassifierOptions = Utils.joinOptions(((OptionHandler) m_Template)
      .getOptions());
  } else {
    m_ClassifierOptions = "";
  }
  if (m_Template instanceof Serializable) {
    ObjectStreamClass obs = ObjectStreamClass.lookup(m_Template.getClass());
    m_ClassifierVersion = "" + obs.getSerialVersionUID();
  } else {
    m_ClassifierVersion = "";
  }
}
项目:repo.kmeanspp.silhouette_score    文件:MultipleClassifiersCombiner.java   
/**
 * Returns an enumeration describing the available options
 *
 * @return an enumeration of all the available options
 */
public Enumeration<Option> listOptions() {

  Vector<Option> newVector = new Vector<Option>(1);

  newVector.addElement(new Option(
        "\tFull class name of classifier to include, followed\n"
        + "\tby scheme options. May be specified multiple times.\n"
        + "\t(default: \"weka.classifiers.rules.ZeroR\")",
        "B", 1, "-B <classifier specification>"));

  newVector.addAll(Collections.list(super.listOptions()));

  for (Classifier classifier : getClassifiers()) {
    if (classifier instanceof OptionHandler) {
      newVector.addElement(new Option(
        "",
        "", 0, "\nOptions specific to classifier "
          + classifier.getClass().getName() + ":"));
      newVector.addAll(Collections.list(((OptionHandler)classifier).listOptions()));
    }
  }

  return newVector.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:CheckClassifier.java   
/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
  Vector<Option> result = new Vector<Option>();

  result.addAll(Collections.list(super.listOptions()));

  result.add(new Option("\tFull name of the classifier analysed.\n"
    + "\teg: weka.classifiers.bayes.NaiveBayes\n"
    + "\t(default weka.classifiers.rules.ZeroR)", "W", 1, "-W"));

  if ((m_Classifier != null) && (m_Classifier instanceof OptionHandler)) {
    result.add(new Option("", "", 0, "\nOptions specific to classifier "
      + m_Classifier.getClass().getName() + ":"));
    result.addAll(Collections.list(((OptionHandler) m_Classifier)
      .listOptions()));
  }

  return result.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:CheckClassifier.java   
/**
 * Gets the current settings of the CheckClassifier.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  Vector<String> result;
  String[] options;

  result = new Vector<String>();

  Collections.addAll(result, super.getOptions());

  if (getClassifier() != null) {
    result.add("-W");
    result.add(getClassifier().getClass().getName());
  }

  if ((m_Classifier != null) && (m_Classifier instanceof OptionHandler)) {

    options = ((OptionHandler) m_Classifier).getOptions();
    if (options.length > 0) {
      result.add("--");
      Collections.addAll(result, options);
    }
  }

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:CheckClassifier.java   
/**
 * Checks whether the scheme can take command line options.
 * 
 * @return index 0 is true if the classifier can take options
 */
protected boolean[] canTakeOptions() {

  boolean[] result = new boolean[2];

  print("options...");
  if (m_Classifier instanceof OptionHandler) {
    println("yes");
    if (m_Debug) {
      println("\n=== Full report ===");
      Enumeration<Option> enu = ((OptionHandler) m_Classifier).listOptions();
      while (enu.hasMoreElements()) {
        Option option = enu.nextElement();
        print(option.synopsis() + "\n" + option.description() + "\n");
      }
      println("\n");
    }
    result[0] = true;
  } else {
    println("no");
    result[0] = false;
  }

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:SingleClassifierEnhancer.java   
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
public Enumeration<Option> listOptions() {

  Vector<Option> newVector = new Vector<Option>(3);

  newVector.addElement(new Option(
        "\tFull name of base classifier.\n"
        + "\t(default: " + defaultClassifierString() + 
        ((defaultClassifierOptions().length > 0) ? 
         " with options " + Utils.joinOptions(defaultClassifierOptions()) + ")" : ")"),
        "W", 1, "-W"));

  newVector.addAll(Collections.list(super.listOptions()));

  newVector.addElement(new Option(
        "",
        "", 0, "\nOptions specific to classifier "
        + m_Classifier.getClass().getName() + ":"));
  newVector.addAll(Collections.list(((OptionHandler)m_Classifier).listOptions()));

  return newVector.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:CheckKernel.java   
/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
  Vector<Option> result = new Vector<Option>();

  result.addElement(new Option("\tFull name of the kernel analysed.\n"
    + "\teg: weka.classifiers.functions.supportVector.RBFKernel\n"
    + "\t(default weka.classifiers.functions.supportVector.RBFKernel)", "W",
    1, "-W"));

  result.addAll(Collections.list(super.listOptions()));

  if ((m_Kernel != null) && (m_Kernel instanceof OptionHandler)) {
    result.addElement(new Option("", "", 0, "\nOptions specific to kernel "
      + m_Kernel.getClass().getName() + ":"));
    result.addAll(Collections.list(((OptionHandler) m_Kernel).listOptions()));
  }

  return result.elements();
}
项目:repo.kmeanspp.silhouette_score    文件:RegressionSplitEvaluator.java   
/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  Vector<String> result;
  String[] classifierOptions;

  result = new Vector<String>();

  classifierOptions = new String[0];
  if ((m_Template != null) && (m_Template instanceof OptionHandler)) {
    classifierOptions = ((OptionHandler) m_Template).getOptions();
  }

  if (getNoSizeDetermination()) {
    result.add("-no-size");
  }

  if (getClassifier() != null) {
    result.add("-W");
    result.add(getClassifier().getClass().getName());
  }
  result.add("--");
  result.addAll(Arrays.asList(classifierOptions));

  return result.toArray(new String[result.size()]);
}
项目:repo.kmeanspp.silhouette_score    文件:ClusterMembership.java   
/**
 * Gets the current settings of the filter.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {

  Vector<String> options = new Vector<String>();

  if (!getIgnoredAttributeIndices().equals("")) {
    options.add("-I");
    options.add(getIgnoredAttributeIndices());
  }

  if (m_clusterer != null) {
    options.add("-W");
    options.add(getDensityBasedClusterer().getClass().getName());
  }

  if ((m_clusterer != null) && (m_clusterer instanceof OptionHandler)) {
    String[] clustererOptions = ((OptionHandler) m_clusterer).getOptions();
    if (clustererOptions.length > 0) {
      options.add("--");
      Collections.addAll(options, clustererOptions);
    }
  }
  return options.toArray(new String[0]);
}
项目:repo.kmeanspp.silhouette_score    文件:ClassifierSplitEvaluator.java   
/**
 * Updates the options that the current classifier is using.
 */
protected void updateOptions() {

  if (m_Template instanceof OptionHandler) {
    m_ClassifierOptions = Utils.joinOptions(((OptionHandler) m_Template)
      .getOptions());
  } else {
    m_ClassifierOptions = "";
  }
  if (m_Template instanceof Serializable) {
    ObjectStreamClass obs = ObjectStreamClass.lookup(m_Template.getClass());
    m_ClassifierVersion = "" + obs.getSerialVersionUID();
  } else {
    m_ClassifierVersion = "";
  }
}
项目:repo.kmeanspp.silhouette_score    文件:AlgorithmListPanel.java   
/**
 * Return a component that has been configured to display the specified
 * value. That component's paint method is then called to "render" the cell.
 * If it is necessary to compute the dimensions of a list because the list
 * cells do not have a fixed size, this method is called to generate a
 * component on which getPreferredSize can be invoked.
 * 
 * @param list The JList we're painting.
 * @param value The value returned by list.getModel().getElementAt(index).
 * @param index The cells index.
 * @param isSelected True if the specified cell was selected.
 * @param cellHasFocus True if the specified cell has the focus.
 * @return A component whose paint() method will render the specified value.
 */
@Override
public Component getListCellRendererComponent(JList list, Object value,
  int index, boolean isSelected, boolean cellHasFocus) {

  Component c = super.getListCellRendererComponent(list, value, index,
    isSelected, cellHasFocus);
  String rep = value.getClass().getName();
  int dotPos = rep.lastIndexOf('.');
  if (dotPos != -1) {
    rep = rep.substring(dotPos + 1);
  }
  if (value instanceof OptionHandler) {
    rep += " " + Utils.joinOptions(((OptionHandler) value).getOptions());
  }
  setText(rep);
  return c;
}
项目:repo.kmeanspp.silhouette_score    文件:DensityBasedClustererSplitEvaluator.java   
/**
 * Parses a given list of options. Valid options are:
 * <p>
 *
 * -W classname <br>
 * Specify the full class name of the clusterer to evaluate.
 * <p>
 *
 * All option after -- will be passed to the classifier.
 *
 * @param options the list of options as an array of strings
 * @exception Exception if an option is not supported
 */
@Override
public void setOptions(String[] options) throws Exception {
  m_NoSizeDetermination = Utils.getFlag("no-size", options);

  String cName = Utils.getOption('W', options);
  if (cName.length() == 0) {
    throw new Exception("A clusterer must be specified with"
      + " the -W option.");
  }
  // Do it first without options, so if an exception is thrown during
  // the option setting, listOptions will contain options for the actual
  // Classifier.
  setClusterer((DensityBasedClusterer) AbstractClusterer.forName(cName, null));
  if (getClusterer() instanceof OptionHandler) {
    ((OptionHandler) getClusterer()).setOptions(Utils
      .partitionOptions(options));
    updateOptions();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:MultiFilter.java   
/**
 * returns the filter classname and the options as one string
 * 
 * @param filter the filter to get the specs for
 * @return the classname plus options
 */
protected String getFilterSpec(Filter filter) {
  String result;

  if (filter == null) {
    result = "";
  } else {
    result = filter.getClass().getName();
    if (filter instanceof OptionHandler) {
      result += " "
        + Utils.joinOptions(((OptionHandler) filter).getOptions());
    }
  }

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:RegressionSplitEvaluator.java   
/**
 * Returns an enumeration describing the available options..
 *
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {

  Vector<Option> newVector = new Vector<Option>(2);

  newVector.addElement(new Option(
    "\tSkips the determination of sizes (train/test/classifier)\n"
      + "\t(default: sizes are determined)", "no-size", 0, "-no-size"));
  newVector
    .addElement(new Option("\tThe full class name of the classifier.\n"
      + "\teg: weka.classifiers.bayes.NaiveBayes", "W", 1, "-W <class name>"));

  if ((m_Template != null) && (m_Template instanceof OptionHandler)) {
    newVector.addElement(new Option("", "", 0,
      "\nOptions specific to classifier " + m_Template.getClass().getName()
        + ":"));
    newVector.addAll(Collections.list(((OptionHandler) m_Template)
      .listOptions()));
  }
  return newVector.elements();
}
项目:emr-nlp-server    文件:SVMPredictor.java   
public Instances removeAttribute(String attrIndex, Instances data) throws Exception {
    String[] options = weka.core.Utils.splitOptions("-R " + attrIndex);
    String filterName = "weka.filters.unsupervised.attribute.Remove";
    Filter filter = (Filter) Class.forName(filterName).newInstance();
    if (filter instanceof OptionHandler) {
        ((OptionHandler) filter).setOptions(options);
    }
    filter.setInputFormat(data);
    // make the instances
    return Filter.useFilter(data, filter);
}
项目:anti-spam-weka-gui    文件:FilterConfiguration.java   
private static Filter buildAttributeFilterFor(AttributeFilter attributeFilter, Instances dataSet) throws Exception
{
    ASEvaluation evaluator = attributeFilter.getEvalClazz().newInstance();
    ((OptionHandler) evaluator).setOptions(Utils.splitOptions(attributeFilter.getEvalConfig()));

    ASSearch search = attributeFilter.getSearchClazz().newInstance();
    ((OptionHandler) search).setOptions(Utils.splitOptions(attributeFilter.getSearchConfig()));

    Filter filter = new AttributeSelection();
    filter.setInputFormat(dataSet);
    ((AttributeSelection) filter).setEvaluator(evaluator);
    ((AttributeSelection) filter).setSearch(search);

    return filter;
}
项目:repo.kmeanspp.silhouette_score    文件:Associator.java   
private void buildAssociations(Instances data) throws Exception {

    // see if there is an environment variable with
    // options for the associator
    if (m_env != null && m_Associator instanceof OptionHandler) {
      String opts = m_env
        .getVariableValue("weka.gui.beans.associator.schemeOptions");
      if (opts != null && opts.length() > 0) {
        String[] options = Utils.splitOptions(opts);
        if (options.length > 0) {
          try {
            ((OptionHandler) m_Associator).setOptions(options);
          } catch (Exception ex) {
            String warningMessage = "[Associator] WARNING: unable to set options \""
              + opts + "\"for " + m_Associator.getClass().getName();
            if (m_log != null) {
              m_log.logMessage(warningMessage);
            } else {
              System.err.print(warningMessage);
            }
          }
        }
      }
    }

    m_Associator.buildAssociations(data);
  }
项目:repo.kmeanspp.silhouette_score    文件:AggregateableFilteredClassifier.java   
/**
 * Gets the filter specification string, which contains the class name of the
 * filter and any options to the filter
 * 
 * @return the filter string.
 */
protected String getFilterSpec() {

  Filter c = getPreConstructedFilter();
  if (c instanceof OptionHandler) {
    return c.getClass().getName() + " "
      + Utils.joinOptions(((OptionHandler) c).getOptions());
  }
  return c.getClass().getName();
}
项目:repo.kmeanspp.silhouette_score    文件:CheckEstimator.java   
/**
 * Gets the current settings of the CheckEstimator.
 * 
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
  Vector<String> result = new Vector<String>();

  if (getDebug()) {
    result.add("-D");
  }

  if (getSilent()) {
    result.add("-S");
  }

  result.add("-N");
  result.add("" + getNumInstances());

  if (getEstimator() != null) {
    result.add("-W");
    result.add(getEstimator().getClass().getName());
  }

  if ((m_Estimator != null) && (m_Estimator instanceof OptionHandler)) {
    String[] options = ((OptionHandler) m_Estimator).getOptions();

    if (options.length > 0) {
      result.add("--");
      Collections.addAll(result, options);
    }
  }

  return result.toArray(new String[result.size()]);
}