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


Java Filter.output方法代碼示例

本文整理匯總了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;
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:32,代碼來源:Filter.java

示例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;
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:52,代碼來源:PreconstructedKMeans.java


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