feature

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChangepointCompBias  = "bias"
	ChangepointCompSlope = "slope"
)
View Source
const (
	FourierCompSin = "sin"
	FourierCompCos = "cos"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Changepoint

type Changepoint struct {
	Name            string          `json:"name"`
	ChangepointComp ChangepointComp `json:"changepoint_component"`
}

Changepoint feature representing a point in time that we expect a jump or trend change in the training time series. The component is either of type bias (jump) or slope (trend).

func NewChangepoint

func NewChangepoint(name string, comp ChangepointComp) *Changepoint

NewChangepoint creates a new changepoint instance given a name and changepoint component type

func (Changepoint) Decode

func (c Changepoint) Decode() map[string]string

Decode converts the feature into a map of label values

func (Changepoint) Get

func (c Changepoint) Get(label string) (string, bool)

Get returns the value of an arbitrary label annd returns the value along with whether the label exists

func (Changepoint) String

func (c Changepoint) String() string

String returns the string representation of the changepoint feature

func (Changepoint) Type

func (c Changepoint) Type() FeatureType

Type returns the type of this feature

func (*Changepoint) UnmarshalJSON

func (c *Changepoint) UnmarshalJSON(data []byte) error

UnmarshalJSON is the custom unmarshalling to convert a map[string]string to a changepoint feature

type ChangepointComp

type ChangepointComp string

type Event added in v0.2.11

type Event struct {
	Name string `json:"name"`
}

Event feature representing a point in time that we expect a jump or trend change in the training time series. The component is either of type bias (jump) or slope (trend).

func NewEvent added in v0.2.11

func NewEvent(name string) *Event

NewEvent creates a new event instance given a name

func (Event) Decode added in v0.2.11

func (e Event) Decode() map[string]string

Decode converts the feature into a map of label values

func (Event) Get added in v0.2.11

func (e Event) Get(label string) (string, bool)

Get returns the value of an arbitrary label annd returns the value along with whether the label exists

func (Event) String added in v0.2.11

func (e Event) String() string

String returns the string representation of the event feature

func (Event) Type added in v0.2.11

func (e Event) Type() FeatureType

Type returns the type of this feature

func (*Event) UnmarshalJSON added in v0.2.11

func (e *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON is the custom unmarshalling to convert a map[string]string to a event feature

type Feature

type Feature interface {
	// String returns the string representation of the feature
	String() string

	// Get returns the value of an arbitrary label and returns the value along with whether
	// the label exists
	Get(string) (string, bool)

	// Type returns the type of this feature
	Type() FeatureType

	// Decode converts the feature into a map of label values
	Decode() map[string]string

	// UnmarshalJSON is the custom unmarshalling to convert a map[string]string
	// to a feature
	UnmarshalJSON([]byte) error
}

Feature is an interface representing a type of feature e.g. changepoint, seasonality, or time

type FeatureType

type FeatureType string
const (
	FeatureTypeChangepoint FeatureType = "changepoint"
	FeatureTypeSeasonality FeatureType = "seasonality"
	FeatureTypeTime        FeatureType = "time"
	FeatureTypeEvent       FeatureType = "event"
)

type FourierComp

type FourierComp string

type Seasonality

type Seasonality struct {
	Name        string      `json:"name"`
	FourierComp FourierComp `json:"fourier_component"`
	Order       int         `json:"order"`
}

Seasonality feature representing a single seasonality component. A seasonality component consists of a name, component (sin or cos), and order (fourier order).

func NewSeasonality

func NewSeasonality(name string, fcomp FourierComp, order int) *Seasonality

NewSeasonality creates a new seasonality feature instance givenn a name, sin/cos component, and Fourier order

func (Seasonality) Decode

func (s Seasonality) Decode() map[string]string

Decode converts the feature innto a map of label values

func (Seasonality) Get

func (s Seasonality) Get(label string) (string, bool)

Get returns the value of an arbitrary label and returns the value along with whether the label exists

func (Seasonality) String

func (s Seasonality) String() string

String returns the string representation of the seasonality feature

func (Seasonality) Type

func (s Seasonality) Type() FeatureType

Type returns the type of this feature

func (*Seasonality) UnmarshalJSON

func (s *Seasonality) UnmarshalJSON(data []byte) error

UnmarshalJSON is the custom unmarshalling to convert a map[string]string to a seasonality feature

type Set added in v0.1.0

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

Set represents a mapping to each feature data keyed by the string representation of the feature.

func NewSet added in v0.2.0

func NewSet() *Set

NewSet initializes a new feature set

func (*Set) Del added in v0.2.0

func (s *Set) Del(f Feature) *Set

Del will attempt to remove an existing feature from the set. If there are no more features stored, the data length will be reset to 0 and will be initialized on the next Set call.

func (*Set) Get added in v0.2.0

func (s *Set) Get(f Feature) ([]float64, bool)

Get retrieves the values of a particular feature. This returns an extra bool to indicate if the feature exists in the set or not.

func (*Set) Labels added in v0.1.0

func (s *Set) Labels() []Feature

Labels returns the sorted slice of all tracked features in the FeatureSet

func (*Set) Len added in v0.2.0

func (s *Set) Len() int

Len returns the number of labels stored in the feature set

func (*Set) Matrix added in v0.1.0

func (s *Set) Matrix(intercept bool) *mat.Dense

Matrix returns a metric representation of the FeatureSet to be used with matrix methods The matrix has m rows representing the number of observations and n columns representing the number of features.

func (*Set) RemoveZeroOnlyFeatures added in v0.2.11

func (s *Set) RemoveZeroOnlyFeatures()

RemoveZeroOnlyFeatures scans through all features and removes any features with only zero values. This is to prevent fitting issues.

func (*Set) Set added in v0.2.0

func (s *Set) Set(f Feature, data []float64) *Set

Set will store the input feature with the input slice of values. This will zero pad out the data if it is less than the current data length of the set. If it is larger, all other features will be zero padded.

func (*Set) Update added in v0.2.0

func (s *Set) Update(other *Set) *Set

Update will merge an input set with the existing set. If the data length of the input is less than the existing, the input is zero padded out to match. If the data length of the input is greater than the existing, the existing is zero padded out to match. Any overlapping keys will result in a replacement.

type Time

type Time struct {
	Name string `json:"name"`
}

Time feature representing a time based feature e.g. hour of day.

func NewTime

func NewTime(name string) *Time

NewTime creataes aa new time instance given a name

func (Time) Decode

func (t Time) Decode() map[string]string

Decode converts the feature into a map of label values

func (Time) Get

func (t Time) Get(label string) (string, bool)

Get returns the value of an arbitrary label annd returns the value along with whether the label exists

func (Time) String

func (t Time) String() string

String returns the string representationf of the time feature

func (Time) Type

func (t Time) Type() FeatureType

Type returns the type of this feature

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON is the custom unmarshalling to convert a map[string]string to a time feature

Jump to

Keyboard shortcuts

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