model

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Items

func Items(dataSet ...core.DataSetInterface) map[uint32]bool

func Top

func Top(items map[uint32]bool, userId uint32, n int, exclude *core.MarginalSubSet, model IModel) ([]uint32, []float64)

Types

type BPR

type BPR struct {
	ModelBase
	UserFactor [][]float64 // p_u
	ItemFactor [][]float64 // q_i

	UserRatings []*core.MarginalSubSet
	ItemPop     *ItemPop
	// contains filtered or unexported fields
}

贝叶斯个性化推荐 模型

func NewBPR

func NewBPR(params Params) *BPR

func (*BPR) Fit

func (bpr *BPR) Fit(trainSet core.DataSetInterface)

func (*BPR) Predict

func (bpr *BPR) Predict(userId, itemId uint32) float64

func (*BPR) SetParams

func (bpr *BPR) SetParams(params Params)

type IModel

type IModel interface {
	SetParams(params Params)
	GetParams() Params
	Predict(userId, itemId uint32) float64
	Fit(trainSet core.DataSetInterface)
}

type ItemPop

type ItemPop struct {
	ModelBase
	Pop []float64
}

func NewItemPop

func NewItemPop(params Params) *ItemPop

func (*ItemPop) Fit

func (pop *ItemPop) Fit(set core.DataSetInterface)

func (*ItemPop) Predict

func (pop *ItemPop) Predict(userId, itemId uint32) float64

type ModelBase

type ModelBase struct {
	Params      Params
	UserIndexer *core.Indexer // Users' ID set
	ItemIndexer *core.Indexer // Items' ID set
	// contains filtered or unexported fields
}

func (*ModelBase) GetParams

func (model *ModelBase) GetParams() Params

func (*ModelBase) Init

func (model *ModelBase) Init(trainSet core.DataSetInterface)

func (*ModelBase) SetParams

func (model *ModelBase) SetParams(params Params)

type ParamName

type ParamName string
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)	随机状态(种子)
	UseBias       ParamName = "UseBias"       // use bias				使用偏见
	InitMean      ParamName = "InitMean"      // mean of gaussian initial parameter	高斯初始参数的平均值
	InitStdDev    ParamName = "InitStdDev"    // standard deviation of gaussian initial parameter	高斯初始参数的标准偏差
	InitLow       ParamName = "InitLow"       // lower bound of uniform initial parameter			统一初始参数的下界
	InitHigh      ParamName = "InitHigh"      // upper bound of uniform initial parameter			统一初始参数的上限
	NUserClusters ParamName = "NUserClusters" // number of user cluster								用户集群数
	NItemClusters ParamName = "NItemClusters" // number of item cluster								项目群数
	Type          ParamName = "Type"          // type for KNN										KNN类型
	UserBased     ParamName = "UserBased"     // user based if true. otherwise item based.			基于用户(如果为true)。 否则基于项目。
	Similarity    ParamName = "Similarity"    // similarity metrics									相似性指标
	K             ParamName = "K"             // number of neighbors								邻居数
	MinK          ParamName = "MinK"          // least number of neighbors							邻居最少
	Optimizer     ParamName = "Optimizer"     // optimizer for optimization (SGD/ALS/BPR)			用于优化的优化器(SGD / ALS / BPR)
	Shrinkage     ParamName = "Shrinkage"     // shrinkage strength of similarity					相似收缩强度
	Alpha         ParamName = "Alpha"         // alpha value, depend on context						alpha值,取决于上下文
)

type Params

type Params map[ParamName]interface{}

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 bool parameter by name. Returns _default if not exists or type doesn't match.

func (Params) GetFloat64

func (parameters Params) GetFloat64(name ParamName, _default float64) float64

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

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. Returns _default if not exists or type doesn't match.

func (Params) Merge

func (parameters Params) Merge(params Params) Params

Merge another group of hyper-parameters to current group of hyper-parameters.

type SVD

type SVD struct {
	ModelBase
	UserFactor [][]float64 // p_u
	ItemFactor [][]float64 // q_i
	UserBias   []float64   // b_u
	ItemBias   []float64   // b_i
	GlobalMean float64     // mu

	// Fallback model
	UserRatings []*core.MarginalSubSet
	ItemPop     *ItemPop
	// contains filtered or unexported fields
}

func NewSVD

func NewSVD(params Params) *SVD

func (*SVD) Fit

func (svd *SVD) Fit(trainSet core.DataSetInterface)

func (*SVD) Predict

func (svd *SVD) Predict(userId, itemId uint32) float64

Predict by the SVD model.

func (*SVD) SetParams

func (svd *SVD) SetParams(params Params)

Jump to

Keyboard shortcuts

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