MCPcopy Create free account
hub / github.com/Open-Quant/openquant / get_ind_matrix

Function get_ind_matrix

crates/openquant/src/sampling.rs:5–19  ·  view source on GitHub ↗

Indicator matrix (rows=bar_index, cols=labels), values 0/1.

(label_endtime: &[(usize, usize)], bar_index: &[usize])

Source from the content-addressed store, hash-verified

3
4/// Indicator matrix (rows=bar_index, cols=labels), values 0/1.
5pub fn get_ind_matrix(label_endtime: &[(usize, usize)], bar_index: &[usize]) -> Vec<Vec<u8>> {
6 // validate
7 for (s, e) in label_endtime {
8 assert!(s <= e, "label endtime out of order");
9 }
10 let mut ind = vec![vec![0u8; label_endtime.len()]; bar_index.len()];
11 for (col, (start, end)) in label_endtime.iter().enumerate() {
12 for (row_idx, bar) in bar_index.iter().enumerate() {
13 if *bar >= *start && *bar <= *end {
14 ind[row_idx][col] = 1;
15 }
16 }
17 }
18 ind
19}
20
21/// Average uniqueness of indicator matrix (single value).
22pub fn get_ind_mat_average_uniqueness(ind_mat: &[Vec<u8>]) -> f64 {

Callers 9

test_value_error_raiseFunction · 0.85
synthetic_datasetFunction · 0.85
test_sb_classifierFunction · 0.85
test_sb_regressorFunction · 0.85
sampling_get_ind_matrixFunction · 0.85

Calls

no outgoing calls

Tested by 5

test_value_error_raiseFunction · 0.68
synthetic_datasetFunction · 0.68
test_sb_classifierFunction · 0.68
test_sb_regressorFunction · 0.68