本文整理汇总了Java中weka.classifiers.evaluation.Prediction类的典型用法代码示例。如果您正苦于以下问题:Java Prediction类的具体用法?Java Prediction怎么用?Java Prediction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Prediction类属于weka.classifiers.evaluation包,在下文中一共展示了Prediction类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateResults
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
public static void evaluateResults(Evaluation evaluation) {
for (Prediction p : evaluation.predictions()) {
System.out.println(p.actual() + " " + p.predicted());
}
System.out.println(evaluation.toSummaryString("\nResults\n======\n", true));
// System.out.println(evaluation.toSummaryString(evaluation.correlationCoefficient() + " " + evaluation.errorRate() + " " + evaluation.meanAbsoluteError() + " ");
}
示例2: computeAccuracyAndRecordPrediction
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
public double computeAccuracyAndRecordPrediction(BayesianNetwork bn, DataOnMemory<DataInstance> data){
double correctPredictions = 0;
Variable classVariable = bn.getVariables().getVariableById(nb_.getClassIndex());
VMP vmp = new VMP();
vmp.setModel(bn);
for (DataInstance instance : data) {
double realValue = instance.getValue(classVariable);
instance.setValue(classVariable, Utils.missingValue());
vmp.setEvidence(instance);
vmp.runInference();
Multinomial posterior = vmp.getPosterior(classVariable);
if (Utils.maxIndex(posterior.getProbabilities())==realValue)
correctPredictions++;
Prediction prediction = new NominalPrediction(realValue, posterior.getProbabilities());
predictions.add(prediction);
instance.setValue(classVariable, realValue);
}
return correctPredictions/data.getNumberOfDataInstances();
}
示例3: predictionsToString
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
/**
* Returns a string containing all the predictions.
*
* @param predictions a <code>FastVector</code> containing the predictions
* @return a <code>String</code> representing the vector of predictions.
*/
public static String predictionsToString(ArrayList<Prediction> predictions) {
StringBuffer sb = new StringBuffer();
sb.append(predictions.size()).append(" predictions\n");
for (int i = 0; i < predictions.size(); i++) {
sb.append(predictions.get(i)).append('\n');
}
return sb.toString();
}
示例4: predictionsToString
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
/**
* Returns a string containing all the predictions.
*
* @param predictions a <code>FastVector</code> containing the predictions
* @return a <code>String</code> representing the vector of predictions.
*/
protected String predictionsToString(ArrayList<Prediction> predictions) {
StringBuffer sb = new StringBuffer();
sb.append(predictions.size()).append(" predictions\n");
for (int i = 0; i < predictions.size(); i++) {
sb.append(predictions.get(i)).append('\n');
}
return sb.toString();
}
示例5: evaluateResults
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
public static void evaluateResults(Evaluation evaluation){
for(Prediction p: evaluation.predictions()){
System.out.println(p.actual() + " " + p.predicted() );
}
System.out.println(evaluation.toSummaryString("\nResults\n======\n", true));
// System.out.println(evaluation.toSummaryString(evaluation.correlationCoefficient() + " " + evaluation.errorRate() + " " + evaluation.meanAbsoluteError() + " ");
}
示例6: main
import weka.classifiers.evaluation.Prediction; //导入依赖的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();
ArrayList<Prediction> predictions = new ArrayList<Prediction>();
eu.setSeed(1);
predictions.addAll(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() {
@Override
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();
}
}
示例7: predictions
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
/**
* Returns the predictions that have been collected.
*
* @return a reference to the FastVector containing the predictions that have
* been collected. This should be null if no predictions have been
* collected.
*/
public ArrayList<Prediction> predictions() {
return m_delegate.predictions();
}
示例8: getVisualizeMenuItem
import weka.classifiers.evaluation.Prediction; //导入依赖的package包/类
/**
* Get a JMenu or JMenuItem which contain action listeners that perform the
* visualization, using some but not necessarily all of the data. Exceptions
* thrown because of changes in Weka since compilation need to be caught by
* the implementer.
*
* @see NoClassDefFoundError
* @see IncompatibleClassChangeError
*
* @param preds predictions
* @param classAtt class attribute
* @return menuitem for opening visualization(s), or null to indicate no
* visualization is applicable for the input
*/
public JMenuItem getVisualizeMenuItem(ArrayList<Prediction> preds,
Attribute classAtt);