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