Versions in this module Expand all Collapse all v0 v0.4.6 Jun 16, 2022 Changes in this version + func AUC(posPrediction, negPrediction []float32) float32 + func Accuracy(posPrediction, negPrediction []float32) float32 + func LoadLibFMFile(path string) (features [][]int32, values [][]float32, targets base.Array[float32], ...) + func MarshalIndex(w io.Writer, index UnifiedIndex) error + func MarshalModel(w io.Writer, m FactorizationMachine) error + func Precision(posPrediction, negPrediction []float32) float32 + func Recall(posPrediction, _ []float32) float32 + type BaseFactorizationMachine struct + Index UnifiedIndex + func (b *BaseFactorizationMachine) Init(trainSet *Dataset) + type Dataset struct + CtxFeatures [][]int32 + CtxValues [][]float32 + Index UnifiedIndex + ItemFeatures [][]int32 + Items base.Array[int32] + NegativeCount int + NormValues base.Array[float32] + PositiveCount int + Target base.Array[float32] + UserFeatures [][]int32 + Users base.Array[int32] + func LoadDataFromBuiltIn(name string) (train, test *Dataset, err error) + func (dataset *Dataset) Bytes() int + func (dataset *Dataset) Count() int + func (dataset *Dataset) Get(i int) ([]int32, []float32, float32) + func (dataset *Dataset) ItemCount() int + func (dataset *Dataset) Split(ratio float32, seed int64) (*Dataset, *Dataset) + func (dataset *Dataset) UserCount() int + type FM struct + B float32 + MaxTarget float32 + MinTarget float32 + Task FMTask + V [][]float32 + W []float32 + func NewFM(task FMTask, params model.Params) *FM + func (fm *FM) Bytes() int + func (fm *FM) Clear() + func (fm *FM) Fit(trainSet, testSet *Dataset, config *FitConfig) Score + func (fm *FM) GetParamsGrid() model.ParamsGrid + func (fm *FM) Init(trainSet *Dataset) + func (fm *FM) InternalPredict(features []int32, values []float32) float32 + func (fm *FM) Invalid() bool + func (fm *FM) Marshal(w io.Writer) error + func (fm *FM) Predict(userId, itemId string, userLabels, itemLabels []string) float32 + func (fm *FM) SetParams(params model.Params) + func (fm *FM) Unmarshal(r io.Reader) error + type FMTask uint8 + const FMClassification + const FMRegression + type FactorizationMachine interface + Bytes func() int + Fit func(trainSet *Dataset, testSet *Dataset, config *FitConfig) Score + InternalPredict func(x []int32, values []float32) float32 + Marshal func(w io.Writer) error + Predict func(userId, itemId string, userLabels, itemLabels []string) float32 + func Clone(m FactorizationMachine) FactorizationMachine + func UnmarshalModel(r io.Reader) (FactorizationMachine, error) + type FitConfig struct + Jobs int + Tracker model.Tracker + Verbose int + func NewFitConfig() *FitConfig + func (config *FitConfig) LoadDefaultIfNil() *FitConfig + func (config *FitConfig) SetJobs(nJobs int) *FitConfig + func (config *FitConfig) SetTracker(tracker model.Tracker) *FitConfig + func (config *FitConfig) SetVerbose(verbose int) *FitConfig + type ModelSearcher struct + func NewModelSearcher(nEpoch, nTrials, nJobs int) *ModelSearcher + func (searcher *ModelSearcher) Fit(trainSet, valSet *Dataset, tracker model.Tracker, runner model.Runner) error + func (searcher *ModelSearcher) GetBestModel() (FactorizationMachine, Score) + type ParamsSearchResult struct + BestIndex int + BestModel FactorizationMachine + BestParams model.Params + BestScore Score + Params []model.Params + Scores []Score + func GridSearchCV(estimator FactorizationMachine, trainSet *Dataset, testSet *Dataset, ...) ParamsSearchResult + func RandomSearchCV(estimator FactorizationMachine, trainSet *Dataset, testSet *Dataset, ...) ParamsSearchResult + type Score struct + AUC float32 + Accuracy float32 + Precision float32 + RMSE float32 + Recall float32 + Task FMTask + func EvaluateClassification(estimator FactorizationMachine, testSet *Dataset) Score + func EvaluateRegression(estimator FactorizationMachine, testSet *Dataset) Score + func (score Score) BetterThan(s Score) bool + func (score Score) GetValue() float32 + func (score Score) ZapFields() []zap.Field + type SnapshotManger struct + BestScore Score + BestWeights []interface{} + func (sm *SnapshotManger) AddSnapshot(score Score, weights ...interface{}) + type UnifiedDirectIndex struct + N int32 + func (unified *UnifiedDirectIndex) Bytes() int + func (unified *UnifiedDirectIndex) CountContextLabels() int32 + func (unified *UnifiedDirectIndex) CountItemLabels() int32 + func (unified *UnifiedDirectIndex) CountItems() int32 + func (unified *UnifiedDirectIndex) CountUserLabels() int32 + func (unified *UnifiedDirectIndex) CountUsers() int32 + func (unified *UnifiedDirectIndex) EncodeContextLabel(label string) int32 + func (unified *UnifiedDirectIndex) EncodeItem(itemId string) int32 + func (unified *UnifiedDirectIndex) EncodeItemLabel(itemLabel string) int32 + func (unified *UnifiedDirectIndex) EncodeUser(userId string) int32 + func (unified *UnifiedDirectIndex) EncodeUserLabel(userLabel string) int32 + func (unified *UnifiedDirectIndex) GetContextLabels() []string + func (unified *UnifiedDirectIndex) GetItemLabels() []string + func (unified *UnifiedDirectIndex) GetItems() []string + func (unified *UnifiedDirectIndex) GetUserLabels() []string + func (unified *UnifiedDirectIndex) GetUsers() []string + func (unified *UnifiedDirectIndex) Len() int32 + func (unified *UnifiedDirectIndex) Marshal(w io.Writer) error + func (unified *UnifiedDirectIndex) Unmarshal(r io.Reader) error + type UnifiedIndex interface + Bytes func() int + CountContextLabels func() int32 + CountItemLabels func() int32 + CountItems func() int32 + CountUserLabels func() int32 + CountUsers func() int32 + EncodeContextLabel func(ctxLabel string) int32 + EncodeItem func(itemId string) int32 + EncodeItemLabel func(itemLabel string) int32 + EncodeUser func(userId string) int32 + EncodeUserLabel func(userLabel string) int32 + GetContextLabels func() []string + GetItemLabels func() []string + GetItems func() []string + GetUserLabels func() []string + GetUsers func() []string + Len func() int32 + Marshal func(w io.Writer) error + Unmarshal func(r io.Reader) error + func NewUnifiedDirectIndex(n int32) UnifiedIndex + func UnmarshalIndex(r io.Reader) (UnifiedIndex, error) + type UnifiedMapIndex struct + CtxLabelIndex base.Index + ItemIndex base.Index + ItemLabelIndex base.Index + UserIndex base.Index + UserLabelIndex base.Index + func (unified *UnifiedMapIndex) Bytes() int + func (unified *UnifiedMapIndex) CountContextLabels() int32 + func (unified *UnifiedMapIndex) CountItemLabels() int32 + func (unified *UnifiedMapIndex) CountItems() int32 + func (unified *UnifiedMapIndex) CountUserLabels() int32 + func (unified *UnifiedMapIndex) CountUsers() int32 + func (unified *UnifiedMapIndex) EncodeContextLabel(label string) int32 + func (unified *UnifiedMapIndex) EncodeItem(itemId string) int32 + func (unified *UnifiedMapIndex) EncodeItemLabel(itemLabel string) int32 + func (unified *UnifiedMapIndex) EncodeUser(userId string) int32 + func (unified *UnifiedMapIndex) EncodeUserLabel(userLabel string) int32 + func (unified *UnifiedMapIndex) GetContextLabels() []string + func (unified *UnifiedMapIndex) GetItemLabels() []string + func (unified *UnifiedMapIndex) GetItems() []string + func (unified *UnifiedMapIndex) GetUserLabels() []string + func (unified *UnifiedMapIndex) GetUsers() []string + func (unified *UnifiedMapIndex) Len() int32 + func (unified *UnifiedMapIndex) Marshal(w io.Writer) error + func (unified *UnifiedMapIndex) Unmarshal(r io.Reader) error + type UnifiedMapIndexBuilder struct + CtxLabelIndex base.Index + ItemIndex base.Index + ItemLabelIndex base.Index + UserIndex base.Index + UserLabelIndex base.Index + func NewUnifiedMapIndexBuilder() *UnifiedMapIndexBuilder + func (builder *UnifiedMapIndexBuilder) AddCtxLabel(ctxLabel string) + func (builder *UnifiedMapIndexBuilder) AddItem(itemId string) + func (builder *UnifiedMapIndexBuilder) AddItemLabel(itemLabel string) + func (builder *UnifiedMapIndexBuilder) AddUser(userId string) + func (builder *UnifiedMapIndexBuilder) AddUserLabel(userLabel string) + func (builder *UnifiedMapIndexBuilder) Build() UnifiedIndex