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


Java Evaluation.toMatrixString方法代码示例

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


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

示例1: printClassifierResults

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
/**
 *  Prints the results stored in an Evaluation object to standard output
 *  (summary, class results and confusion matrix)
 * 
 * @param Evaluation eval
 * @throws Exception
 */
public void printClassifierResults (Evaluation eval) throws Exception
{
	// Print the result à la Weka explorer:
       String strSummary = eval.toSummaryString();
       System.out.println(strSummary);
         
       // Print per class results
       String resPerClass = eval.toClassDetailsString();
       System.out.println(resPerClass);
       
       // Get the confusion matrix
       String cMatrix = eval.toMatrixString();
       System.out.println(cMatrix);	
       
       System.out.println();
}
 
开发者ID:Elhuyar,项目名称:Elixa,代码行数:24,代码来源:WekaWrapper.java

示例2: trainClassifier

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
public void trainClassifier(Classifier classifier, File trainingDataset,
                            FileOutputStream trainingModel, Integer
                                    crossValidationFoldNumber) throws Exception {

    CSVLoader csvLoader = new CSVLoader();
    csvLoader.setSource(trainingDataset);

    Instances instances = csvLoader.getDataSet();

    switch(classifier) {
        case KNN:
            int K = (int) Math.ceil(Math.sqrt(instances.numInstances()));
            this.classifier = new IBk(K);
            break;
        case NB:
            this.classifier = new NaiveBayes();
    }

    if(instances.classIndex() == -1) {
        instances.setClassIndex(instances.numAttributes() - 1);
    }

    this.classifier.buildClassifier(instances);

    if(crossValidationFoldNumber > 0) {
        Evaluation evaluation = new Evaluation(instances);
        evaluation.crossValidateModel(this.classifier, instances, crossValidationFoldNumber,
                new Random(1));
        kappa = evaluation.kappa();
        fMeasure = evaluation.weightedFMeasure();
        confusionMatrix = evaluation.toMatrixString("Confusion matrix: ");
    }

    ObjectOutputStream outputStream = new ObjectOutputStream(trainingModel);
    outputStream.writeObject(this.classifier);
    outputStream.flush();
    outputStream.close();
}
 
开发者ID:FlorentinTh,项目名称:SpeakerAuthentication,代码行数:39,代码来源:Learning.java

示例3: classifyMyInstances

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
public String classifyMyInstances(Instances inst) throws Exception {
    Instances data = inst;
    String summary = "";
    WekaConfig conf = WekaConfig.getInstance();
    String algorithm = conf.getAlgorithm();
    Classifier clas = null;

    if (conf.isFilterBool()) {
        FilterSet filtr = new FilterSet();
        switch (conf.getFilter()) {
            case "CSF greedy":
                data = filtr.filterCFS_Greedy(inst);
                break;
            case "CSF best first":
                data = filtr.filterCFS_BestFirst(inst);
                break;
            case "Filtered CSF greedy":
                data = filtr.filterFilteredCSF_Greedy(inst);
                break;
            case "Filtered CSF best first":
                data = filtr.filterFilteredCSF_BestFirst(inst);
                break;
            case "Consistency greedy":
                data = filtr.filterConsinstency_Greedy(inst);
                break;
            case "Consistency best first":
                data = filtr.filterConsinstency_BestFirst(inst);
                break;
        }
    }

    switch (algorithm) {
        case "J48":
            summary += "J48 \n";
            clas = classifyJ48(data);
            break;
        case "Naive Bayes":
            summary += "Naive Bayes \n";
            clas = classifyNaiveBayes(data);
            break;
        case "Lazy IBk":
            summary += "Lazy IBk \n";
            clas = classifyIBk(data);
            break;
        case "Random Tree":
            summary += "Random Tree \n";
            clas = classifyRandomTree(data);
            break;
        case "SMO":
            summary += "SMO \n";
            clas = classifySMO(data);
            break;
        case "PART":
            summary += "PART \n";
            clas = classifyPART(data);
            break;
        case "Decision Table":
            summary += "Decision Table \n";
            clas = classifyDecisionTable(data);
            break;
        case "Multi Layer":
            summary += "Multi Layer \n";
            clas = classifyMultiLayer(data);
            break;
        case "Kstar":
            summary += "Kstar \n";
            clas = classifyKStar(data);
            break;
    }

    summary += "\n";
    summary += "---------Klasifikacja-------------- \n";
    summary += clas.toString();
    Evaluate eval = new Evaluate();
    Evaluation evalu = eval.crossValidation(clas, data, conf.getFolds());
    summary += "----------Ewaluacja---------------- \n";
    summary += evalu.toSummaryString();
    summary += evalu.toMatrixString();

    return summary;
}
 
开发者ID:andrzejtrzaska,项目名称:VoiceStressAnalysis,代码行数:82,代码来源:Classification.java


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