Documentation
¶
Index ¶
- func AUC(posPrediction, negPrediction []float32) float32
- func Accuracy(posPrediction, negPrediction []float32) float32
- func LoadLibFMFile(path string) (features [][]lo.Tuple2[int32, float32], targets []float32, maxLabel int32, ...)
- func MarshalModel(w io.Writer, m FactorizationMachines) error
- func Precision(posPrediction, negPrediction []float32) float32
- func Recall(posPrediction, _ []float32) float32
- type BaseFactorizationMachines
- type BatchInference
- type Dataset
- func (dataset *Dataset) Count() int
- func (dataset *Dataset) CountContextLabels() int
- func (dataset *Dataset) CountItemLabels() int
- func (dataset *Dataset) CountItems() int
- func (dataset *Dataset) CountNegative() int
- func (dataset *Dataset) CountPositive() int
- func (dataset *Dataset) CountUserLabels() int
- func (dataset *Dataset) CountUsers() int
- func (dataset *Dataset) Get(i int) ([]int32, []float32, float32)
- func (dataset *Dataset) GetIndex() dataset.UnifiedIndex
- func (dataset *Dataset) GetTarget(i int) float32
- func (dataset *Dataset) Split(ratio float32, seed int64) (*Dataset, *Dataset)
- type Embedding
- type FMV2
- func (fm *FMV2) BatchInternalPredict(x []lo.Tuple2[[]int32, []float32], jobs int) []float32
- func (fm *FMV2) BatchPredict(inputs []lo.Tuple4[string, string, []Label, []Label], jobs int) []float32
- func (fm *FMV2) Clear()
- func (fm *FMV2) Fit(ctx context.Context, trainSet, testSet dataset.CTRSplit, config *FitConfig) Score
- func (fm *FMV2) Forward(indices, values *nn.Tensor, jobs int) *nn.Tensor
- func (fm *FMV2) Init(trainSet dataset.CTRSplit)
- func (fm *FMV2) InternalPredict(_ []int32, _ []float32) float32
- func (fm *FMV2) Invalid() bool
- func (fm *FMV2) Marshal(w io.Writer) error
- func (fm *FMV2) Parameters() []*nn.Tensor
- func (fm *FMV2) Predict(_, _ string, _, _ []Label) float32
- func (fm *FMV2) SetParams(params model.Params)
- func (fm *FMV2) SuggestParams(trial goptuna.Trial) model.Params
- func (fm *FMV2) Unmarshal(r io.Reader) error
- type FactorizationMachineCloner
- type FactorizationMachineSpawner
- type FactorizationMachines
- type FitConfig
- type Label
- type ModelCreator
- type ModelSearch
- type Score
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadLibFMFile ¶
func LoadLibFMFile(path string) (features [][]lo.Tuple2[int32, float32], targets []float32, maxLabel int32, err error)
LoadLibFMFile loads libFM format file.
func MarshalModel ¶
func MarshalModel(w io.Writer, m FactorizationMachines) error
Types ¶
type BaseFactorizationMachines ¶
type BaseFactorizationMachines struct {
model.BaseModel
Index dataset.UnifiedIndex
}
func (*BaseFactorizationMachines) Init ¶
func (b *BaseFactorizationMachines) Init(trainSet dataset.CTRSplit)
type BatchInference ¶
type Dataset ¶
type Dataset struct {
Index dataset.UnifiedIndex
UserLabels [][]lo.Tuple2[int32, float32]
ItemLabels [][]lo.Tuple2[int32, float32]
ContextLabels [][]lo.Tuple2[int32, float32]
Users []int32
Items []int32
Target []float32
ItemEmbeddings [][][]float32
ItemEmbeddingDimension []int
ItemEmbeddingIndex *dataset.Index
PositiveCount int
NegativeCount int
}
Dataset for click-through-rate models.
func LoadDataFromBuiltIn ¶
LoadDataFromBuiltIn loads built-in dataset.
func (*Dataset) CountContextLabels ¶
func (*Dataset) CountItemLabels ¶
func (*Dataset) CountItems ¶
CountItems returns the number of items.
func (*Dataset) CountNegative ¶
func (*Dataset) CountPositive ¶
func (*Dataset) CountUserLabels ¶
func (*Dataset) CountUsers ¶
CountUsers returns the number of users.
func (*Dataset) GetIndex ¶
func (dataset *Dataset) GetIndex() dataset.UnifiedIndex
type Embedding ¶
func ConvertEmbeddings ¶
type FMV2 ¶
type FMV2 struct {
BaseFactorizationMachines
// parameters
B *nn.Tensor
W nn.Layer
V nn.Layer
// contains filtered or unexported fields
}
func (*FMV2) BatchInternalPredict ¶
func (*FMV2) BatchPredict ¶
func (*FMV2) Parameters ¶
type FactorizationMachineCloner ¶
type FactorizationMachineCloner interface {
Clone() FactorizationMachines
}
type FactorizationMachineSpawner ¶
type FactorizationMachineSpawner interface {
Spawn() FactorizationMachines
}
type FactorizationMachines ¶
type FactorizationMachines interface {
model.Model
Predict(userId, itemId string, userFeatures, itemFeatures []Label) float32
InternalPredict(x []int32, values []float32) float32
Fit(ctx context.Context, trainSet, testSet dataset.CTRSplit, config *FitConfig) Score
Marshal(w io.Writer) error
}
func Spawn ¶
func Spawn(m FactorizationMachines) FactorizationMachines
func UnmarshalModel ¶
func UnmarshalModel(r io.Reader) (FactorizationMachines, error)
type FitConfig ¶
func NewFitConfig ¶
func NewFitConfig() *FitConfig
func (*FitConfig) LoadDefaultIfNil ¶
func (*FitConfig) SetPatience ¶
func (*FitConfig) SetVerbose ¶
type Label ¶
func ConvertLabels ¶
type ModelCreator ¶
type ModelCreator func() FactorizationMachines
type ModelSearch ¶
type ModelSearch struct {
// contains filtered or unexported fields
}
func NewModelSearch ¶
func NewModelSearch(models map[string]ModelCreator, trainSet, testSet dataset.CTRSplit, config *FitConfig) *ModelSearch
func (*ModelSearch) Objective ¶
func (ms *ModelSearch) Objective(trial goptuna.Trial) (float64, error)
func (*ModelSearch) WithContext ¶
func (ms *ModelSearch) WithContext(ctx context.Context) *ModelSearch
func (*ModelSearch) WithSpan ¶
func (ms *ModelSearch) WithSpan(span *monitor.Span) *ModelSearch
type Score ¶
func EvaluateClassification ¶
func EvaluateClassification(estimator FactorizationMachines, testSet dataset.CTRSplit, jobs int) Score
EvaluateClassification evaluates factorization machines in classification task.
func EvaluateRegression ¶
func EvaluateRegression(estimator FactorizationMachines, testSet *Dataset) Score
EvaluateRegression evaluates factorization machines in regression task.
func (Score) BetterThan ¶
Click to show internal directories.
Click to hide internal directories.