Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Linear

type Linear struct {
	Features     [][]float64
	Theta        []float64
	Output       []float64
	LearningRate float64
	Hypothesis   LinearHypothesis
	Result       *optimize.Result
}

Linear struct of Linear regression this could be used for either Linear regression and logistic regression

type LinearHypothesis

type LinearHypothesis func(X, theta []float64) float64

LinearHypothesis struct for hypothesis

type LinearRegression

type LinearRegression struct {
	Linear
}

LinearRegression inherits Liner

func NewLinearRegression

func NewLinearRegression() *LinearRegression

NewLinearRegression return new pointer of LogisticRegression struct with default Linear hypothesis ax+b

func (*LinearRegression) Func

func (l *LinearRegression) Func(theta []float64) float64

Func return cost

func (*LinearRegression) Grad

func (l *LinearRegression) Grad(grad, theta []float64)

Grad updates initil thetas to minimum

func (*LinearRegression) Minimize

func (l *LinearRegression) Minimize(setting *LinearSetting) *optimize.Result

Minimize start training of hypothesis

func (*LinearRegression) Predict

func (l *LinearRegression) Predict(X []float64) float64

Predict start training of hypothesis

type LinearSetting

type LinearSetting struct {
	MajorIteration int
	Threshod       float64
}

LinearSetting struct for setting

func LinearDefaultSetting

func LinearDefaultSetting() *LinearSetting

LinearDefaultSetting returns default setting for Linear regression

type LogisticRegression

type LogisticRegression struct {
	Linear
	TrueDegree float64
}

LogisticRegression inherits Liner

func NewLogisticRegression

func NewLogisticRegression() *LogisticRegression

NewLogisticRegression return new pointer of LogisticRegression struct with default Linear hypothesis ax+b

func (*LogisticRegression) Func

func (l *LogisticRegression) Func(theta []float64) float64

Func returns cost of theta

func (*LogisticRegression) Grad

func (l *LogisticRegression) Grad(grad, theta []float64)

Grad updates initil thetas to minimum

func (*LogisticRegression) Minimize

func (l *LogisticRegression) Minimize(setting *LinearSetting) *optimize.Result

Minimize start training of hypothesis Minimize start training of hypothesis

func (*LogisticRegression) Predict

func (l *LogisticRegression) Predict(X []float64) bool

Predict start training of hypothesis

Source Files