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


Java Classifier.toString方法代碼示例

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


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

示例1: testAggregatingAggregateableClassifiers

import weka.classifiers.Classifier; //導入方法依賴的package包/類
@Test
public void testAggregatingAggregateableClassifiers() throws Exception {
  Instances train = new Instances(new BufferedReader(new StringReader(
    CorrelationMatrixMapTaskTest.IRIS)));

  train.setClassIndex(train.numAttributes() - 1);
  WekaClassifierMapTask task = setupAggregateableBatchClassifier();
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c1 = task.getClassifier();
  String c1S = c1.toString();

  task = setupAggregateableBatchClassifier();
  task.setUseReservoirSamplingWhenBatchLearning(true);
  task.setReservoirSampleSize(75);
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c2 = task.getClassifier();
  String c2S = c2.toString();

  // different classifiers
  assertFalse(c1S.equals(c2S));

  WekaClassifierReduceTask reduce = new WekaClassifierReduceTask();
  List<Classifier> toAgg = new ArrayList<Classifier>();
  toAgg.add(c1);
  toAgg.add(c2);
  Classifier aggregated = reduce.aggregate(toAgg);
  String aggregatedS = aggregated.toString();

  // aggregated classifier differs from both base classifier
  assertFalse(aggregatedS.equals(c1S));
  assertFalse(aggregatedS.equals(c2S));
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:45,代碼來源:WekaClassifierTaskTest.java

示例2: testAggregatingNonAggregateableClassifiers

import weka.classifiers.Classifier; //導入方法依賴的package包/類
@Test
public void testAggregatingNonAggregateableClassifiers() throws Exception {
  Instances train = new Instances(new BufferedReader(new StringReader(
    CorrelationMatrixMapTaskTest.IRIS)));

  train.setClassIndex(train.numAttributes() - 1);
  WekaClassifierMapTask task = setupBatchClassifier();
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c1 = task.getClassifier();
  String c1S = c1.toString();

  task = setupBatchClassifier();
  task.setUseReservoirSamplingWhenBatchLearning(true);
  task.setReservoirSampleSize(75);
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c2 = task.getClassifier();
  String c2S = c2.toString();

  // different classifiers
  assertFalse(c1S.equals(c2S));

  WekaClassifierReduceTask reduce = new WekaClassifierReduceTask();
  List<Classifier> toAgg = new ArrayList<Classifier>();
  toAgg.add(c1);
  toAgg.add(c2);
  Classifier aggregated = reduce.aggregate(toAgg);

  assertTrue(aggregated instanceof Vote);
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:42,代碼來源:WekaClassifierTaskTest.java

示例3: testAggregatingAggregateableClassifiersForceVote

import weka.classifiers.Classifier; //導入方法依賴的package包/類
@Test
public void testAggregatingAggregateableClassifiersForceVote()
  throws Exception {
  Instances train = new Instances(new BufferedReader(new StringReader(
    CorrelationMatrixMapTaskTest.IRIS)));

  train.setClassIndex(train.numAttributes() - 1);
  WekaClassifierMapTask task = setupAggregateableBatchClassifier();
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c1 = task.getClassifier();
  String c1S = c1.toString();

  task = setupAggregateableBatchClassifier();
  task.setUseReservoirSamplingWhenBatchLearning(true);
  task.setReservoirSampleSize(75);
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c2 = task.getClassifier();
  String c2S = c2.toString();

  // different classifiers
  assertFalse(c1S.equals(c2S));

  WekaClassifierReduceTask reduce = new WekaClassifierReduceTask();
  List<Classifier> toAgg = new ArrayList<Classifier>();
  toAgg.add(c1);
  toAgg.add(c2);
  Classifier aggregated = reduce.aggregate(toAgg, null, true);

  assertTrue(aggregated instanceof Vote);
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:43,代碼來源:WekaClassifierTaskTest.java

示例4: testAggregatingWithMinTrainingFraction

import weka.classifiers.Classifier; //導入方法依賴的package包/類
@Test
public void testAggregatingWithMinTrainingFraction() throws Exception {
  Instances train = new Instances(new BufferedReader(new StringReader(
    CorrelationMatrixMapTaskTest.IRIS)));

  train.setClassIndex(train.numAttributes() - 1);
  WekaClassifierMapTask task = setupAggregateableBatchClassifier();
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c1 = task.getClassifier();
  String c1S = c1.toString();

  task = setupAggregateableBatchClassifier();
  task.setUseReservoirSamplingWhenBatchLearning(true);
  task.setReservoirSampleSize(75);
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c2 = task.getClassifier();
  String c2S = c2.toString();

  // different classifiers
  assertFalse(c1S.equals(c2S));

  task = setupAggregateableBatchClassifier();
  task.setUseReservoirSamplingWhenBatchLearning(true);
  task.setReservoirSampleSize(60);
  task.setup(new Instances(train, 0));

  for (int i = 0; i < train.numInstances(); i++) {
    task.processInstance(train.instance(i));
  }
  task.finalizeTask();

  Classifier c3 = task.getClassifier();
  WekaClassifierReduceTask reduce = new WekaClassifierReduceTask();
  List<Classifier> toAgg = new ArrayList<Classifier>();
  toAgg.add(c1);
  toAgg.add(c2);
  toAgg.add(c3);

  reduce.setMinTrainingFraction(0.5);
  List<Integer> numTraining = new ArrayList<Integer>();
  numTraining.add(150);
  numTraining.add(75);
  numTraining.add(60);

  Classifier aggregated = reduce.aggregate(toAgg, numTraining, false);

  assertFalse(aggregated instanceof Vote);

  List<Integer> discarded = reduce.getDiscarded();
  assertTrue(discarded != null);

  // should be one classifier discarded (< minTrainingFraction)
  assertTrue(discarded.size() == 1);
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:67,代碼來源:WekaClassifierTaskTest.java


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