encoders

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGram = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DictionaryModel

type DictionaryModel struct {
	Dimensions int
	Dictionary []string
	Quality    float64
}

func NewDictionaryModel

func NewDictionaryModel() *DictionaryModel

func (*DictionaryModel) CalculateFloats

func (m *DictionaryModel) CalculateFloats([]float64) []float64

func (*DictionaryModel) CalculateString

func (m *DictionaryModel) CalculateString(s string) []float64

func (*DictionaryModel) Fit

func (m *DictionaryModel) Fit(set *Input)

func (*DictionaryModel) GetDimensions

func (m *DictionaryModel) GetDimensions() int

func (*DictionaryModel) GetQuality

func (m *DictionaryModel) GetQuality() float64

func (*DictionaryModel) Name

func (m *DictionaryModel) Name() string

type Dimension

type Dimension struct {
	Inputs    int
	InputType InputType
	Type      EncoderType
	Model     EncoderModel
}

type Encoder

type Encoder struct {
	// Name of the encoder
	Name string
	// Dimensions hold the EncoderModel for the dimensions
	Models map[string]*Dimension
	// Config of the Encoder
	Config *EncoderConfig
	// Scanned determines if scan was executed
	Scanned bool
}

func NewEncoder

func NewEncoder(name string) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(name string, input Unified) []float64

func (*Encoder) Explain

func (e *Encoder) Explain()

reporting of what the encoder did

func (*Encoder) Scan

func (e *Encoder) Scan(name string, input *Input, encoder EncoderType)

func (*Encoder) Transform

func (e *Encoder) Transform(name string, set *Input)

type EncoderConfig

type EncoderConfig struct {
	DelimiterToken    string
	DimToSamplesRatio float64
	// Decision heuristics
	FloatReducerThreshold     int
	TopicModelMinDelimiters   int
	NGramsMaxTokens           int
	DictionaryMaxEntries      int
	DictionaryMaxDelimiters   int
	SplitDictionaryMaxEntries int
	// Application settings
	FloatReducerSpearman   float64
	FloatReducerSkewness   float64
	FloatReducerZeroValues bool
	NGramMaxGrams          int
	NGramMaxCapacity       int
	NGramCropRatio         float64
	DefaultStringEncoder   EncoderType
}

func DefaultConfig

func DefaultConfig() *EncoderConfig

type EncoderModel

type EncoderModel interface {
	Fit(*Input)
	CalculateString(string) []float64
	CalculateFloats([]float64) []float64
	GetDimensions() int
	GetQuality() float64
	Name() string
}

type EncoderType

type EncoderType int
const (
	// Automatic means that the encoder decides based on heuristics what to do
	Automatic EncoderType = iota
	// StringDictionary uses exact matches on strings as dictionary approach
	StringDictionary
	// StringSplittedDictionary
	StringSplitDictionary
	// StringTopics uses topic modelling on strings
	StringTopics
	// StringNGrams uses N-Gram modelling on strings
	StringNGrams
	// FloatExact just uses the float value it gets from input
	FloatExact
	// FloatReducer reduces a large number of floats to a smaller input space
	FloatReducer
)

func (EncoderType) String

func (e EncoderType) String() string

type FloatExactModel

type FloatExactModel struct {
	Dimensions int
	Quality    float64
}

func NewFloatExactModel

func NewFloatExactModel() *FloatExactModel

func (*FloatExactModel) CalculateFloats

func (m *FloatExactModel) CalculateFloats(value []float64) []float64

func (*FloatExactModel) CalculateString

func (m *FloatExactModel) CalculateString(s string) []float64

func (*FloatExactModel) Fit

func (m *FloatExactModel) Fit(set *Input)

func (*FloatExactModel) GetDimensions

func (m *FloatExactModel) GetDimensions() int

func (*FloatExactModel) GetQuality

func (m *FloatExactModel) GetQuality() float64

func (*FloatExactModel) Name

func (m *FloatExactModel) Name() string

type FloatReducerModel

type FloatReducerModel struct {
	Model      map[int]bool
	Dimensions int
	Quality    float64
	Config     *EncoderConfig
}

func NewFloatReducerModel

func NewFloatReducerModel(config *EncoderConfig) *FloatReducerModel

func (*FloatReducerModel) CalculateFloats

func (m *FloatReducerModel) CalculateFloats(value []float64) []float64

func (*FloatReducerModel) CalculateString

func (m *FloatReducerModel) CalculateString(s string) []float64

func (*FloatReducerModel) Fit

func (m *FloatReducerModel) Fit(set *Input)

func (*FloatReducerModel) GetDimensions

func (m *FloatReducerModel) GetDimensions() int

func (*FloatReducerModel) GetQuality

func (m *FloatReducerModel) GetQuality() float64

func (*FloatReducerModel) Name

func (m *FloatReducerModel) Name() string

type Input

type Input struct {
	Name   string
	Values []*Unified
	Type   InputType
}

func NewInput

func NewInput(name string, t InputType) *Input

func (*Input) Add

func (i *Input) Add(unified *Unified)

func (*Input) AddFloats

func (i *Input) AddFloats(sample []float64)

func (*Input) AddString

func (i *Input) AddString(sample string)

type InputType

type InputType int
const (
	String InputType = iota
	Floats
)

func (InputType) String

func (e InputType) String() string

type Inputs

type Inputs struct {
	Inputs []*Input
}

func NewInputs

func NewInputs() *Inputs

func (*Inputs) Add

func (i *Inputs) Add(input *Input)

type NGramModel

type NGramModel struct {
	Dimensions int
	// Grams to index in vector
	GramsLookup map[string]int
	// Grams to number of appearances
	Grams       map[string]int
	Samples     int
	MaxGrams    int
	MaxCapacity int
	CropRatio   float64
	Quality     float64
}

func NewNGramModel

func NewNGramModel(config *EncoderConfig) *NGramModel

func (*NGramModel) CalculateFloats

func (m *NGramModel) CalculateFloats([]float64) []float64

func (*NGramModel) CalculateString

func (m *NGramModel) CalculateString(s string) []float64

func (*NGramModel) Fit

func (m *NGramModel) Fit(set *Input)

func (*NGramModel) GetDimensions

func (m *NGramModel) GetDimensions() int

func (*NGramModel) GetQuality

func (m *NGramModel) GetQuality() float64

func (*NGramModel) Name

func (m *NGramModel) Name() string

type SplitDictionaryModel

type SplitDictionaryModel struct {
	Dimensions int
	Delimiter  string
	Dictionary []string
	Quality    float64
}

func NewSplitDictionaryModel

func NewSplitDictionaryModel(config *EncoderConfig) *SplitDictionaryModel

func (*SplitDictionaryModel) CalculateFloats

func (m *SplitDictionaryModel) CalculateFloats([]float64) []float64

func (*SplitDictionaryModel) CalculateString

func (m *SplitDictionaryModel) CalculateString(s string) []float64

func (*SplitDictionaryModel) Fit

func (m *SplitDictionaryModel) Fit(set *Input)

func (*SplitDictionaryModel) GetDimensions

func (m *SplitDictionaryModel) GetDimensions() int

func (*SplitDictionaryModel) GetQuality

func (m *SplitDictionaryModel) GetQuality() float64

func (*SplitDictionaryModel) Name

func (m *SplitDictionaryModel) Name() string

type Unified

type Unified struct {
	String string
	Float  []float64
	Type   InputType
	Label  string
	Target float64
}

Jump to

Keyboard shortcuts

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