model

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 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

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

Types

type BaseModel

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

func (model *BaseModel) GetParams() Params

GetParams returns all hyper-parameters.

func (*BaseModel) GetRandomGenerator

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

func (*BaseModel) SetParams

func (model *BaseModel) SetParams(params Params)

SetParams sets hyper-parameters for the BaseModel model.

type DatasetFormat

type DatasetFormat int
const (
	FormatNCF DatasetFormat = iota
	FormatLibFM
)

type Model

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

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

type ParamName

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

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

func (parameters Params) Copy() Params

Copy hyper-parameters.

func (Params) GetBool

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

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

func (Params) GetInt

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

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

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

GetString gets a string parameter

func (Params) Overwrite

func (parameters Params) Overwrite(params Params) Params

func (Params) ToString

func (parameters Params) ToString() string

type ParamsGrid

type ParamsGrid map[ParamName][]interface{}

ParamsGrid contains candidate for grid search.

func (ParamsGrid) Fill

func (grid ParamsGrid) Fill(_default ParamsGrid)

func (ParamsGrid) Len

func (grid ParamsGrid) Len() int

func (ParamsGrid) NumCombinations

func (grid ParamsGrid) NumCombinations() int

type Runner

type Runner interface {
	Lock()
	UnLock()
}

type Tracker

type Tracker interface {
	Start(total int)
	Update(done int)
	Finish()
	Suspend(flag bool)
	SubTracker() Tracker
	Fail(err string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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