sort

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ItemDefaultName = "DEFAULT"
)

Variables

This section is empty.

Functions

func BetweenSlackInterval

func BetweenSlackInterval(input, setPoint, delta float64) bool

func DPP

func DPP(L *mat.Dense, topN int, existed []int) []int

func DPPWithWindow

func DPPWithWindow(L *mat.Dense, topN int, windowSize int) []int

func FlowControl

func FlowControl(controllers map[int]*PIDController, ctx *context.RecommendContext) (map[int]float64, int)

FlowControl 非单品(整体)目标流量调控,返回各个目标的调控力度

func GetMaxScore

func GetMaxScore(items []*module.Item) float64

func Load

func Load(config *recconf.RecommendConfig)

func RegisterEmbeddingHook

func RegisterEmbeddingHook(name string, fn EmbeddingHookFunc)

func RegisterSort

func RegisterSort(name string, s ISort)

func RegisterSortWithConfig

func RegisterSortWithConfig(config *recconf.RecommendConfig)

func SampleControlTargetsByScore

func SampleControlTargetsByScore(n int, score, alpha map[int]float64, ctx *context.RecommendContext)

SampleControlTargetsByScore 按照偏好分权重选择n个上提目标,未被选中的目标调控值置0

func Sort

func Sort(sortData *SortData, tag string)

func ToString

func ToString(plan interface{}, excludes ...string) string

Types

type AlgoScoreSort

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

func NewAlgoScoreSort

func NewAlgoScoreSort(config recconf.SortConfig) *AlgoScoreSort

func (*AlgoScoreSort) Sort

func (s *AlgoScoreSort) Sort(sortData *SortData) error

type BoostScoreByWeight

type BoostScoreByWeight struct {
	BoostScoreByWeightDao module.BoostScoreByWeightDao
}

func NewBoostScoreByWeight

func NewBoostScoreByWeight(config recconf.SortConfig) *BoostScoreByWeight

func (*BoostScoreByWeight) Sort

func (s *BoostScoreByWeight) Sort(sortData *SortData) error

type BoostScoreCondition

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

func NewBoostScoreCondition

func NewBoostScoreCondition(config *recconf.BoostScoreCondition) (*BoostScoreCondition, error)

type BoostScoreSort

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

func NewBoostScoreSort

func NewBoostScoreSort(config recconf.SortConfig) *BoostScoreSort

func (*BoostScoreSort) CloneWithConfig

func (s *BoostScoreSort) CloneWithConfig(params map[string]interface{}) ISort

func (*BoostScoreSort) GetSortName

func (s *BoostScoreSort) GetSortName() string

func (*BoostScoreSort) Sort

func (s *BoostScoreSort) Sort(sortData *SortData) error

type DPPSort

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

func NewDPPSort

func NewDPPSort(config recconf.DPPSortConfig) *DPPSort

func (*DPPSort) GenerateEmbedding

func (s *DPPSort) GenerateEmbedding(context *context.RecommendContext, item *module.Item) []float64

func (*DPPSort) KernelMatrix

func (s *DPPSort) KernelMatrix(context *context.RecommendContext, items []*module.Item, lenEmb int, hasTable bool) (*mat.Dense, error)

func (*DPPSort) Sort

func (s *DPPSort) Sort(sortData *SortData) error

type DistinctIdCondition

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

func NewDistinctIdCondition

func NewDistinctIdCondition(config *recconf.DistinctIdCondition) *DistinctIdCondition

type DistinctIdSort

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

func NewDistinctIdSort

func NewDistinctIdSort(config recconf.SortConfig) *DistinctIdSort

func (*DistinctIdSort) Sort

func (s *DistinctIdSort) Sort(sortData *SortData) error

type DiversityMatchFunc

type DiversityMatchFunc func(item *module.Item) bool

type DiversityRule

type DiversityRule struct {
	DiversityRuleConfig recconf.DiversityRuleConfig
	DimensionItemMap    map[module.ItemId]string
}

func NewDiversityRule

func NewDiversityRule(config recconf.DiversityRuleConfig) *DiversityRule

func (*DiversityRule) GetDimensionValue

func (r *DiversityRule) GetDimensionValue(item *module.Item) string

func (*DiversityRule) Match

func (r *DiversityRule) Match(item *module.Item, itemList []*module.Item) bool

type DiversityRuleSort

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

func NewDiversityRuleSort

func NewDiversityRuleSort(config recconf.SortConfig) *DiversityRuleSort

func (*DiversityRuleSort) CloneWithConfig

func (s *DiversityRuleSort) CloneWithConfig(params map[string]interface{}) ISort

func (*DiversityRuleSort) GetSortName

func (s *DiversityRuleSort) GetSortName() string

func (*DiversityRuleSort) Sort

func (s *DiversityRuleSort) Sort(sortData *SortData) error

type EmbeddingHookFunc

type EmbeddingHookFunc func(context *context.RecommendContext, item *module.Item) []float64

type Expression

type Expression struct {
	Field  string      `json:"field"`
	Option string      `json:"option"`
	Value  interface{} `json:"value"`
}

type ICloneSort

type ICloneSort interface {
	CloneWithConfig(params map[string]interface{}) ISort
	GetSortName() string
}

type ISort

type ISort interface {
	Sort(sortData *SortData) error
}

func GetSort

func GetSort(name string) (ISort, error)

GetSort return sort by name

type ItemContainer

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

func NewItemContaienr

func NewItemContaienr(strategy Strategy, size int) *ItemContainer

func (*ItemContainer) Assembly

func (c *ItemContainer) Assembly() (ret []*module.Item)

func (*ItemContainer) Assign

func (c *ItemContainer) Assign(name string, size int, capacity int, sortStrategy SortStrategy)

func (*ItemContainer) Split

func (c *ItemContainer) Split(items []*module.Item)

type ItemKey

type ItemKey string

type ItemKeyFunc

type ItemKeyFunc func(item *module.Item, context *context.RecommendContext) string

type ItemRankScoreSort

type ItemRankScoreSort struct {
}

func NewItemRankScoreSort

func NewItemRankScoreSort() *ItemRankScoreSort

func (*ItemRankScoreSort) Sort

func (s *ItemRankScoreSort) Sort(sortData *SortData) error

type ItemRankSlice

type ItemRankSlice []*module.Item

func (ItemRankSlice) Len

func (us ItemRankSlice) Len() int

func (ItemRankSlice) Less

func (us ItemRankSlice) Less(i, j int) bool

func (ItemRankSlice) Swap

func (us ItemRankSlice) Swap(i, j int)

type ItemScoreSlice

type ItemScoreSlice []*module.Item

func (ItemScoreSlice) Len

func (us ItemScoreSlice) Len() int

func (ItemScoreSlice) Less

func (us ItemScoreSlice) Less(i, j int) bool

func (ItemScoreSlice) Swap

func (us ItemScoreSlice) Swap(i, j int)

type ItemScoreSort

type ItemScoreSort struct {
}

func (*ItemScoreSort) Sort

func (s *ItemScoreSort) Sort(sortData *SortData) error

type ItemSlot

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

ItemSlot is a group of items split by the Strategy, like SplitByRecallName

type MatrixDotFunc

type MatrixDotFunc func(threshold float64, pre, cur *module.Item) bool

type MatrixScatterRule

type MatrixScatterRule struct {
	Threshold float64
	// contains filtered or unexported fields
}

func NewMatrixScatterRule

func NewMatrixScatterRule(threshold float64, items []*module.Item, f MatrixDotFunc) *MatrixScatterRule

func (*MatrixScatterRule) Match

func (r *MatrixScatterRule) Match(pos int, item *module.Item, context *context.RecommendContext) bool

pos start from 1 return true or false, if return true, the item can add into the items

type MixSortStrategy

type MixSortStrategy interface {
	ContainsRecallName(name string) bool
	AppendItem(item *module.Item)
	IsFull() bool
	GetStrategyType() MixSortStrategyType
	BuildItems(items []*module.Item) []*module.Item
	Evaluate(properties map[string]interface{}) (bool, error)
	EvaluateByDomain(userProperties, itemProperties map[string]interface{}) (bool, error)
	IsUseCondition() bool
}

type MixSortStrategyType

type MixSortStrategyType int
const (
	FixPositionStrategyType MixSortStrategyType = 1

	RandomPositionStrategyType MixSortStrategyType = 2

	DefaultStrategyType MixSortStrategyType = 3
)

type MultiRecallMixSort

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

func NewMultiRecallMixSort

func NewMultiRecallMixSort(config recconf.SortConfig) *MultiRecallMixSort

func (*MultiRecallMixSort) Sort

func (s *MultiRecallMixSort) Sort(sortData *SortData) error

type PIDController

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

func (*PIDController) Do

func (p *PIDController) Do(input float64) (float64, float64)

func (*PIDController) DoWithId

func (p *PIDController) DoWithId(input float64, itemOrExpId string) (float64, float64)

func (*PIDController) GenScopeConditions

func (p *PIDController) GenScopeConditions()

func (*PIDController) GetMinExpTraffic

func (p *PIDController) GetMinExpTraffic() float64

func (*PIDController) IsAllocateExpWise

func (p *PIDController) IsAllocateExpWise() bool

func (*PIDController) IsContextMatch

func (p *PIDController) IsContextMatch(ctx *context.RecommendContext, item *module.Item) bool

func (*PIDController) IsControlledItem

func (p *PIDController) IsControlledItem(ctx *context.RecommendContext, item *module.Item) bool

func (*PIDController) IsControlledTraffic

func (p *PIDController) IsControlledTraffic(ctx *context.RecommendContext) bool

func (*PIDController) SetAllocateExpWise

func (p *PIDController) SetAllocateExpWise(wise bool)

func (*PIDController) SetConditions

func (p *PIDController) SetConditions(conditions []Expression)

func (*PIDController) SetErrDiscount

func (p *PIDController) SetErrDiscount(discount float64)

func (*PIDController) SetFreezeMinutes

func (p *PIDController) SetFreezeMinutes(minutes int)

func (*PIDController) SetMatchConditions

func (p *PIDController) SetMatchConditions(conditions []Expression)

func (*PIDController) SetMinExpTraffic

func (p *PIDController) SetMinExpTraffic(traffic float64)

func (*PIDController) SetOnline

func (p *PIDController) SetOnline(online bool)

func (*PIDController) SetParameters

func (p *PIDController) SetParameters(kp, ki, kd float32)

func (*PIDController) SetRunWithZeroInput

func (p *PIDController) SetRunWithZeroInput(run bool)

func (*PIDController) SetSampleTime

func (p *PIDController) SetSampleTime(sampleTime float32)

func (*PIDController) SetStartPageNum

func (p *PIDController) SetStartPageNum(pageNum int)

type PIDStatus

type PIDStatus struct {
	LastTime   int64
	LastOutput float32
	LastError  float32
	ErrSum     float32
}

type PositionReviseSort

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

func NewPositionReviseSort

func NewPositionReviseSort(config recconf.SortConfig) *PositionReviseSort

func (*PositionReviseSort) CloneWithConfig

func (p *PositionReviseSort) CloneWithConfig(params map[string]interface{}) ISort

func (*PositionReviseSort) GetSortName

func (p *PositionReviseSort) GetSortName() string

func (*PositionReviseSort) Sort

func (p *PositionReviseSort) Sort(sortData *SortData) error

type SortData

type SortData struct {
	Data         interface{}
	Context      *context.RecommendContext
	User         *module.User
	PipelineName string
}

type SortService

type SortService struct {
	SortStrategies map[string][]ISort
}

func (*SortService) AddSort

func (ss *SortService) AddSort(scene string, s ISort)

func (*SortService) AddSorts

func (ss *SortService) AddSorts(scene string, sorts []ISort)

func (*SortService) Sort

func (ss *SortService) Sort(data *SortData, tag string)

type SortStrategy

type SortStrategy int
const (
	SortByScoreStrategy SortStrategy = iota
	SortByRandomStrategy
)

type Strategy

type Strategy int

Strategy use to split items by which way

const (
	// RecallName split Items to ItemMap by recallName
	SplitByRecallName Strategy = iota
)

type WindowRule

type WindowRule struct {
	Size    int
	Min     int
	Max     int
	ItemKey ItemKeyFunc

	Total int
	// contains filtered or unexported fields
}

func NewWindowRule

func NewWindowRule(min, max, size, total int, f ItemKeyFunc) *WindowRule

size : window size total: window total size, recommend item list size

func (*WindowRule) AddToWindow

func (w *WindowRule) AddToWindow(pos int, item *module.Item, context *context.RecommendContext) bool

item add to the window list by the param pos, a int value of position pos start from 1 return true or false, if add success, return true, else return false

Jump to

Keyboard shortcuts

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