mlbend-preprocess Releases (1): 0.1.0.0 0xa8182854f375cd61135ccd32993993cc indexed https://jend.leeeet.dev/files.txt?path=mlbend-preprocess@0.1.0.0 Definitions (40): MlbendPreprocess.one_hot_count_length (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot_count_length) # LAW (one_hot_count_length): the one-hot matrix has one row for every # label. law one_hot_count_length: for ys: List<&2, Nat> {one_hot_count_of(ys) == List.length(&2, Nat, ys) : Nat} MlbendPreprocess.Bounds (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=Bounds) # The extremes of every column: the smallest and the largest. type Bounds is Data: Bounds{mins: List<&2, F32>, maxs: List<&2, F32>} MlbendPreprocess.bounds_max_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_max_go) # The largest of two rows, cell by cell. def bounds_max_go(maxs: List<&2, F32>, row: List<&2, F32>, +acc: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.bounds_max (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_max) # The largest of two rows, cell by cell. def bounds_max(maxs: List<&2, F32>, row: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.bounds_min_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_min_go) # The smallest of two rows, cell by cell. def bounds_min_go(mins: List<&2, F32>, row: List<&2, F32>, +acc: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.bounds_min (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_min) # The smallest of two rows, cell by cell. def bounds_min(mins: List<&2, F32>, +row: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.bounds_of_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_of_go) # The extremes of every column, row by row. def bounds_of_go(+rows: List<&2, List<&2, F32>>, +mins: List<&2, F32>, +maxs: List<&2, F32>) -> Bounds: MlbendPreprocess.bounds_of_rows (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_of_rows) # The extremes of every column, row by row. def bounds_of_rows(+rows: List<&2, List<&2, F32>>) -> Bounds: MlbendPreprocess.bounds_of (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=bounds_of) # The extremes of every column of a matrix. def bounds_of(+r: Nat, +c: Nat, a: T.Mat) -> Bounds: MlbendPreprocess.l1_finish_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l1_finish_go) # The row, divided, cell by cell. def l1_finish_go(acc: List<&2, F32>, +k: F32, +out: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.l1_finish (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l1_finish) # The row, divided. def l1_finish(acc: List<&2, F32>, total: F32) -> List<&2, F32>: MlbendPreprocess.l1_row_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l1_row_go) # One row divided by the sum of its absolute values, cell by cell. def l1_row_go(+row: List<&2, F32>, +acc: List<&2, F32>, +total: F32) -> List<&2, F32>: MlbendPreprocess.l1_row (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l1_row) # One row divided by the sum of its absolute values. def l1_row(+row: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.l1_normalize_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l1_normalize_go) # The rows of a matrix, each divided by the sum of its absolute values. def l1_normalize_go(+rows: List<&2, List<&2, F32>>, +acc: List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>: MlbendPreprocess.mat_of_ (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=mat_of_) # A matrix of r rows of c numbers, when there is one. def mat_of_(+r: Nat, +c: Nat, m: Maybe<&2, T.Mat>) -> T.Mat: MlbendPreprocess.mat_of (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=mat_of) # A matrix of r rows of c numbers. When the rows do not fit, the # matrix is empty: a shape that does not hold is not a matrix. def mat_of(+r: Nat, +c: Nat, +rows: List<&2, List<&2, F32>>) -> T.Mat: MlbendPreprocess.l1_normalize (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l1_normalize) # The L1 normaliser: every row divided by the sum of its absolute # values. def l1_normalize(+r: Nat, +c: Nat, a: T.Mat) -> T.Mat: MlbendPreprocess.l2_finish_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_finish_go) # The row, divided, cell by cell. def l2_finish_go(acc: List<&2, F32>, +norm: F32, +out: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.l2_norm_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_norm_go) # The length of a row, cell by cell. def l2_norm_go(acc: List<&2, F32>, +acc_sum: F32) -> F32: MlbendPreprocess.l2_norm (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_norm) # The length of a row. def l2_norm(acc: List<&2, F32>) -> F32: MlbendPreprocess.l2_finish (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_finish) # The row, divided by its length. def l2_finish(+acc: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.l2_row_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_row_go) # One row divided by the length of its arrow, cell by cell. def l2_row_go(+row: List<&2, F32>, +acc: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.l2_row (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_row) # One row divided by the length of its arrow. def l2_row(+row: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.l2_normalize_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_normalize_go) # The rows of a matrix, each divided by the length of its arrow. def l2_normalize_go(+rows: List<&2, List<&2, F32>>, +acc: List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>: MlbendPreprocess.l2_normalize (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=l2_normalize) # The L2 normaliser: every row divided by the length of its arrow. def l2_normalize(+r: Nat, +c: Nat, +a: T.Mat) -> T.Mat: MlbendPreprocess.scale_row_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=scale_row_go) # One row scaled column by column, cell by cell. def scale_row_go(+row: List<&2, F32>, mins: List<&2, F32>, maxs: List<&2, F32>, +acc: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.scale_row (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=scale_row) # One row scaled column by column. def scale_row(+row: List<&2, F32>, mins: List<&2, F32>, maxs: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.scaled_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=scaled_go) # A matrix scaled column by column, row by row. def scaled_go(+rows: List<&2, List<&2, F32>>, +mins: List<&2, F32>, +maxs: List<&2, F32>, +acc: List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>: MlbendPreprocess.scaled_of (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=scaled_of) # A matrix scaled column by column. def scaled_of(+r: Nat, +c: Nat, a: T.Mat, +b: Bounds) -> List<&2, List<&2, F32>>: MlbendPreprocess.scaled (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=scaled) # A matrix scaled column by column: every cell is (x - min) / (max - min). def scaled(+r: Nat, +c: Nat, a: T.Mat, +b: Bounds) -> List<&2, List<&2, F32>>: MlbendPreprocess.min_max (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=min_max) # The min-max scaler: every column mapped onto [0, 1]. def min_max(+r: Nat, +c: Nat, +a: T.Mat) -> T.Mat: MlbendPreprocess.replace_at_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=replace_at_go) # A list with its nth element replaced, element by element. def replace_at_go(+xs: List<&2, F32>, +n: Nat, +v: F32, +acc: List<&2, F32>) -> List<&2, F32>: MlbendPreprocess.replace_at (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=replace_at) # A list with its nth element replaced. def replace_at(+xs: List<&2, F32>, n: Nat, v: F32) -> List<&2, F32>: MlbendPreprocess.one_hot_row (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot_row) # One row of a one-hot matrix: a zero in every column but the label's. def one_hot_row(+label: Nat, k: Nat) -> List<&2, F32>: MlbendPreprocess.one_hot_rows_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot_rows_go) # The rows of a one-hot matrix, label by label. def one_hot_rows_go(+labels: List<&2, Nat>, +k: Nat, +acc: List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>: MlbendPreprocess.one_hot_rows (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot_rows) # The rows of a one-hot matrix, one for every label. def one_hot_rows(+labels: List<&2, Nat>, +k: Nat) -> List<&2, List<&2, F32>>: MlbendPreprocess.one_hot (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot) # The one-hot encoding: a row of k numbers for every label, with a one # in the column of the label. It is Nothing when there are not exactly # n labels. def one_hot(+k: Nat, +n: Nat, labels: List<&2, Nat>) -> Maybe<&2, T.Mat>: MlbendPreprocess.one_hot_count_go (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot_count_go) # The number of rows of a one-hot matrix, counted. def one_hot_count_go(+labels: List<&2, Nat>, +acc: Nat) -> Nat: MlbendPreprocess.one_hot_count_of (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=one_hot_count_of) # The number of rows of a one-hot matrix. def one_hot_count_of(ys: List<&2, Nat>) -> Nat: MlbendPreprocess.standardize (https://jend.leeeet.dev/definition.txt?path=mlbend-preprocess@0.1.0.0/main.bend&name=standardize) def standardize(+r: Nat, +c: Nat, a: T.Mat) -> T.Mat: