cn-nnzy/mbglot/eval does not have a README file

    LangStats

    pub(all) struct LangStats {
    lang :
    Lang

    support : Int
    predicted : Int
    correct : Int
    precision : Double?
    recall : Double?
    f1 : Double?
    } derive(Eq,
    Debug
    )

    Accuracy figures for one language. precision is None when no sample was predicted as this language, recall when it has no samples.

    Report

    pub struct Report {
    // private fields
    }

    The outcome of evaluate: how every sample was classified.

    Report::accuracy

    fn Report::accuracy(self : Report) -> Double

    Share of samples predicted correctly, 0.0 for an empty report.

    Report::confusion_markdown

    fn Report::confusion_markdown(self : Report, langs : Array[
    Lang
    ]) -> String

    The confusion matrix over langs as a Markdown table: one row per expected language, one column per predicted language in langs, then a column for other languages and one for no prediction.

    Report::correct

    fn Report::correct(self : Report) -> Int

    Number of samples predicted as their expected language.

    Report::count

    fn Report::count(self : Report, expected :
    Lang
    , predicted :
    Lang
    ?) -> Int

    How many samples of language expected were predicted as predicted (None: not identified).

    Report::languages

    fn Report::languages(self : Report) -> Array[
    Lang
    ]

    The expected languages, in order of first appearance in the samples.

    Report::macro_f1

    fn Report::macro_f1(self : Report) -> Double

    Mean F1 over the expected languages, counting a language that was never predicted as 0.

    Report::per_language

    fn Report::per_language(self : Report) -> Array[LangStats]

    Precision, recall and F1 for every expected language, in order of first appearance.

    Report::to_markdown

    fn Report::to_markdown(self : Report, confusions? : Int) -> String

    A Markdown summary of the report: overall accuracy, a table with precision, recall and F1 per language (in order of first appearance), and the confusions most frequent mistakes.

    Report::top_confusions

    fn Report::top_confusions(self : Report, n : Int) -> Array[(
    Lang
    ,
    Lang
    ?, Int)]

    The n most frequent mistakes as (expected, predicted, count), most frequent first; ties are ordered by expected language, then by prediction, in Lang::all() order with None last.

    Report::total

    fn Report::total(self : Report) -> Int

    Number of samples.

    Report::unidentified

    fn Report::unidentified(self : Report) -> Int

    Number of samples for which no language was predicted.

    Sample

    pub(all) struct Sample {
    lang :
    Lang

    text : String
    } derive(Eq,
    Debug
    )

    A text with its known language.

    evaluate

    fn evaluate(samples : Array[Sample], predict : (String) ->
    Lang
    ?) -> Report

    Runs predict on every sample and tallies the results. predict returns None when it declines to identify a text; such a sample counts as wrong for accuracy and recall, but as a prediction of no language for precision.

    percent

    fn percent(x : Double) -> String

    x as a percentage with one decimal, computed with integers so that every backend prints the same digits.

    Source Files