File size: 1,275 Bytes
5d966be
 
 
b5b4a38
 
5d966be
 
 
 
 
b5b4a38
fae8f77
 
 
 
 
 
 
b5b4a38
 
5d966be
fae8f77
b5b4a38
 
 
 
 
 
 
fae8f77
 
 
 
 
eec3b88
b5b4a38
 
fae8f77
 
 
 
 
 
 
b5b4a38
 
 
 
 
 
5d966be
b5b4a38
fae8f77
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
70
71
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"`
	Epochs         int      `json:"epochs"`
	LearningRate   float64  `json:"learning_rate"`
	HiddenSize     int      `json:"hidden_size"`
	ActivationFunc string   `json:"activation"`
}

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

	csvString := string(csvBytes)
	target := "species"
	features := []string{
		"petal length",
		"sepal length",
		"sepal width",
		"petal width",
	}

	payload := RequestPayload{
		CSVData:        csvString,
		Features:       features,
		Target:         target,
		Epochs:         100,
		LearningRate:   0.01,
		HiddenSize:     12,
		ActivationFunc: "tanh",
	}

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

	r, err := http.Post(
		"http://127.0.0.1:3000/neural-network",
		"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))

}