mlbend-split Releases (2): 0.1.1.0 0xe8b7953f71ec5b441a90a08e0961269b indexed https://jend.leeeet.dev/files.txt?path=mlbend-split@0.1.1.0 0.1.0.0 0x97faf074f5fec7518a7b67151e3be4f7 unindexed https://jend.leeeet.dev/files.txt?path=mlbend-split@0.1.0.0 Definitions (27): MlbendSplit.Split (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=Split) type Split is Data: Split{train: List<&2, Nat>, test: List<&2, Nat>} MlbendSplit.split_covers (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=split_covers) # LAW (split_covers): every row of the dataset is placed in a fold — the # fold list holds one entry per row, so the folds are a partition of the # rows: the test rows of a fold and its training rows are disjoint, and # together they hold every row. law split_covers: for labels: List<&2, Nat> for +orders: List<&2, List<&2, Nat>> for +k: Nat for +i: Nat {count_rows(folds_from(labels, orders, k, i)) == List.length(&2, Nat, labels) : Nat} MlbendSplit.rows_of_class (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=rows_of_class) # The rows of one class, with their indices. def rows_of_class(labels: List<&2, Nat>, +c: Nat, +i: Nat, +acc: List<&2, Nat>) -> List<&2, Nat>: MlbendSplit.shuffled_list (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=shuffled_list) # The list of a pair: the list, and the generator that comes after it. def shuffled_list(pair: List<&2, Nat> & Rand.Rng) -> List<&2, Nat>: MlbendSplit.shuffled_class (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=shuffled_class) # The rows of one class, shuffled by the generator. def shuffled_class(labels: List<&2, Nat>, +c: Nat, +seed: U32) -> List<&2, Nat>: MlbendSplit.class_orders_go (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=class_orders_go) # The shuffled rows of every class, one class after the other. def class_orders_go(+labels: List<&2, Nat>, +seed: U32, remaining: Nat, +next: Nat, +acc: List<&2, List<&2, Nat>>) -> List<&2, List<&2, Nat>>: MlbendSplit.class_orders (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=class_orders) # The shuffled rows of every class, one class after the other. def class_orders(labels: List<&2, Nat>, seed: U32, c: Nat) -> List<&2, List<&2, Nat>>: MlbendSplit.largest_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=largest_of) # The largest label of the labels. def largest_of(labels: List<&2, Nat>, +acc: Nat) -> Nat: MlbendSplit.classes_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=classes_of) # The number of classes of the labels: one more than the largest label. def classes_of(labels: List<&2, Nat>) -> Nat: MlbendSplit.count_rows (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=count_rows) # The number of rows a list of folds holds. def count_rows(fs: List<&2, Nat>) -> Nat: MlbendSplit.position_go (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=position_go) # The place of a row among the shuffled rows of its class. def position_go(order: List<&2, Nat>, +i: Nat, +at: Nat) -> Nat: MlbendSplit.position_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=position_of) # The place of a row among the shuffled rows of its class. def position_of(order: List<&2, Nat>, i: Nat) -> Nat: MlbendSplit.fold_in_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=fold_in_of) # The fold of a row, given the shuffled rows of its class. def fold_in_of(order: List<&2, Nat>, k: Nat, i: Nat) -> Nat: MlbendSplit.order_head (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=order_head) # The first of the shuffled rows of every class. def order_head(orders: List<&2, List<&2, Nat>>) -> List<&2, Nat>: MlbendSplit.order_tail (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=order_tail) # The orders of every class but the first. def order_tail(+orders: List<&2, List<&2, Nat>>) -> List<&2, List<&2, Nat>>: MlbendSplit.order_at (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=order_at) # The shuffled rows of the class of a label: the n-th of the orders. def order_at(n: Nat, +orders: List<&2, List<&2, Nat>>) -> List<&2, Nat>: MlbendSplit.fold_in (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=fold_in) # The fold of a row: its place among the shuffled rows of its class, # dealt out over the folds in turn. def fold_in(orders: List<&2, List<&2, Nat>>, k: Nat, label: Nat, i: Nat) -> Nat: MlbendSplit.folds_from (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=folds_from) # The fold of every row from the row i on, given the shuffled rows of # every class. def folds_from(labels: List<&2, Nat>, +orders: List<&2, List<&2, Nat>>, +k: Nat, +i: Nat) -> List<&2, Nat>: MlbendSplit.folds (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=folds) # The fold of every row of the dataset, in the order of the rows. def folds(+labels: List<&2, Nat>, seed: U32, k: Nat) -> List<&2, Nat>: MlbendSplit.test_row (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=test_row) # The row, in the fold. def test_row(fold: Nat, f: Nat, +test: List<&2, Nat>, i: Nat) -> List<&2, Nat>: MlbendSplit.train_row (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=train_row) # The row, out of the fold. def train_row(fold: Nat, f: Nat, +train: List<&2, Nat>, i: Nat) -> List<&2, Nat>: MlbendSplit.split_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=split_of) # The rows of one fold: the ones that test and the ones that train. def split_of(fs: List<&2, Nat>, +f: Nat, +i: Nat, +test: List<&2, Nat>, +train: List<&2, Nat>) -> Split: MlbendSplit.split (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=split) # The rows of one fold: the ones that test and the ones that train. def split(labels: List<&2, Nat>, seed: U32, k: Nat, f: Nat) -> Split: MlbendSplit.test_of_go (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=test_of_go) # The rows of the fold f: the ones that test. def test_of_go(+fs: List<&2, Nat>, +f: Nat, +i: Nat, +acc: List<&2, Nat>) -> List<&2, Nat>: MlbendSplit.test_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=test_of) # The rows of the fold f: the ones that test. def test_of(fs: List<&2, Nat>, f: Nat) -> List<&2, Nat>: MlbendSplit.train_of_go (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=train_of_go) # The rows of the fold f: the ones that train. def train_of_go(+fs: List<&2, Nat>, +f: Nat, +i: Nat, +acc: List<&2, Nat>) -> List<&2, Nat>: MlbendSplit.train_of (https://jend.leeeet.dev/definition.txt?path=mlbend-split@0.1.1.0/main.bend&name=train_of) # The rows of the fold f: the ones that train. def train_of(fs: List<&2, Nat>, f: Nat) -> List<&2, Nat>: