model

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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() util.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
	SuggestParams(trial goptuna.Trial) Params
	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"
	BatchSize    ParamName = "BatchSize"
	HiddenLayers ParamName = "HiddenLayers"
	Optimizer    ParamName = "Optimizer"
	AutoScale    ParamName = "AutoScale"

	SGD  = "sgd"
	Adam = "adam"
)

Predefined hyper-parameter names

type Params

type Params map[ParamName]any

Params stores hyper-parameters for an model. It is a map between strings (names) and anys (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) GetIntSlice

func (parameters Params) GetIntSlice(name ParamName, _default []int) []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

type ParamsGrid

type ParamsGrid map[ParamName][]any

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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