zoukankan      html  css  js  c++  java
  • Matlab table类型变量使用示例

    clear;
    
    CM = load('confusionMatrix_5Exp.mat');
    
    fieldNames = fieldnames(CM);
    fieldNames = fieldNames';
    varNames = {'CM', 'Sen', 'Spc', 'Prc', 'F1', 'Acc'};
    varTypes = {'cell', 'double', 'double', 'double', 'double', 'double'};
    
    CMCell = cell(numel(fieldNames),1);
    CMTable = table('Size', [numel(fieldNames) numel(varNames)], 'VariableTypes', varTypes, 'VariableNames', varNames, 'RowNames', fieldNames);
    for iField = 1:numel(fieldNames)
        curCM = getfield(CM, fieldNames{iField});
        resultCM = genRes(curCM);
        CMCell{iField} = curCM;
        CMTable(iField, :) = {{curCM}, resultCM.Sensitivity, resultCM.Specificity, resultCM.Precision, resultCM.F1, resultCM.Accuracy};
        
    end
    
    %% Support Functions
    function resultCM = genRes(CM)
    resultCM.Sensitivity = CM(1,1)/(CM(1,1) + CM(2,1));
    resultCM.Specificity = CM(2,2)/(CM(2,2) + CM(1,2));
    resultCM.Precision = CM(1,1)/(CM(1,1) + CM(1,2));
    resultCM.F1 = 2*((resultCM.Precision*resultCM.Specificity)/(resultCM.Precision+resultCM.Specificity));
    resultCM.Accuracy = (CM(1,1)+CM(2,2))/sum(CM, 'all')*100;
    
    end

    % 附件地址:https://files.cnblogs.com/files/virter/confusionMatrix_5Exp.rar
  • 相关阅读:
    codeforces 189A
    hdu 2085
    hdu 2083
    cf 1237 C2. Balanced Removals (Harder)
    cf 1244 D. Paint the Tree
    cf 1241 E. Paint the Tree(DP)
    cf 1241 D. Sequence Sorting(思维)
    cf1228 D Complete Tripartite(哈希)
    Windows10 与 WSL(Ubuntu)的文件互访
    Ubuntu下运行python文件
  • 原文地址:https://www.cnblogs.com/virter/p/13635895.html
Copyright © 2011-2022 走看看