本文整理匯總了Java中weka.filters.Filter.output方法的典型用法代碼示例。如果您正苦於以下問題:Java Filter.output方法的具體用法?Java Filter.output怎麽用?Java Filter.output使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.filters.Filter
的用法示例。
在下文中一共展示了Filter.output方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: useFilter
import weka.filters.Filter; //導入方法依賴的package包/類
/**
* Filters an entire set of instances through a filter and returns the new
* set.
*
* @param data the data to be filtered
* @param filter the filter to be used
* @return the filtered set of data
* @throws Exception if the filter can't be used successfully
*/
public static Instances useFilter(Instances data, Filter filter)
throws Exception {
/*
* System.err.println(filter.getClass().getName() + " in:" +
* data.numInstances());
*/
for (int i = 0; i < data.numInstances(); i++) {
filter.input(data.instance(i));
}
filter.batchFinished();
Instances newData = filter.getOutputFormat();
Instance processed;
while ((processed = filter.output()) != null) {
newData.add(processed);
}
/*
* System.err.println(filter.getClass().getName() + " out:" +
* newData.numInstances());
*/
return newData;
}
示例2: clusterProcessedInstance
import weka.filters.Filter; //導入方法依賴的package包/類
public int clusterProcessedInstance(Filter preprocess, Instance inst,
boolean updateDistanceFunction, long[] instanceCanopies) throws Exception {
if (preprocess != null) {
preprocess.input(inst);
inst = preprocess.output();
}
if (updateDistanceFunction) {
m_DistanceFunction.update(inst);
}
double minDist = Integer.MAX_VALUE;
int bestCluster = 0;
// no fast distance calculations in this version as we
// need the within cluster errors
for (int i = 0; i < m_NumClusters; i++) {
double dist;
if (m_speedUpDistanceCompWithCanopies && instanceCanopies != null
&& instanceCanopies.length > 0) {
try {
if (!Canopy.nonEmptyCanopySetIntersection(
m_centroidCanopyAssignments.get(i), instanceCanopies)) {
continue;
}
} catch (Exception ex) {
ex.printStackTrace();
}
dist =
m_DistanceFunction.distance(inst, m_ClusterCentroids.instance(i));
} else {
dist =
m_DistanceFunction.distance(inst, m_ClusterCentroids.instance(i));
}
if (dist < minDist) {
minDist = dist;
bestCluster = i;
}
}
if (m_DistanceFunction instanceof EuclideanDistance) {
// Euclidean distance to Squared Euclidean distance
minDist *= minDist * inst.weight();
}
m_squaredErrors[bestCluster] += minDist;
return bestCluster;
}