當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。