ml

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	False = float64(0)
	True  = float64(1)
)

Predefined values for true and false.

Variables

This section is empty.

Functions

func ApplyThreshold added in v0.0.56

func ApplyThreshold(y *mat.VecDense, t float64) *mat.VecDense

ApplyThreshold applies a threshold to the given vector, transforming every value x > t to True and all other values to False. It transforms the input vector and returns it as well.

func Bool

func Bool(t bool) float64

Bool converts a bool to a value representing false or true.

func Normalize

func Normalize(xs *mat.Dense) error

Normalize normalizes the the given feature vectors.

Types

type Fitter added in v0.0.57

type Fitter interface {
	Fit(x *mat.Dense, y *mat.VecDense) float64
}

Fitter is used to train a ml-model on input values.

type LR

type LR struct {
	LearningRate float64

	Ntrain int
	// contains filtered or unexported fields
}

LR implements LinearRegression

func (*LR) Error added in v0.0.40

func (lr *LR) Error() float64

Error returns the remaining training error.

func (*LR) Fit

func (lr *LR) Fit(x *mat.Dense, y *mat.VecDense) float64

Fit fits the linear regression model and returns its final error.

func (*LR) GobDecode added in v0.0.7

func (lr *LR) GobDecode(data []byte) error

GobDecode implements the GobDecoder interface.

func (*LR) GobEncode added in v0.0.7

func (lr *LR) GobEncode() ([]byte, error)

GobEncode implements the GobEncoder interface.

func (*LR) Instances added in v0.0.40

func (lr *LR) Instances() int

Instances returns the number of training instances used.

func (*LR) MarshalJSON

func (lr *LR) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface.

func (*LR) Predict

func (lr *LR) Predict(x *mat.Dense) *mat.VecDense

Predict calculates the predictions for the given values.

func (*LR) UnmarshalJSON

func (lr *LR) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshal interface.

func (*LR) Weights added in v0.0.7

func (lr *LR) Weights() []float64

Weights returns the weights of the logic regression model.

type NN added in v0.0.57

type NN struct {
	// contains filtered or unexported fields
}

func NewNN added in v0.0.57

func NewNN(c NNConfig) *NN

func (*NN) Fit added in v0.0.57

func (nn *NN) Fit(x *mat.Dense, y *mat.VecDense) float64

Fit trains the neural network on the given data.

func (*NN) GobDecode added in v0.0.57

func (nn *NN) GobDecode(data []byte) error

GobDecode implements the GobDecoder interface.

func (*NN) GobEncode added in v0.0.57

func (nn *NN) GobEncode() ([]byte, error)

GobEncode implements the GobEncoder interface.

func (*NN) Predict added in v0.0.57

func (nn *NN) Predict(x *mat.Dense) *mat.VecDense

type NNConfig added in v0.0.57

type NNConfig struct {
	LearningRate float64
	Epochs       int
	Input        int
	Hidden       int
}

type Predictor added in v0.0.57

type Predictor interface {
	Predict(x *mat.Dense) *mat.VecDense
}

Predictor is used to predict values based on a ml-model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL