core

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: 4 Imported by: 0

Documentation

Index

Constants

View Source
const NotId = -1

Variables

This section is empty.

Functions

func NewMatrixInt

func NewMatrixInt(row, col int) [][]int

func NewMatrixfloat64

func NewMatrixfloat64(row, col int) [][]float64

Types

type DataSet

type DataSet struct {
	// contains filtered or unexported fields
}

func NewDataSet

func NewDataSet(data map[uint32]map[uint32]float64) (set *DataSet)

func (*DataSet) Count

func (set *DataSet) Count() int

func (*DataSet) GetWithIndex

func (set *DataSet) GetWithIndex(i int) (userindex int, itemindex int, score float64)

func (*DataSet) GlobalMean

func (set *DataSet) GlobalMean() float64

func (*DataSet) Item

func (set *DataSet) Item(itemId uint32) *MarginalSubSet

func (*DataSet) ItemByIndex

func (set *DataSet) ItemByIndex(itemIndex int) *MarginalSubSet

func (*DataSet) ItemCount

func (set *DataSet) ItemCount() int

func (*DataSet) ItemIndexer

func (set *DataSet) ItemIndexer() *Indexer

func (*DataSet) Items

func (set *DataSet) Items() []*MarginalSubSet

func (*DataSet) User

func (set *DataSet) User(userId uint32) *MarginalSubSet

func (*DataSet) UserByIndex

func (set *DataSet) UserByIndex(userIndex int) *MarginalSubSet

func (*DataSet) UserCount

func (set *DataSet) UserCount() int

func (*DataSet) UserIndexer

func (set *DataSet) UserIndexer() *Indexer

func (*DataSet) Users

func (set *DataSet) Users() []*MarginalSubSet

type DataSetInterface

type DataSetInterface interface {
	Count() int
	GlobalMean() float64
	UserCount() int
	ItemCount() int
	Users() []*MarginalSubSet
	Items() []*MarginalSubSet
	UserIndexer() *Indexer
	ItemIndexer() *Indexer
	User(userId uint32) *MarginalSubSet
	Item(itemId uint32) *MarginalSubSet
	UserByIndex(userIndex int) *MarginalSubSet
	ItemByIndex(itemIndex int) *MarginalSubSet
	GetWithIndex(i int) (int, int, float64)
}

type Indexer

type Indexer struct {
	Indices map[uint32]int
	Ids     []uint32
}

func NewIndexer

func NewIndexer() *Indexer

func (*Indexer) Add

func (set *Indexer) Add(id uint32) int

func (*Indexer) Len

func (set *Indexer) Len() int

func (*Indexer) ToID

func (set *Indexer) ToID(index int) uint32

func (*Indexer) ToIndex

func (set *Indexer) ToIndex(id uint32) int

type MarginalSubSet

type MarginalSubSet struct {
	Indexer *Indexer
	SubSet  []int
}

func NewMarginalSubSet

func NewMarginalSubSet(indexer *Indexer, subset []int) *MarginalSubSet

func (*MarginalSubSet) Contain

func (set *MarginalSubSet) Contain(id uint32) bool

func (*MarginalSubSet) GetID

func (set *MarginalSubSet) GetID(i int) uint32

func (*MarginalSubSet) GetIndex

func (set *MarginalSubSet) GetIndex(i int) int

func (*MarginalSubSet) Len

func (set *MarginalSubSet) Len() int

func (*MarginalSubSet) Less

func (set *MarginalSubSet) Less(i, j int) bool

func (*MarginalSubSet) Swap

func (set *MarginalSubSet) Swap(i, j int)

type MaxHeap

type MaxHeap struct {
	Elem  []interface{} // store elements
	Score []float64     // store scores
	K     int           // the size of heap
}

func NewMaxHeap

func NewMaxHeap(k int) *MaxHeap

func (*MaxHeap) Add

func (maxHeap *MaxHeap) Add(elem interface{}, score float64)

func (*MaxHeap) Len

func (maxHeap *MaxHeap) Len() int

func (*MaxHeap) Less

func (maxHeap *MaxHeap) Less(i, j int) bool

func (*MaxHeap) Pop

func (maxHeap *MaxHeap) Pop() interface{}

func (*MaxHeap) Push

func (maxHeap *MaxHeap) Push(x interface{})

func (*MaxHeap) Swap

func (maxHeap *MaxHeap) Swap(i, j int)

func (*MaxHeap) ToSorted

func (maxHeap *MaxHeap) ToSorted() ([]interface{}, []float64)

type RandomGenerator

type RandomGenerator struct {
	*rand.Rand
}

func NewRandomGenerator

func NewRandomGenerator(seed int64) RandomGenerator

func (RandomGenerator) NewNormalMatrix

func (rng RandomGenerator) NewNormalMatrix(row, col int, mean, stdDev float64) [][]float64

func (RandomGenerator) NewNormalVector

func (rng RandomGenerator) NewNormalVector(size int, mean, stdDev float64) []float64

Jump to

Keyboard shortcuts

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