config

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeighborTypeAuto    = "auto"
	NeighborTypeSimilar = "similar"
	NeighborTypeRelated = "related"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CollaborativeConfig added in v0.4.0

type CollaborativeConfig struct {
	ModelFitPeriod    time.Duration `mapstructure:"model_fit_period" validate:"gt=0"`
	ModelSearchPeriod time.Duration `mapstructure:"model_search_period" validate:"gt=0"`
	ModelSearchEpoch  int           `mapstructure:"model_search_epoch" validate:"gt=0"`
	ModelSearchTrials int           `mapstructure:"model_search_trials" validate:"gt=0"`
	EnableIndex       bool          `mapstructure:"enable_index"`
	IndexRecall       float32       `mapstructure:"index_recall" validate:"gt=0"`
	IndexFitEpoch     int           `mapstructure:"index_fit_epoch" validate:"gt=0"`
}

type Config

type Config struct {
	Database  DatabaseConfig  `mapstructure:"database"`
	Master    MasterConfig    `mapstructure:"master"`
	Server    ServerConfig    `mapstructure:"server"`
	Recommend RecommendConfig `mapstructure:"recommend"`
}

Config is the configuration for the engine.

func GetDefaultConfig added in v0.4.0

func GetDefaultConfig() *Config

func LoadConfig

func LoadConfig(path string, oneModel bool) (*Config, error)

LoadConfig loads configuration from toml file.

func (*Config) ItemNeighborDigest added in v0.4.1

func (config *Config) ItemNeighborDigest() string

func (*Config) OfflineRecommendDigest added in v0.4.1

func (config *Config) OfflineRecommendDigest(option ...DigestOption) string

func (*Config) UserNeighborDigest added in v0.4.1

func (config *Config) UserNeighborDigest() string

func (*Config) Validate added in v0.4.5

func (config *Config) Validate(oneModel bool) error

type DataSourceConfig added in v0.4.0

type DataSourceConfig struct {
	PositiveFeedbackTypes []string `mapstructure:"positive_feedback_types" validate:"min=1,dive,required"` // positive feedback type
	ReadFeedbackTypes     []string `mapstructure:"read_feedback_types" validate:"min=1,dive,required"`     // feedback type for read event
	PositiveFeedbackTTL   uint     `mapstructure:"positive_feedback_ttl" validate:"gte=0"`                 // time-to-live of positive feedbacks
	ItemTTL               uint     `mapstructure:"item_ttl" validate:"gte=0"`                              // item-to-live of items
}

type DatabaseConfig

type DatabaseConfig struct {
	DataStore  string `mapstructure:"data_store" validate:"required,data_store"`   // database for data store
	CacheStore string `mapstructure:"cache_store" validate:"required,cache_store"` // database for cache store
}

DatabaseConfig is the configuration for the database.

type DigestOption added in v0.4.1

type DigestOption func(option *digestOptions)

func WithCollaborative added in v0.4.1

func WithCollaborative(v bool) DigestOption

func WithItemNeighborDigest added in v0.4.1

func WithItemNeighborDigest(digest string) DigestOption

func WithRanking added in v0.4.1

func WithRanking(v bool) DigestOption

func WithUserNeighborDigest added in v0.4.1

func WithUserNeighborDigest(digest string) DigestOption

type MasterConfig

type MasterConfig struct {
	Port              int           `mapstructure:"port" validate:"gte=0"`        // master port
	Host              string        `mapstructure:"host"`                         // master host
	HttpPort          int           `mapstructure:"http_port" validate:"gte=0"`   // HTTP port
	HttpHost          string        `mapstructure:"http_host"`                    // HTTP host
	NumJobs           int           `mapstructure:"n_jobs" validate:"gt=0"`       // number of working jobs
	MetaTimeout       time.Duration `mapstructure:"meta_timeout" validate:"gt=0"` // cluster meta timeout (second)
	DashboardUserName string        `mapstructure:"dashboard_user_name"`          // dashboard user name
	DashboardPassword string        `mapstructure:"dashboard_password"`           // dashboard password
}

MasterConfig is the configuration for the master.

type NeighborsConfig added in v0.4.0

type NeighborsConfig struct {
	NeighborType  string  `mapstructure:"neighbor_type" validate:"oneof=auto similar related ''"`
	EnableIndex   bool    `mapstructure:"enable_index"`
	IndexRecall   float32 `mapstructure:"index_recall" validate:"gt=0"`
	IndexFitEpoch int     `mapstructure:"index_fit_epoch" validate:"gt=0"`
}

type OfflineConfig added in v0.4.0

type OfflineConfig struct {
	CheckRecommendPeriod         time.Duration      `mapstructure:"check_recommend_period" validate:"gt=0"`
	RefreshRecommendPeriod       time.Duration      `mapstructure:"refresh_recommend_period" validate:"gt=0"`
	ExploreRecommend             map[string]float64 `mapstructure:"explore_recommend"`
	EnableLatestRecommend        bool               `mapstructure:"enable_latest_recommend"`
	EnablePopularRecommend       bool               `mapstructure:"enable_popular_recommend"`
	EnableUserBasedRecommend     bool               `mapstructure:"enable_user_based_recommend"`
	EnableItemBasedRecommend     bool               `mapstructure:"enable_item_based_recommend"`
	EnableColRecommend           bool               `mapstructure:"enable_collaborative_recommend"`
	EnableClickThroughPrediction bool               `mapstructure:"enable_click_through_prediction"`
	// contains filtered or unexported fields
}

func (*OfflineConfig) GetExploreRecommend added in v0.4.0

func (config *OfflineConfig) GetExploreRecommend(key string) (value float64, exist bool)

func (*OfflineConfig) Lock added in v0.4.0

func (config *OfflineConfig) Lock()

func (*OfflineConfig) UnLock added in v0.4.0

func (config *OfflineConfig) UnLock()

type OnlineConfig added in v0.4.0

type OnlineConfig struct {
	FallbackRecommend            []string `mapstructure:"fallback_recommend"`
	NumFeedbackFallbackItemBased int      `mapstructure:"num_feedback_fallback_item_based" validate:"gt=0"`
}

type PopularConfig added in v0.4.0

type PopularConfig struct {
	PopularWindow time.Duration `mapstructure:"popular_window" validate:"gte=0"`
}

type RecommendConfig

type RecommendConfig struct {
	CacheSize     int                 `mapstructure:"cache_size" validate:"gt=0"`
	CacheExpire   time.Duration       `mapstructure:"cache_expire" validate:"gt=0"`
	DataSource    DataSourceConfig    `mapstructure:"data_source"`
	Popular       PopularConfig       `mapstructure:"popular"`
	UserNeighbors NeighborsConfig     `mapstructure:"user_neighbors"`
	ItemNeighbors NeighborsConfig     `mapstructure:"item_neighbors"`
	Collaborative CollaborativeConfig `mapstructure:"collaborative"`
	Replacement   ReplacementConfig   `mapstructure:"replacement"`
	Offline       OfflineConfig       `mapstructure:"offline"`
	Online        OnlineConfig        `mapstructure:"online"`
}

RecommendConfig is the configuration of recommendation setup.

type ReplacementConfig added in v0.4.0

type ReplacementConfig struct {
	EnableReplacement        bool    `mapstructure:"enable_replacement"`
	PositiveReplacementDecay float64 `mapstructure:"positive_replacement_decay" validate:"gt=0"`
	ReadReplacementDecay     float64 `mapstructure:"read_replacement_decay" validate:"gt=0"`
}

type ServerConfig

type ServerConfig struct {
	APIKey         string        `mapstructure:"api_key"`                      // default number of returned items
	DefaultN       int           `mapstructure:"default_n" validate:"gt=0"`    // secret key for RESTful APIs (SSL required)
	ClockError     time.Duration `mapstructure:"clock_error" validate:"gte=0"` // clock error in the cluster in seconds
	AutoInsertUser bool          `mapstructure:"auto_insert_user"`             // insert new users while inserting feedback
	AutoInsertItem bool          `mapstructure:"auto_insert_item"`             // insert new items while inserting feedback
	CacheExpire    time.Duration `mapstructure:"cache_expire" validate:"gt=0"` // server-side cache expire time
}

ServerConfig is the configuration for the server.

type Settings added in v0.4.4

type Settings struct {
	Config *Config

	// database clients
	CacheClient cache.Database
	DataClient  data.Database

	// recommendation models
	RankingModel        ranking.MatrixFactorization
	RankingModelVersion int64
	ClickModel          click.FactorizationMachine
	ClickModelVersion   int64
}

func NewSettings added in v0.4.4

func NewSettings() *Settings

Jump to

Keyboard shortcuts

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