mlbend-metrics
Releases (1):
0.1.0.0 0x9afaa60ee4d17706cb14d6ec20d1d4ae indexed https://jend.leeeet.dev/files.txt?path=mlbend-metrics@0.1.0.0
Definitions (42):
MlbendMetrics.Bad (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=Bad)
type Bad is Data:
Mismatch{expected: Nat, got: Nat}
Empty{}
MlbendMetrics.same_of (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=same_of)
# 1 when a and b are the same label, 0 otherwise
def same_of(s: Bool) -> Nat:
MlbendMetrics.same (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=same)
def same(a: Nat, b: Nat) -> Nat:
MlbendMetrics.count (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count)
# the number of samples
def count(ys: List<&2, Nat>) -> Nat:
MlbendMetrics.count_true.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_true.go)
# the number of samples whose true label is k
def count_true.go(ys: List<&2, Nat>, +k: Nat, n: Nat) -> Nat:
MlbendMetrics.count_true (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_true)
def count_true(ys: List<&2, Nat>, k: Nat) -> Nat:
MlbendMetrics.count_pred.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_pred.go)
# the number of samples whose predicted label is k
def count_pred.go(ps: List<&2, Nat>, +k: Nat, n: Nat) -> Nat:
MlbendMetrics.count_pred (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_pred)
def count_pred(ps: List<&2, Nat>, k: Nat) -> Nat:
MlbendMetrics.count_both.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_both.go)
# the number of samples whose true label is k and whose predicted label
# is k too: the true positives of the class k
def count_both.go(ys: List<&2, Nat>, ps: List<&2, Nat>, +k: Nat, n: Nat) -> Nat:
MlbendMetrics.count_both (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_both)
def count_both(ys: List<&2, Nat>, ps: List<&2, Nat>, k: Nat) -> Nat:
MlbendMetrics.count_right.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_right.go)
# the number of samples predicted right
def count_right.go(ys: List<&2, Nat>, ps: List<&2, Nat>, n: Nat) -> Nat:
MlbendMetrics.count_right (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_right)
def count_right(ys: List<&2, Nat>, ps: List<&2, Nat>) -> Nat:
MlbendMetrics.count_length (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=count_length)
# LAW 1 (count_length): the number of samples is the length of the list
# of labels. (The count is this package's own walk, so the law pins it
# to the length Base counts.)
law count_length:
for ys: List<&2, Nat>
{count(ys) == List.length(&2, Nat, ys) : Nat}
MlbendMetrics.Sum (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=Sum)
type Sum is Data:
Sum{n: Nat, s: F32}
MlbendMetrics.sum_add (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=sum_add)
def sum_add(a: Sum, x: F32) -> Sum:
MlbendMetrics.sq_sum.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=sq_sum.go)
# the sum of the squared differences of the pairs walked
def sq_sum.go(ys: List<&2, F32>, ps: List<&2, F32>, acc: Sum) -> Sum:
MlbendMetrics.abs_sum.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=abs_sum.go)
# the sum of the absolute differences of the pairs walked
def abs_sum.go(ys: List<&2, F32>, ps: List<&2, F32>, acc: Sum) -> Sum:
MlbendMetrics.ratio_of (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=ratio_of)
# the ratio a over b, or 0.0 when b is zero
def ratio_of(z: Bool, +a: Nat, +b: Nat) -> F32:
MlbendMetrics.ratio (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=ratio)
def ratio(+a: Nat, +b: Nat) -> F32:
MlbendMetrics.mean (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=mean)
# the mean of a sum over n pairs
def mean(s: Sum, n: Nat) -> F32:
MlbendMetrics.same_len_of (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=same_len_of)
# the number of pairs to walk, or why the two sequences do not agree
def same_len_of(s: Bool, +n: Nat, +m: Nat) -> Result<&1, &1, Bad, Nat>:
MlbendMetrics.same_len (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=same_len)
def same_len(+n: Nat, +m: Nat) -> Result<&1, &1, Bad, Nat>:
MlbendMetrics.not_empty_of (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=not_empty_of)
# the number of pairs to walk, or why there are none
def not_empty_of(z: Bool, n: Nat) -> Result<&1, &1, Bad, Nat>:
MlbendMetrics.not_empty (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=not_empty)
# the number of pairs, or why there is no answer
def not_empty(r: Result<&1, &1, Bad, Nat>) -> Result<&1, &1, Bad, Nat>:
MlbendMetrics.pairs (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=pairs)
# the number of pairs the two sequences hold, or why there is no answer
def pairs(a, -A: Kind(a), ys: List, ps: List) -> Result<&1, &1, Bad, Nat>:
MlbendMetrics.mse.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=mse.go)
# the mean squared error between the targets and the predictions
def mse.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, F32>, +ps: List<&2, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.mse (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=mse)
def mse(+ys: List<&2, F32>, +ps: List<&2, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.mae.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=mae.go)
# the mean absolute error between the targets and the predictions
def mae.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, F32>, +ps: List<&2, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.mae (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=mae)
def mae(+ys: List<&2, F32>, +ps: List<&2, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.rmse.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=rmse.go)
# the root mean squared error between the targets and the predictions
def rmse.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, F32>, +ps: List<&2, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.rmse (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=rmse)
def rmse(+ys: List<&2, F32>, +ps: List<&2, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.accuracy.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=accuracy.go)
# the fraction of the samples predicted right
def accuracy.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, Nat>, +ps: List<&2, Nat>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.accuracy (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=accuracy)
def accuracy(+ys: List<&2, Nat>, +ps: List<&2, Nat>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.precision.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=precision.go)
# the fraction of the samples predicted as k that are really k: the
# precision of the class k
def precision.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.precision (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=precision)
def precision(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.recall.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=recall.go)
# the fraction of the samples really k that are predicted as k: the
# recall of the class k
def recall.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.recall (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=recall)
def recall(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.f1_num_of (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=f1_num_of)
# the harmonic mean of two scores
def f1_num_of(z: Bool, +p: F32, +r: F32) -> F32:
MlbendMetrics.f1_num (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=f1_num)
def f1_num(+p: F32, +r: F32) -> F32:
MlbendMetrics.f1_of (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=f1_of)
# the harmonic mean of a precision and a recall
def f1_of(p: Result<&1, &1, Bad, F32>, r: Result<&1, &1, Bad, F32>) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.f1.go (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=f1.go)
# the harmonic mean of the precision and the recall of the class k
def f1.go(r: Result<&1, &1, Bad, Nat>, +ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, Bad, F32>:
MlbendMetrics.f1 (https://jend.leeeet.dev/definition.txt?path=mlbend-metrics@0.1.0.0/main.bend&name=f1)
def f1(+ys: List<&2, Nat>, +ps: List<&2, Nat>, +k: Nat) -> Result<&1, &1, Bad, F32>: