forked from ardanlabs/gotraining
/
template2.go
52 lines (38 loc) · 1.23 KB
/
template2.go
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
43
44
45
46
47
48
49
50
51
52
// All material is licensed under the Apache License Version 2.0, January 2004
// http://www.apache.org/licenses/LICENSE-2.0
// go build
// ./template2
// Sample program to generate a histogram of diabetes bmi values.
package main
import (
"bytes"
"log"
"github.com/kniren/gota/dataframe"
"github.com/pachyderm/pachyderm/src/client"
)
func main() {
// Connect to Pachyderm on our localhost. By default
// Pachyderm will be exposed on port 30650.
c, err := client.NewFromAddress("0.0.0.0:30650")
if err != nil {
log.Fatal(err)
}
defer c.Close()
// Get the diabetes dataset from Pachyderm's data
// versioning at the latest commit.
var b bytes.Buffer
if err := c.GetFile("diabetes", "master", "diabetes.csv", 0, 0, "", false, nil, &b); err != nil {
log.Fatal()
}
// Create a dataframe from the CSV file.
// The types of the columns will be inferred.
diabetesDF := dataframe.ReadCSV(bytes.NewReader(b.Bytes()))
// Create a plotter.Values value and fill it with the
// values from the respective column of the dataframe.
// Make a plot and set its title.
// Create a histogram of our values drawn
// from the standard normal.
// Normalize the histogram.
// Add the histogram to the plot.
// Save the plot to a PNG file.
}