Skip to content

Linear Regression written in golang that utilizes Gradient Descent.

Notifications You must be signed in to change notification settings

chenjsa/linearregression

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Linear Regression

Linear regression written in golang. It utilizes Gradient Descent to calculate the weights.

Usage

Import

Import the package

import (
  "github.com/ohheydom/linearregression"
)

Create a sample with labels

Samples need to be slices of float64s. The training set x should be a multidimensional slice. y should contain the labels for each corresponding x sample.

X := [][]float64{[]float64{1, 1}, []float64{2, 2}, []float64{3, 3}, []float64{4, 4}}
y := []float64{1, 2, 3, 4}

Create a Linear Regression struct and Fit

lr := linearregression.LinearRegression{}
lr.fit(x, y)

Show weights

The first weight listed will be the intercept value. The following weights will be the coefficients for each feature.

fmt.Println(lr.Weights)

Examples folder will have more examples soon.

About

Linear Regression written in golang that utilizes Gradient Descent.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%