當前位置: 首頁>>代碼示例>>Java>>正文


Java Filter.makeCopy方法代碼示例

本文整理匯總了Java中weka.filters.Filter.makeCopy方法的典型用法代碼示例。如果您正苦於以下問題:Java Filter.makeCopy方法的具體用法?Java Filter.makeCopy怎麽用?Java Filter.makeCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在weka.filters.Filter的用法示例。


在下文中一共展示了Filter.makeCopy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: applyFilter

import weka.filters.Filter; //導入方法依賴的package包/類
/**
  * Passes the dataset through the filter that has been configured for use.
  * 
  * @param filter	the filter to apply
  */
 protected void applyFilter(final Filter filter) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
@Override
public void run() {
  try {

    if (filter != null) {
      m_FilterPanel.addToHistory();
    
      if (m_Log instanceof TaskLogger) {
	((TaskLogger)m_Log).taskStarted();
      }
      m_Log.statusMessage("Passing dataset through filter "
	  + filter.getClass().getName());
      String cmd = filter.getClass().getName();
      if (filter instanceof OptionHandler)
	cmd += " " + Utils.joinOptions(((OptionHandler) filter).getOptions());
      m_Log.logMessage("Command: " + cmd);
      int classIndex = m_AttVisualizePanel.getColoringIndex();
      if ((classIndex < 0) && (filter instanceof SupervisedFilter)) {
	throw new IllegalArgumentException("Class (colour) needs to " +
					   "be set for supervised " +
					   "filter.");
      }
      Instances copy = new Instances(m_Instances);
      copy.setClassIndex(classIndex);
      Filter filterCopy = Filter.makeCopy(filter);
      filterCopy.setInputFormat(copy);
      Instances newInstances = Filter.useFilter(copy, filterCopy);
      if (newInstances == null || newInstances.numAttributes() < 1) {
	throw new Exception("Dataset is empty.");
      }
      m_Log.statusMessage("Saving undo information");
      addUndoPoint();
      m_AttVisualizePanel.setColoringIndex(copy.classIndex());
      // if class was not set before, reset it again after use of filter
      if (m_Instances.classIndex() < 0)
	newInstances.setClassIndex(-1);
      m_Instances = newInstances;
      setInstances(m_Instances);
      if (m_Log instanceof TaskLogger) {
	((TaskLogger)m_Log).taskFinished();
      }
    }
    
  } catch (Exception ex) {

    if (m_Log instanceof TaskLogger) {
      ((TaskLogger)m_Log).taskFinished();
    }
    // Pop up an error optionpane
    JOptionPane.showMessageDialog(PreprocessPanel.this,
				  "Problem filtering instances:\n"
				  + ex.getMessage(),
				  "Apply Filter",
				  JOptionPane.ERROR_MESSAGE);
    m_Log.logMessage("Problem filtering instances: " + ex.getMessage());
    m_Log.statusMessage("Problem filtering instances");
  }
  m_IOThread = null;
}
     };
     m_IOThread.setPriority(Thread.MIN_PRIORITY); // UI has most priority
     m_IOThread.start();
   } else {
     JOptionPane.showMessageDialog(this,
			    "Can't apply filter at this time,\n"
			    + "currently busy with other IO",
			    "Apply Filter",
			    JOptionPane.WARNING_MESSAGE);
   }
 }
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:80,代碼來源:PreprocessPanel.java


注:本文中的weka.filters.Filter.makeCopy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。