Documentation
¶
Overview ¶
Package predictor provides functionalities for loading predictions based on saved data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
Hours uint8
// contains filtered or unexported fields
}
func (*Controller) LoadEvents ¶
LoadEvents loads historical events from the database into the predictor.
func (*Controller) PredictLoad ¶
func (c *Controller) PredictLoad() []databaser.Event
PredictLoad generates load predictions for the configured number of hours.
func (*Controller) Run ¶
func (c *Controller) Run(ctx context.Context) <-chan struct{}
Run starts the controller to listen for events and process them.
type HolidayChecker ¶
HolidayChecker checks if a given date is a holiday and retrieves the holiday title.
type HourlyStats ¶
type HourlyStats struct {
WeightedSum float64 // Sum(load × weight)
TotalWeight float64 // Sum(weight)
Count uint64 // total events counted
LastUpdate time.Time // last update time
}
HourlyStats is a storage for hourly statistics.
type Prediction ¶
type Prediction struct {
TargetTime time.Time
Hour int
Load float64
Confidence float64 // prediction confidence [0.0..1.0]
IsHoliday bool
}
Prediction represents a load prediction for a specific hour.
type Predictor ¶
type Predictor struct {
// contains filtered or unexported fields
}
Predictor holds the statistics and provides methods to update and retrieve predictions.
func New ¶
func New(holidayChecker HolidayChecker) *Predictor
New creates a new Predictor instance with the provided HolidayChecker.
func (*Predictor) Predict ¶
func (p *Predictor) Predict(hoursAhead uint8) Prediction
Predict returns a load prediction for the specified number of hours ahead.
func (*Predictor) PredictRange ¶
func (p *Predictor) PredictRange(maxHours uint8) []Prediction
PredictRange returns load predictions for the next maxHours hours.
type RussianHolidayChecker ¶
type RussianHolidayChecker struct {
// contains filtered or unexported fields
}
func NewRussianHolidayChecker ¶
func NewRussianHolidayChecker(ctx context.Context, db *databaser.DB, location *time.Location) (*RussianHolidayChecker, error)
NewRussianHolidayChecker creates a new RussianHolidayChecker with holidays loaded from the database.
func (*RussianHolidayChecker) HolidayTitle ¶
func (c *RussianHolidayChecker) HolidayTitle(t time.Time) string
HolidayTitle returns the title of the holiday for the given date.