本文整理匯總了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);
}
}