File size: 720 Bytes
dfd3544
 
a4aa491
 
eec3b88
a4aa491
eec3b88
 
a4aa491
dfd3544
 
eec3b88
 
 
 
 
 
 
 
dfd3544
 
eec3b88
 
 
 
 
a4aa491
eec3b88
 
dfd3544
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
package nn

import (
	"fmt"
	"strings"

	"github.com/go-gota/gota/dataframe"
	"github.com/gofiber/fiber/v2"
)

type NN 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"`
	Df             dataframe.DataFrame
}

func NewNN(c *fiber.Ctx) (*NN, error) {
	newNN := new(NN)
	err := c.BodyParser(newNN)
	if err != nil {
		return nil, fmt.Errorf("invalid JSON data: %v", err)
	}
	newNN.Df = dataframe.ReadCSV(strings.NewReader(newNN.CSVData))
	return newNN, nil
}