model

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GorseDir   string
	DataSetDir string
	TempDir    string
)

The Data directories

Functions

func LocateBuiltInDataset added in v0.2.0

func LocateBuiltInDataset(name string, format DatasetFormat) (string, string, error)

Types

type BaseModel added in v0.2.0

type BaseModel struct {
	Params Params // Hyper-parameters
	// contains filtered or unexported fields
}

BaseModel model must be included by every recommendation model. Hyper-parameters, ID sets, random generator and fitting options are managed the BaseModel model.

func (*BaseModel) GetParams added in v0.2.0

func (model *BaseModel) GetParams() Params

GetParams returns all hyper-parameters.

func (*BaseModel) GetRandomGenerator added in v0.2.0

func (model *BaseModel) GetRandomGenerator() base.RandomGenerator

func (*BaseModel) SetParams added in v0.2.0

func (model *BaseModel) SetParams(params Params)

SetParams sets hyper-parameters for the BaseModel model.

type DatasetFormat added in v0.2.0

type DatasetFormat int
const (
	FormatNCF DatasetFormat = iota
	FormatLibFM
)

type Model added in v0.2.0

type Model interface {
	SetParams(params Params)
	GetParams() Params
	GetParamsGrid(withSize bool) ParamsGrid
	Clear()
	Invalid() bool
}

Model is the interface for all models. Any model in this package should implement it.

type ParamName added in v0.2.0

type ParamName string

ParamName is the type of hyper-parameter names.

const (
	Lr          ParamName = "Lr"          // learning rate
	Reg         ParamName = "Reg"         // regularization strength
	NEpochs     ParamName = "NEpochs"     // number of epochs
	NFactors    ParamName = "NFactors"    // number of factors
	RandomState ParamName = "RandomState" // random state (seed)
	InitMean    ParamName = "InitMean"    // mean of gaussian initial parameter
	InitStdDev  ParamName = "InitStdDev"  // standard deviation of gaussian initial parameter
	Alpha       ParamName = "Alpha"       // weight for negative samples in ALS
	Similarity  ParamName = "Similarity"
	UseFeature  ParamName = "UseFeature"
)

Predefined hyper-parameter names

type Params added in v0.2.0

type Params map[ParamName]interface{}

Params stores hyper-parameters for an model. It is a map between strings (names) and interface{}s (values). For example, hyper-parameters for SVD is given by:

 base.Params{
		base.Lr:       0.007,
		base.NEpochs:  100,
		base.NFactors: 80,
		base.Reg:      0.1,
	}

func (Params) Copy added in v0.2.0

func (parameters Params) Copy() Params

Copy hyper-parameters.

func (Params) GetBool added in v0.2.2

func (parameters Params) GetBool(name ParamName, _default bool) bool

GetBool gets a boolean parameter by name. Returns _default if not exists or type doesn't match.

func (Params) GetFloat32 added in v0.2.0

func (parameters Params) GetFloat32(name ParamName, _default float32) float32

func (Params) GetInt added in v0.2.0

func (parameters Params) GetInt(name ParamName, _default int) int

GetInt gets a integer parameter by name. Returns _default if not exists or type doesn't match.

func (Params) GetInt64 added in v0.2.0

func (parameters Params) GetInt64(name ParamName, _default int64) int64

GetInt64 gets a int64 parameter by name. Returns _default if not exists or type doesn't match. The type will be converted if given int.

func (Params) GetString added in v0.2.0

func (parameters Params) GetString(name ParamName, _default string) string

GetString gets a string parameter

func (Params) Overwrite added in v0.2.0

func (parameters Params) Overwrite(params Params) Params

func (Params) ToString added in v0.2.0

func (parameters Params) ToString() string

type ParamsGrid added in v0.2.0

type ParamsGrid map[ParamName][]interface{}

ParamsGrid contains candidate for grid search.

func (ParamsGrid) Fill added in v0.2.0

func (grid ParamsGrid) Fill(_default ParamsGrid)

func (ParamsGrid) Len added in v0.2.0

func (grid ParamsGrid) Len() int

func (ParamsGrid) NumCombinations added in v0.2.0

func (grid ParamsGrid) NumCombinations() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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