mlbend-report Releases (1): 0.1.0.0 0x97687e0483c49ddb64fe1ee5f5244927 indexed https://jend.leeeet.dev/files.txt?path=mlbend-report@0.1.0.0 Definitions (27): MlbendReport.Cls (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=Cls) type Cls is Data: Cls{precision: F32, recall: F32, f1: F32, support: Nat} MlbendReport.Report (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=Report) type Report is Data: Report{classes: List<&2, Cls>, macro_avg: Cls, weighted_avg: Cls, accuracy: F32} MlbendReport.cell.go (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=cell.go) # The cell of the true label i and the predicted label j: how many # samples have both. def cell.go(ys: List<&2, Nat>, ps: List<&2, Nat>, +i: Nat, +j: Nat, n: Nat) -> Nat: MlbendReport.cell (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=cell) def cell(ys: List<&2, Nat>, ps: List<&2, Nat>, +i: Nat, +j: Nat) -> Nat: MlbendReport.rows_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=rows_of) # How many rows a matrix has. def rows_of(m: List<&2, List<&2, Nat>>) -> Nat: MlbendReport.cells_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=cells_of) # How many cells a row has. def cells_of(row: List<&2, Nat>) -> Nat: MlbendReport.row_from (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=row_from) # The row of the class i, from the column j on: n cells, the cell of # every class from j to j+n-1, ascending. The counted form is the # public one, because the law walks it: the counter of the cells left # is the argument that shrinks. def row_from(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat, +i: Nat, n: Nat, +j: Nat) -> List<&2, Nat>: MlbendReport.row (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=row) # The row of the class i: k cells, ascending. def row(ys: List<&2, Nat>, ps: List<&2, Nat>, +k: Nat, +i: Nat) -> List<&2, Nat>: MlbendReport.matrix_from (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=matrix_from) # The rows of the classes i to i+n-1: n rows, each of k cells, ascending. def matrix_from(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat, n: Nat, +i: Nat) -> List<&2, List<&2, Nat>>: MlbendReport.matrix (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=matrix) # The confusion matrix of k classes: k rows of k cells, the row of the # class 0 first. def matrix(ys: List<&2, Nat>, ps: List<&2, Nat>, +k: Nat) -> List<&2, List<&2, Nat>>: MlbendReport.matrix_rows (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=matrix_rows) # LAW 1 (matrix_rows): n rows of the matrix are n rows. law matrix_rows: for +ys: List<&2, Nat> for +ps: List<&2, Nat> for +k: Nat for +n: Nat for +i: Nat {rows_of(matrix_from(ys, ps, k, n, i)) == n : Nat} MlbendReport.row_length (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=row_length) # LAW 2 (row_length): n cells of a row are n cells. law row_length: for +ys: List<&2, Nat> for +ps: List<&2, Nat> for +k: Nat for +i: Nat for +n: Nat for +j: Nat {cells_of(row_from(ys, ps, k, i, n, j)) == n : Nat} MlbendReport.cls_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=cls_of) # The report of one class: its precision, its recall, its F1 and its # support. def cls_of(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +i: Nat) -> Cls: MlbendReport.classes_of.go (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=classes_of.go) # The report of every class, from the class i on: n of them, ascending. def classes_of.go(+ys: List<&2, Nat>, +ps: List<&2, Nat>, n: Nat, +i: Nat) -> List<&2, Cls>: MlbendReport.classes_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=classes_of) # The report of every class: k of them, the class 0 first. def classes_of(ys: List<&2, Nat>, ps: List<&2, Nat>, +k: Nat) -> List<&2, Cls>: MlbendReport.Tot (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=Tot) # The sums the averages rest on: the per-class scores added up, and the # support beside them. type Tot is Data: Tot{p: F32, r: F32, f: F32, support: Nat} MlbendReport.tot_add (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=tot_add) # One class more, added into the sums. def tot_add(t: Tot, c: Cls) -> Tot: MlbendReport.tot_of.go (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=tot_of.go) # The sums over the classes. def tot_of.go(classes: List<&2, Cls>, acc: Tot) -> Tot: MlbendReport.tot_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=tot_of) def tot_of(classes: List<&2, Cls>) -> Tot: MlbendReport.divide (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=divide) # a divided by b, or 0.0 when b is zero — the zero_division convention def divide(+a: F32, +b: F32) -> F32: MlbendReport.macro_of.go (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=macro_of.go) def macro_of.go(t: Tot, +k: Nat) -> Cls: MlbendReport.macro_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=macro_of) # The macro average: the mean of the per-class scores, every class # weighing the same, the way scikit-learn's macro average does. def macro_of(classes: List<&2, Cls>, +k: Nat) -> Cls: MlbendReport.weighted_sums (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=weighted_sums) # The weighted sums: every per-class score multiplied by its support. def weighted_sums(classes: List<&2, Cls>, +p: F32, +r: F32, +f: F32) -> Tot: MlbendReport.weighted_of.go (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=weighted_of.go) def weighted_of.go(t: Tot, +total: Nat) -> Cls: MlbendReport.weighted_of (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=weighted_of) # The weighted average: the per-class scores, each weighed by its # support, over the total support, the way scikit-learn's weighted # average does. def weighted_of(classes: List<&2, Cls>, +total: Nat) -> Cls: MlbendReport.report.go (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=report.go) # The whole report, or why there is none: the labels and the # predictions must agree in length, and there must be at least one # sample. def report.go(r: Result<&1, &1, M.Bad, Nat>, +ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, M.Bad, Report>: MlbendReport.report (https://jend.leeeet.dev/definition.txt?path=mlbend-report@0.1.0.0/main.bend&name=report) def report(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, M.Bad, Report>: