File size: 1,383 Bytes
5d966be
 
 
b5b4a38
 
5d966be
 
 
 
 
b5b4a38
 
 
 
 
 
 
 
 
 
5d966be
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
70
71
72
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"`
	HiddenSize     int      `json:"hidden_size"`
	LearningRate   float64  `json:"learning_rate"`
	ActivationFunc string   `json:"activation_func"`
}

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"
	epochs := 100
	hiddenSize := 8
	learningRate := 0.1
	activationFunc := "tanh"

	payload := RequestPayload{
		CSVData:        csvString,
		Features:       features,
		Target:         target,
		Epochs:         epochs,
		HiddenSize:     hiddenSize,
		LearningRate:   learningRate,
		ActivationFunc: activationFunc,
	}

	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))

}