math

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultContainedVariance = 0.99
View Source
const (
	FftFreqMetricName = "freq"
)

Variables

This section is empty.

Functions

func BatchConvexHull

func BatchConvexHull(sortOnly bool) bitflow.BatchProcessingStep

func ComputeAndProjectPCA

func ComputeAndProjectPCA(containedVariance float64) bitflow.BatchProcessingStep

func FeatureWindowAverage

func FeatureWindowAverage(stats *FeatureWindowStats) bitflow.Value

func FeatureWindowSlope

func FeatureWindowSlope(stats *FeatureWindowStats) bitflow.Value

func LoadBatchPCAModel

func LoadBatchPCAModel(filename string, containedVariance float64) (bitflow.BatchProcessingStep, error)

func LoadStreamingPCAModel

func LoadStreamingPCAModel(filename string, containedVariance float64) (bitflow.SampleProcessor, error)

func RegisterAggregateAvg

func RegisterAggregateAvg(b reg.ProcessorRegistry)

func RegisterAggregateSlope

func RegisterAggregateSlope(b reg.ProcessorRegistry)

func RegisterConvexHull

func RegisterConvexHull(b reg.ProcessorRegistry)

func RegisterConvexHullSort

func RegisterConvexHullSort(b reg.ProcessorRegistry)

func RegisterFFT

func RegisterFFT(b reg.ProcessorRegistry)

func RegisterLinearRegression

func RegisterLinearRegression(b reg.ProcessorRegistry)

func RegisterLinearRegressionBruteForce

func RegisterLinearRegressionBruteForce(b reg.ProcessorRegistry)

func RegisterMinMaxScaling

func RegisterMinMaxScaling(b reg.ProcessorRegistry)

func RegisterPCA

func RegisterPCA(b reg.ProcessorRegistry)

func RegisterPCALoad

func RegisterPCALoad(b reg.ProcessorRegistry)

func RegisterPCALoadStream

func RegisterPCALoadStream(b reg.ProcessorRegistry)

func RegisterPCAStore

func RegisterPCAStore(b reg.ProcessorRegistry)

func RegisterRMS

func RegisterRMS(b reg.ProcessorRegistry)

func RegisterSphere

func RegisterSphere(b reg.ProcessorRegistry)

func RegisterStandardizationScaling

func RegisterStandardizationScaling(b reg.ProcessorRegistry)

func SamplesToMatrix

func SamplesToMatrix(samples []*bitflow.Sample) mat.Matrix

func StorePCAModel

func StorePCAModel(filename string) bitflow.BatchProcessingStep

Types

type AngleBasedSort

type AngleBasedSort struct {
	Reference Point
	Points    []Point
}

func (AngleBasedSort) Len

func (s AngleBasedSort) Len() int

func (AngleBasedSort) Less

func (s AngleBasedSort) Less(i, j int) bool

func (AngleBasedSort) Swap

func (s AngleBasedSort) Swap(i, j int)

type BatchFft

type BatchFft struct {
	// By default, the upper half of the FFT results is cut off, because the FFT results are symmetric.
	// Set LeaveSymmetricPart to true to include preserve all result values.
	LeaveSymmetricPart bool

	// By default, the FFT results are normalized. Set SkipNormalization to true to avoid this.
	// Normalization helps comparing the results of FFTs with different numbers of input values.
	// Normalization is done by dividing every FFT result value by the total number of input values to the FFT.
	// If FillZeros=true, this is the closest power of two above the number of actual input samples. If FillZeros=false, this is the closest power of two beneath that.
	SkipNormalization bool

	// If the number of input samples is not exactly a power of two, the input batch must either be cut short or filled up with zeros.
	// The default is to cut the input to a power of two. set FillZeros to true, to instead fill the input with zeros to reach the next higher power of two.
	FillZeros bool

	// If FrequencyMetricIndex >= 0, the frequency for every FFT result value will be added as a new metric at the given index.
	// If the index is higher than the total number of input metrics, it will be appended as the last metric.
	// The name of that new metric will be FftFreqMetricName ("freq").
	FrequencyMetricIndex int

	// If SamplingFrequency > 0, it will be used as the total sampling frequency when computing the frequency metric.
	// If this is <= 0, the sampling frequency will be computed automatically from the timestamps of the first and last input sample, and the total number of samples.
	SamplingFrequency float64

	// FatalErrors can be set to true to return errors that occur when processing a batch.
	// Otherwise, the error will be printed as a warning and an empty result batch will be produced.
	FatalErrors bool
}

func (*BatchFft) OutputSampleSize

func (s *BatchFft) OutputSampleSize(sampleSize int) int

func (*BatchFft) ProcessBatch

func (s *BatchFft) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*BatchFft) String

func (s *BatchFft) String() string

type BatchRms

type BatchRms struct {
}

func (*BatchRms) ProcessBatch

func (r *BatchRms) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*BatchRms) String

func (r *BatchRms) String() string

type ConvexHull

type ConvexHull []Point

func ComputeConvexHull

func ComputeConvexHull(points []Point) ConvexHull

func (ConvexHull) ComputeLowestPoint

func (p ConvexHull) ComputeLowestPoint() (low Point)

type EvaluatedLinearRegression

type EvaluatedLinearRegression struct {
	LinearRegression
	MSE float64
}

type FeatureAggregator

type FeatureAggregator struct {
	bitflow.NoopProcessor
	WindowSize     int           // Applied if >0
	WindowDuration time.Duration // Applied if >0
	UseCurrentTime bool          // If true, use time.Now() as reference for WindowTime. Otherwise, use the timestamp of the latest Sample.
	// contains filtered or unexported fields
}

func (*FeatureAggregator) Add

func (*FeatureAggregator) AddAvg

func (agg *FeatureAggregator) AddAvg(suffix string) *FeatureAggregator

func (*FeatureAggregator) AddSlope

func (agg *FeatureAggregator) AddSlope(suffix string) *FeatureAggregator

func (*FeatureAggregator) MergeProcessor

func (agg *FeatureAggregator) MergeProcessor(other bitflow.SampleProcessor) bool

func (*FeatureAggregator) OutputSampleSize

func (agg *FeatureAggregator) OutputSampleSize(sampleSize int) int

func (*FeatureAggregator) Sample

func (agg *FeatureAggregator) Sample(sample *bitflow.Sample, header *bitflow.Header) error

func (*FeatureAggregator) String

func (agg *FeatureAggregator) String() string

type FeatureAggregatorOperation

type FeatureAggregatorOperation func(stats *FeatureWindowStats) bitflow.Value

type FeatureWindowStats

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

func (*FeatureWindowStats) Flush

func (stats *FeatureWindowStats) Flush(num int)

func (*FeatureWindowStats) Push

func (stats *FeatureWindowStats) Push(val bitflow.Value, timestamp time.Time)

type LinearRegression

type LinearRegression struct {
	SubHeader
	RegressionClassVar int
	Model              *linear_models.LinearRegression
	TrainData          *base.DenseInstances
}

func NewLinearRegression

func NewLinearRegression(header *bitflow.Header, fieldNames []string) (LinearRegression, error)

func (*LinearRegression) Fit

func (reg *LinearRegression) Fit(samples []*bitflow.Sample) error

func (*LinearRegression) FormulaString

func (reg *LinearRegression) FormulaString() string

func (*LinearRegression) IsValid

func (reg *LinearRegression) IsValid() bool

func (*LinearRegression) MeanSquaredError

func (reg *LinearRegression) MeanSquaredError(data base.FixedDataGrid) (float64, error)

func (*LinearRegression) Predict

func (reg *LinearRegression) Predict(data base.FixedDataGrid) ([]float64, error)

type LinearRegressionBatchProcessor

type LinearRegressionBatchProcessor struct {
}

func (*LinearRegressionBatchProcessor) ProcessBatch

func (reg *LinearRegressionBatchProcessor) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*LinearRegressionBatchProcessor) String

func (reg *LinearRegressionBatchProcessor) String() string

type LinearRegressionBruteForce

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

func (*LinearRegressionBruteForce) ProcessBatch

func (brute *LinearRegressionBruteForce) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*LinearRegressionBruteForce) String

func (brute *LinearRegressionBruteForce) String() string

type MinMaxScaling

type MinMaxScaling struct {
	Min float64
	Max float64
}

func (*MinMaxScaling) ProcessBatch

func (s *MinMaxScaling) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*MinMaxScaling) String

func (s *MinMaxScaling) String() string

type PCAModel

type PCAModel struct {
	Vectors            *mat.Dense
	RawVariances       []float64
	ContainedVariances []float64
}

func (*PCAModel) ComponentsContainingVariance

func (model *PCAModel) ComponentsContainingVariance(variance float64) (count int, sum float64)

func (*PCAModel) ComputeAndReport

func (model *PCAModel) ComputeAndReport(samples []*bitflow.Sample) error

func (*PCAModel) ComputeModel

func (model *PCAModel) ComputeModel(samples []*bitflow.Sample) error

func (*PCAModel) Load

func (model *PCAModel) Load(filename string) (err error)

func (*PCAModel) Project

func (model *PCAModel) Project(numComponents int) *PCAProjection

func (*PCAModel) ProjectHeader

func (model *PCAModel) ProjectHeader(variance float64, header *bitflow.Header) (*PCAProjection, *bitflow.Header, error)

func (*PCAModel) Report

func (model *PCAModel) Report(reportVariance float64) string

func (*PCAModel) String

func (model *PCAModel) String() string

func (*PCAModel) WriteModel

func (model *PCAModel) WriteModel(writer io.Writer) error

type PCAProjection

type PCAProjection struct {
	Model      *PCAModel
	Vectors    mat.Matrix
	Components int
}

func (*PCAProjection) Matrix

func (model *PCAProjection) Matrix(matrix mat.Matrix) *mat.Dense

func (*PCAProjection) Sample

func (model *PCAProjection) Sample(sample *bitflow.Sample) (result *bitflow.Sample)

func (*PCAProjection) Vector

func (model *PCAProjection) Vector(vec []float64) []float64

type Point

type Point struct {
	X, Y float64
}

func SortByAngle

func SortByAngle(points []Point) []Point

func (Point) Distance

func (p Point) Distance(other Point) float64

type SortedRegressions

type SortedRegressions []EvaluatedLinearRegression

func (SortedRegressions) Len

func (slice SortedRegressions) Len() int

func (SortedRegressions) Less

func (slice SortedRegressions) Less(i, j int) bool

func (SortedRegressions) Swap

func (slice SortedRegressions) Swap(i, j int)

type SpherePoints

type SpherePoints struct {
	bitflow.NoopProcessor
	RandomSeed int64
	NumPoints  int

	RadiusMetric int // If >= 0, use to get radius. Otherwise, use Radius field.
	Radius       float64
	// contains filtered or unexported fields
}

func (*SpherePoints) Sample

func (p *SpherePoints) Sample(sample *bitflow.Sample, header *bitflow.Header) error

func (*SpherePoints) Start

func (p *SpherePoints) Start(wg *sync.WaitGroup) golib.StopChan

type StandardizationScaling

type StandardizationScaling struct {
}

func (*StandardizationScaling) ProcessBatch

func (s *StandardizationScaling) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*StandardizationScaling) String

func (s *StandardizationScaling) String() string

type SubHeader

type SubHeader struct {
	Header *bitflow.Header
	Vars   []int
}

func (SubHeader) BuildFilledInstances

func (header SubHeader) BuildFilledInstances(samples []*bitflow.Sample, classAttribute int) (*base.DenseInstances, error)

func (SubHeader) BuildInstances

func (header SubHeader) BuildInstances(classAttribute int) (*base.DenseInstances, error)

func (SubHeader) FillInstances

func (header SubHeader) FillInstances(samples []*bitflow.Sample, instances *base.DenseInstances)

Jump to

Keyboard shortcuts

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