weka.core.Utils.toCommandLine()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中weka.core.Utils.toCommandLine()方法的一些代码示例,展示了Utils.toCommandLine()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.toCommandLine()方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:toCommandLine

Utils.toCommandLine介绍

[英]Generates a commandline of the given object. If the object is not implementing OptionHandler, then it will only return the classname, otherwise also the options.
[中]生成给定对象的命令行。如果对象没有实现OptionHandler,那么它将只返回类名,否则也返回选项。

代码示例

代码示例来源:origin: net.sf.meka/meka

/**
 * Returns the commandline string for the object.
 *
 * @param obj           the object to generate the commandline for
 * @return              the commandline
 * @see                 Utils#toCommandLine(Object)
 */
public static String toCommandLine(Object obj) {
  return Utils.toCommandLine(obj);
}

代码示例来源:origin: Waikato/meka

/**
 * Returns the commandline string for the object.
 *
 * @param obj           the object to generate the commandline for
 * @return              the commandline
 * @see                 Utils#toCommandLine(Object)
 */
public static String toCommandLine(Object obj) {
  return Utils.toCommandLine(obj);
}

代码示例来源:origin: net.sf.meka/meka

/**
 * Returns the container setup as string.
 *
 * @return        the string
 */
@Override
public String toString() {
  if (m_Handler != null)
    return m_File.getAbsolutePath() + "\t" + Utils.toCommandLine(m_Handler);
  else
    return m_File.getAbsolutePath() + "\t";
}

代码示例来源:origin: net.sf.meka/meka

/**
 * Adds the OptionHandler to the options.
 *
 * @param options   the current list of options to extend
 * @param option    the option (without the leading dash)
 * @param value     the current value
 */
public static void add(List<String> options, String option, OptionHandler value) {
  options.add("-" + option);
  options.add("" + Utils.toCommandLine(value));
}

代码示例来源:origin: Waikato/meka

/**
 * Adds the OptionHandler to the options.
 *
 * @param options   the current list of options to extend
 * @param option    the option (without the leading dash)
 * @param value     the current value
 */
public static void add(List<String> options, String option, OptionHandler value) {
  options.add("-" + option);
  options.add("" + Utils.toCommandLine(value));
}

代码示例来源:origin: Waikato/meka

/**
 * Returns the container setup as string.
 *
 * @return        the string
 */
@Override
public String toString() {
  if (m_Handler != null)
    return m_File.getAbsolutePath() + "\t" + Utils.toCommandLine(m_Handler);
  else
    return m_File.getAbsolutePath() + "\t";
}

代码示例来源:origin: net.sf.meka/meka

/**
   * Returns the statistics as string.
   *
   * @return      the statistics
   */
  public String toString() {
    StringBuilder result = new StringBuilder();
    result.append("Classifier=").append(Utils.toCommandLine(m_Classifier)).append(",");
    result.append("Relation=").append(m_Relation).append(",");
    result.append(super.toString());
    return result.toString();
  }
}

代码示例来源:origin: Waikato/meka

/**
   * Returns the statistics as string.
   *
   * @return      the statistics
   */
  public String toString() {
    StringBuilder result = new StringBuilder();
    result.append("Classifier=").append(Utils.toCommandLine(m_Classifier)).append(",");
    result.append("Relation=").append(m_Relation).append(",");
    result.append(super.toString());
    return result.toString();
  }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
 List<String> options = new ArrayList<String>(Arrays.asList(super.getOptions()));
 for (StopwordsHandler handler: m_Stopwords) {
  options.add("-stopwords");
  options.add(Utils.toCommandLine(handler));
 }
 return options.toArray(new String[options.size()]);
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
@Override
public String[] getOptions() {
 List<String> options = new ArrayList<String>(Arrays.asList(super.getOptions()));
 for (StopwordsHandler handler: m_Stopwords) {
  options.add("-stopwords");
  options.add(Utils.toCommandLine(handler));
 }
 return options.toArray(new String[options.size()]);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns a string description of the model.
 *
 * @return        the model
 */
public String toString() {
 StringBuilder    result;
 result = new StringBuilder();
 result.append(getClass().getSimpleName()).append("\n");
 result.append(getClass().getSimpleName().replaceAll(".", "=")).append("\n\n");
 result.append("Force resample with weights: " + getForceResampleWithWeights() + "\n");
 result.append("Base classifier:\n");
 result.append("- command-line: " + Utils.toCommandLine(m_Classifier) + "\n");
 result.append("- handles instance weights: " + (m_Classifier instanceof WeightedInstancesHandler) + "\n\n");
 result.append(m_Classifier.toString());
 return result.toString();
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Returns a string description of the model.
 *
 * @return        the model
 */
public String toString() {
 StringBuilder    result;
 result = new StringBuilder();
 result.append(getClass().getSimpleName()).append("\n");
 result.append(getClass().getSimpleName().replaceAll(".", "=")).append("\n\n");
 result.append("Force resample with weights: " + getForceResampleWithWeights() + "\n");
 result.append("Base classifier:\n");
 result.append("- command-line: " + Utils.toCommandLine(m_Classifier) + "\n");
 result.append("- handles instance weights: " + (m_Classifier instanceof WeightedInstancesHandler) + "\n\n");
 result.append(m_Classifier.toString());
 return result.toString();
}

代码示例来源:origin: Waikato/meka

@Override
  public void actionPerformed(ActionEvent e) {
    String cmdline = Utils.toCommandLine(getClassifier(history, index));
    GUIHelper.copyToClipboard(cmdline);
  }
};

代码示例来源:origin: net.sf.meka/meka

@Override
  public void actionPerformed(ActionEvent e) {
    String cmdline = Utils.toCommandLine(getClassifier(history, index));
    GUIHelper.copyToClipboard(cmdline);
  }
};

代码示例来源:origin: net.sf.meka/meka

/**
 * Retrieves the statis for the specified combination of classifier and dataset.
 *
 * @param classifier    the classifier to check
 * @param dataset       the dataset to check
 * @return              the stats, null if not available
 */
public List<EvaluationStatistics> retrieve(MultiLabelClassifier classifier, Instances dataset) {
  List<EvaluationStatistics>  result;
  String                      cls;
  String                      rel;
  result = new ArrayList<>();
  cls = Utils.toCommandLine(classifier);
  rel = dataset.relationName();
  for (EvaluationStatistics stat: m_Statistics) {
    if (stat.getCommandLine().equals(cls) && stat.getRelation().equals(rel))
      result.add(stat);
  }
  return result;
}

代码示例来源:origin: Waikato/meka

@Override
 public void nextIteration(IterationNotificationEvent e) {
System.err.println("[ITERATION] " + Utils.toCommandLine(e.getClassifier()) + " --> " + e.getDataset().relationName());
 }
});

代码示例来源:origin: Waikato/meka

/**
 * Retrieves the statis for the specified combination of classifier and dataset.
 *
 * @param classifier    the classifier to check
 * @param dataset       the dataset to check
 * @return              the stats, null if not available
 */
public List<EvaluationStatistics> retrieve(MultiLabelClassifier classifier, Instances dataset) {
  List<EvaluationStatistics>  result;
  String                      cls;
  String                      rel;
  result = new ArrayList<>();
  cls = Utils.toCommandLine(classifier);
  rel = dataset.relationName();
  for (EvaluationStatistics stat: m_Statistics) {
    if (stat.getCommandLine().equals(cls) && stat.getRelation().equals(rel))
      result.add(stat);
  }
  return result;
}

代码示例来源:origin: Waikato/meka

/**
 * Checks whether the specified combination of classifier and dataset is required for evaluation
 * or already present from previous evaluation.
 *
 * @param classifier    the classifier to check
 * @param dataset       the dataset to check
 * @return              true if it needs evaluating
 */
public boolean requires(MultiLabelClassifier classifier, Instances dataset) {
  boolean     result;
  String      cls;
  String      rel;
  result = true;
  cls = Utils.toCommandLine(classifier);
  rel = dataset.relationName();
  for (EvaluationStatistics stat: m_Statistics) {
    if (stat.getCommandLine().equals(cls) && stat.getRelation().equals(rel)) {
      result = false;
      break;
    }
  }
  return result;
}
/**

代码示例来源:origin: net.sf.meka/meka

protected List<EvaluationStatistics> doCall() throws Exception {
    List<EvaluationStatistics> result = new ArrayList<>();
    log("Executing fold #" + index + "...");
    try {
      Result res = Evaluation.evaluateModel(current, train, test, m_Threshold, m_Verbosity);
      EvaluationStatistics stats = new EvaluationStatistics(classifier, dataset, res);
      stats.put(KEY_FOLD, index);
      result.add(stats);
    }
    catch (Exception e) {
      handleException(
          "Failed to evaluate dataset '" + dataset.relationName() + "' with classifier: " + Utils.toCommandLine(classifier), e);
    }
    log("...finished fold #" + index);
    return result;
  }
};

代码示例来源:origin: Waikato/meka

protected List<EvaluationStatistics> doCall() throws Exception {
    List<EvaluationStatistics> result = new ArrayList<>();
    log("Executing fold #" + index + "...");
    try {
      Result res = Evaluation.evaluateModel(current, train, test, m_Threshold, m_Verbosity);
      EvaluationStatistics stats = new EvaluationStatistics(classifier, dataset, res);
      stats.put(KEY_FOLD, index);
      result.add(stats);
    }
    catch (Exception e) {
      handleException(
          "Failed to evaluate dataset '" + dataset.relationName() + "' with classifier: " + Utils.toCommandLine(classifier), e);
    }
    log("...finished fold #" + index);
    return result;
  }
};

相关文章

微信公众号

最新文章

更多