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 AFM
- func (fm *AFM) BatchInternalPredict(x []lo.Tuple2[[]int32, []float32], e [][][]float32, jobs int) []float32
- func (fm *AFM) BatchPredict(inputs []lo.Tuple4[string, string, []Label, []Label], embeddings [][]Embedding, ...) []float32
- func (fm *AFM) Clear()
- func (fm *AFM) Fit(ctx context.Context, trainSet, testSet dataset.CTRSplit, config *FitConfig) Score
- func (fm *AFM) Forward(indices, values *nn.Tensor, embeddings []*nn.Tensor, jobs int) *nn.Tensor
- func (fm *AFM) Init(trainSet dataset.CTRSplit)
- func (fm *AFM) InternalPredict(_ []int32, _ []float32) float32
- func (fm *AFM) Invalid() bool
- func (fm *AFM) Marshal(w io.Writer) error
- func (fm *AFM) Parameters() []*nn.Tensor
- func (fm *AFM) Predict(_, _ string, _, _ []Label) float32
- func (fm *AFM) SetParams(params model.Params)
- func (fm *AFM) SuggestParams(trial goptuna.Trial) model.Params
- func (fm *AFM) Unmarshal(r io.Reader) error
- 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, float32)
- func (dataset *Dataset) GetIndex() dataset.UnifiedIndex
- func (dataset *Dataset) GetItemEmbeddingDim() []int
- func (dataset *Dataset) GetItemEmbeddingIndex() *dataset.Index
- func (dataset *Dataset) GetTarget(i int) float32
- func (dataset *Dataset) Split(ratio float32, seed int64) (*Dataset, *Dataset)
- type Embedding
- 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 AFM ¶ added in v0.5.2
type AFM struct {
BaseFactorizationMachines
// parameters
B *nn.Tensor
W nn.Layer
V nn.Layer
A []nn.Layer
E []nn.Layer
// contains filtered or unexported fields
}
func (*AFM) BatchInternalPredict ¶ added in v0.5.2
func (*AFM) BatchPredict ¶ added in v0.5.2
func (*AFM) InternalPredict ¶ added in v0.5.2
func (*AFM) Parameters ¶ added in v0.5.2
func (*AFM) SuggestParams ¶ added in v0.5.2
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 // Index by row id, embedding id, embedding dimension
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
func (*Dataset) GetItemEmbeddingDim ¶ added in v0.5.2
func (*Dataset) GetItemEmbeddingIndex ¶ added in v0.5.2
type Embedding ¶
func ConvertEmbeddings ¶
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 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.