当前位置: 首页>>代码示例>>Java>>正文


Java FastVector.appendElements方法代码示例

本文整理汇总了Java中weka.core.FastVector.appendElements方法的典型用法代码示例。如果您正苦于以下问题:Java FastVector.appendElements方法的具体用法?Java FastVector.appendElements怎么用?Java FastVector.appendElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.core.FastVector的用法示例。


在下文中一共展示了FastVector.appendElements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Tests the ThresholdCurve generation from the command line.
 * The classifier is currently hardcoded. Pipe in an arff file.
 *
 * @param args currently ignored
 */
public static void main(String [] args) {

  try {
    
    Instances inst = new Instances(new java.io.InputStreamReader(System.in));
    if (false) {
      System.out.println(ThresholdCurve.getNPointPrecision(inst, 11));
    } else {
      inst.setClassIndex(inst.numAttributes() - 1);
      ThresholdCurve tc = new ThresholdCurve();
      EvaluationUtils eu = new EvaluationUtils();
      Classifier classifier = new weka.classifiers.functions.Logistic();
      FastVector predictions = new FastVector();
      for (int i = 0; i < 2; i++) { // Do two runs.
        eu.setSeed(i);
        predictions.appendElements(eu.getCVPredictions(classifier, inst, 10));
        //System.out.println("\n\n\n");
      }
      Instances result = tc.getCurve(predictions);
      System.out.println(result);
    }
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:32,代码来源:ThresholdCurve.java

示例2: getCVPredictions

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Generate a bunch of predictions ready for processing, by performing a
 * cross-validation on the supplied dataset.
 *
 * @param classifier the Classifier to evaluate
 * @param data the dataset
 * @param numFolds the number of folds in the cross-validation.
 * @exception Exception if an error occurs
 */
public FastVector getCVPredictions(Classifier classifier, 
                                   Instances data, 
                                   int numFolds) 
  throws Exception {

  FastVector predictions = new FastVector();
  Instances runInstances = new Instances(data);
  Random random = new Random(m_Seed);
  runInstances.randomize(random);
  if (runInstances.classAttribute().isNominal() && (numFolds > 1)) {
    runInstances.stratify(numFolds);
  }
  int inst = 0;
  for (int fold = 0; fold < numFolds; fold++) {
    Instances train = runInstances.trainCV(numFolds, fold, random);
    Instances test = runInstances.testCV(numFolds, fold);
    FastVector foldPred = getTrainTestPredictions(classifier, train, test);
    predictions.appendElements(foldPred);
  } 
  return predictions;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:31,代码来源:EvaluationUtils.java

示例3: main

import weka.core.FastVector; //导入方法依赖的package包/类
/**
  * Tests the CostCurve generation from the command line.
  * The classifier is currently hardcoded. Pipe in an arff file.
  *
  * @param args currently ignored
  */
 public static void main(String [] args) {

   try {
     
     Instances inst = new Instances(new java.io.InputStreamReader(System.in));
     
     inst.setClassIndex(inst.numAttributes() - 1);
     CostCurve cc = new CostCurve();
     EvaluationUtils eu = new EvaluationUtils();
     Classifier classifier = new weka.classifiers.functions.Logistic();
     FastVector predictions = new FastVector();
     for (int i = 0; i < 2; i++) { // Do two runs.
eu.setSeed(i);
predictions.appendElements(eu.getCVPredictions(classifier, inst, 10));
//System.out.println("\n\n\n");
     }
     Instances result = cc.getCurve(predictions);
     System.out.println(result);
     
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:30,代码来源:CostCurve.java

示例4: main

import weka.core.FastVector; //导入方法依赖的package包/类
public static void main(String[] args) {
  try {
    Instances train = new Instances(new java.io.BufferedReader(new java.io.FileReader(args[0])));
    train.setClassIndex(train.numAttributes() - 1);
    weka.classifiers.evaluation.ThresholdCurve tc = 
      new weka.classifiers.evaluation.ThresholdCurve();
    weka.classifiers.evaluation.EvaluationUtils eu = 
      new weka.classifiers.evaluation.EvaluationUtils();
    //weka.classifiers.Classifier classifier = new weka.classifiers.functions.Logistic();
    weka.classifiers.Classifier classifier = new weka.classifiers.bayes.NaiveBayes();
    FastVector predictions = new FastVector();
    eu.setSeed(1);
    predictions.appendElements(eu.getCVPredictions(classifier, train, 10));
    Instances result = tc.getCurve(predictions, 0);
    PlotData2D pd = new PlotData2D(result);
    pd.m_alwaysDisplayPointsOfThisSize = 10;

    boolean[] connectPoints = new boolean[result.numInstances()];
    for (int i = 1; i < connectPoints.length; i++) {
      connectPoints[i] = true;
    }
    pd.setConnectPoints(connectPoints);
    final javax.swing.JFrame jf = 
      new javax.swing.JFrame("CostBenefitTest");
    jf.setSize(1000,600);
    //jf.pack();
    jf.getContentPane().setLayout(new BorderLayout());
    final CostBenefitAnalysis.AnalysisPanel analysisPanel = 
      new CostBenefitAnalysis.AnalysisPanel();
    
    jf.getContentPane().add(analysisPanel, BorderLayout.CENTER);
    jf.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent e) {
        jf.dispose();
        System.exit(0);
      }
    });
    
    jf.setVisible(true);
    
    analysisPanel.setDataSet(pd, train.classAttribute());
    
  } catch (Exception ex) {
    ex.printStackTrace();
  }
 
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:48,代码来源:CostBenefitAnalysis.java


注:本文中的weka.core.FastVector.appendElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。