-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.go
More file actions
42 lines (36 loc) · 819 Bytes
/
plot.go
File metadata and controls
42 lines (36 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package elm
import (
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/plotutil"
"gonum.org/v1/plot/vg"
)
func Points(n []int, v []float64) plotter.XYs {
pts := make(plotter.XYs, len(n))
for i := range pts {
pts[i].Y = v[i]
pts[i].X = float64(n[i])
}
return pts
}
func PlotPng(X [][]float64, name string) {
h := []int{5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
ans := make([]float64, len(h))
for i, v := range h {
ans[i] = CrossValidation(X, 3, 256, 1, v, 0)
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "ELM"
p.X.Label.Text = "Hidden neurons"
p.Y.Label.Text = "percent"
err = plotutil.AddLinePoints(p, "First", Points(h, ans))
if err != nil {
panic(err)
}
if err := p.Save(4*vg.Inch, 4*vg.Inch, name+".png"); err != nil {
panic(err)
}
}