File size: 1,188 Bytes
5d966be
 
 
b5b4a38
 
5d966be
 
 
 
 
b5b4a38
eec3b88
 
 
 
 
b5b4a38
 
5d966be
b5b4a38
 
 
 
 
 
 
 
 
 
 
eec3b88
 
 
 
 
 
b5b4a38
 
eec3b88
 
 
 
b5b4a38
 
 
 
 
 
5d966be
b5b4a38
 
 
 
 
5d966be
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type RequestPayload struct {
	CSVData   string   `json:"csv_data"`
	Features  []string `json:"features"`
	Target    string   `json:"target"`
	Algorithm string   `json:"algorithm"`
	Args      map[string]interface{}
}

func main() {
	filePath := "iris.csv"

	csvBytes, err := ioutil.ReadFile(filePath)
	if err != nil {
		fmt.Println("Error reading CSV file: ", err)
		return
	}

	csvString := string(csvBytes)
	features := []string{"petal length", "sepal length", "sepal width", "petal width"}
	target := "species"
	args := map[string]interface{}{
		"epochs":        100,
		"hidden_size":   8,
		"learning_rate": 0.1,
		"activation":    "tanh",
	}

	payload := RequestPayload{
		CSVData:  csvString,
		Features: features,
		Target:   target,
		Args:     args,
	}

	jsonPayload, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}

	r, err := http.Post(
		"http://127.0.0.1:3000/",
		"application/json",
		bytes.NewBuffer(jsonPayload),
	)
	if err != nil {
		panic(err)
	}

	defer r.Body.Close()

	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(body))

}