August 2019
Beginner to intermediate
798 pages
17h 2m
English
The Go code of this section will be saved in regression.go, which is going to be presented in three parts. The output of the program will be two floating-point numbers that define a and b in the first-degree equation.
The first part of regression.go contains the following code:
package main
import (
"encoding/csv"
"flag"
"fmt"
"gonum.org/v1/gonum/stat"
"os"
"strconv"
)
type xy struct {
x []float64
y []float64
}
The xy structure is used to hold the data and should change according to your data format and values.
The second part of regression.go is as follows:
func main() { flag.Parse() if len(flag.Args()) == 0 { fmt.Printf("usage: regression filename\n") return } filename := flag.Args()[0] file, err := os.Open(filename) ...Read now
Unlock full access