• 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
  • 相关阅读:
    mysql安装遇到的坑
    git pull 、git fetch、 git clone
    MD markdown入门
    Libevent:8Bufferevents高级主题
    Libevent:6辅助函数以及类型
    Libevent:5events相关
    Libevent:4event loop
    Libevent:3创建event_base
    Libevent:2设置
    Libevent:1前言
  • 原文地址:https://www.cnblogs.com/virter/p/13635895.html
Copyright © 2020-2023  润新知