Numpy-Neuron / nn /main.go
Jensen-holm's picture
significantly decreased the complexity of the API by deciding to make
eec3b88
raw
history blame
720 Bytes
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
}