Indicator matrix (rows=bar_index, cols=labels), values 0/1.
(label_endtime: &[(usize, usize)], bar_index: &[usize])
| 3 | |
| 4 | /// Indicator matrix (rows=bar_index, cols=labels), values 0/1. |
| 5 | pub 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). |
| 22 | pub fn get_ind_mat_average_uniqueness(ind_mat: &[Vec<u8>]) -> f64 { |
no outgoing calls