MCPcopy Create free account
hub / github.com/daniel-e/rustml / as_matrix

Method as_matrix

src/datasets.rs:319–334  ·  view source on GitHub ↗

Returns a matrix which contains the population consisting of one or more subpopulations. Each row of the matrix represents a sample generated from one of the subpopulations. The value in the first column of a row denotes the subpopulation from which this sample has been generated. If the value is 0 this sample has been created from the first subpopulation (i.e. the first data source that has bee

(&mut self)

Source from the content-addressed store, hash-verified

317 /// Then, the matrix could look like:
318 ///
319 pub fn as_matrix(&mut self) -> Matrix<f64> {
320
321 let mut m = Matrix::new();
322
323 for (idx, &mut (n, ref mut nd)) in self.normal.iter_mut().enumerate() {
324 for _ in (0..n) {
325 let v = nd.next().unwrap().clone();
326 let mut x = vec![idx as f64];
327 for j in v {
328 x.push(j);
329 }
330 m.add_row(&x);
331 }
332 }
333 m
334 }
335}
336
337/// Creates a mixture model with normally distributed data sources.

Callers 5

test_mixtureFunction · 0.80
mainFunction · 0.80
plot_mixtureFunction · 0.80
plot_nnFunction · 0.80

Calls 2

add_rowMethod · 0.80
nextMethod · 0.45

Tested by 1

test_mixtureFunction · 0.64