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

Function plot_mixture

examples/plots.rs:32–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30}
31
32pub fn plot_mixture() {
33
34 let seed = [2, 3, 5, 7];
35
36 let m =
37 mixture_builder()
38 .add(100, normal_builder(seed).add(1.0, 1.2).add(2.0, 1.2))
39 .add(100, normal_builder(seed).add(5.0, 1.5).add(6.0, 1.5))
40 .add(100, normal_builder(seed).add(6.0, 1.5).add(0.0, 1.5))
41 .as_matrix();
42
43 builder()
44 .add_matrix("X = $$", &m)
45 .add("A = X(X(:,1) == 0, 2:end)")
46 .add("B = X(X(:,1) == 1, 2:end)")
47 .add("C = X(X(:,1) == 2, 2:end)")
48 .add("plot(A(:,1), A(:,2), 'o', 'markerfacecolor', 'yellow', 'color', 'black', 'markersize', 5)")
49 .add("hold on")
50 .add("plot(B(:,1), B(:,2), 'o', 'markerfacecolor', 'blue', 'color', 'black', 'markersize', 5)")
51 .add("plot(C(:,1), C(:,2), 'o', 'markerfacecolor', 'red', 'color', 'black', 'markersize', 5)")
52 .add("grid on")
53 .add("axis([-2, 10, -5, 10])")
54 .add("axis('nolabel')")
55 .add("print -r50 -dpng /tmp/plot_mixture.png")
56 .run("/tmp/plot_normal.m")
57 .unwrap();
58
59 Window::new()
60 .show_image(&RgbImage::from_file("/tmp/plot_mixture.png").unwrap())
61 .wait_key();
62
63}
64
65pub fn plot_knn_decision_boundary() {
66

Callers 1

mainFunction · 0.85

Calls 10

mixture_builderFunction · 0.85
normal_builderFunction · 0.85
from_fileFunction · 0.85
as_matrixMethod · 0.80
runMethod · 0.80
add_matrixMethod · 0.80
wait_keyMethod · 0.80
show_imageMethod · 0.80
builderFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected