Skip to content

Add confusion matrix evaluation helpers for classification problems #27

@atecon

Description

@atecon

Feature Request

Add confusion matrix evaluation helpers for classification problems

It would be useful for users working with classification problems to have convenient helpers in the package for evaluating the results with confusion matrices.

I propose two template functions as a starting point:

function matrix ConfusionMatrix (const series y, const series f)
    /* Confusion matrix */

    list L = y f
    xtab L --column
    matrix ret = $result[-end,-end]
    rnameset(ret, "y=1 y=2 y=3 y=4 y=5")
    cnameset(ret, "f=1 f=2 f=3 f=4 f=5")

    return ret
end function

function void PlotConfusionHeatmap (const matrix cm,
                                    const string title[null],
                                    const string filename[null])
    /* Plot a user-supplied confusion matrix with fixed heatmap settings.*/

    bundle PlotParams = _(xlabel = "Predicted class",
                ylabel = "Actual class",
                zerowhite = TRUE,
                printvals = TRUE,
                do_labels = TRUE)

    if exists(title)
        PlotParams.title = title
    endif
    if exists(filename)
        PlotParams.dest = filename
    endif

    heatmap(cm, PlotParams)
end function

These functions may serve as templates or convenience tools:

  • ConfusionMatrix creates a confusion matrix from observed and predicted series.
  • PlotConfusionHeatmap plots a confusion matrix with fixed heatmap settings.

Having helpers or templates like these would benefit users working on classification evaluation workflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions