core

package
Version: v0.0.0-...-d942b2f Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2014 License: MIT Imports: 10 Imported by: 0

README

Define base structure such as Feature, Sample, DataSet

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FeatureTypeEnum = struct {
	DISCRETE_FEATURE   FeatureType
	CONTINUOUS_FEATURE FeatureType
}{0, 1}

Functions

func FindCategory

func FindCategory(split []float64, value float64) int

func Gini

func Gini(left_dis, right_dis *ArrayVector) float64

func InformationValue

func InformationValue(dataset *DataSet) map[int64]float64

func RemoveLowFreqFeatures

func RemoveLowFreqFeatures(dataset *DataSet, threshold float64)

Types

type ArrayVector

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

func NewArrayVector

func NewArrayVector() *ArrayVector

func (*ArrayVector) AddValue

func (v *ArrayVector) AddValue(key int, value float64)

func (*ArrayVector) AddVector

func (v *ArrayVector) AddVector(v2 *ArrayVector, alpha float64)

func (*ArrayVector) Copy

func (v *ArrayVector) Copy() *ArrayVector

func (*ArrayVector) Dot

func (v *ArrayVector) Dot(v2 *ArrayVector) float64

func (*ArrayVector) Expand

func (v *ArrayVector) Expand(size int)

func (*ArrayVector) FromString

func (v *ArrayVector) FromString(buf string)

func (*ArrayVector) GetValue

func (v *ArrayVector) GetValue(key int) float64

func (*ArrayVector) KeyWithMaxValue

func (v *ArrayVector) KeyWithMaxValue() (int, float64)

func (*ArrayVector) NormL2

func (v *ArrayVector) NormL2() float64

func (*ArrayVector) Scale

func (v *ArrayVector) Scale(s float64)

func (*ArrayVector) SetValue

func (v *ArrayVector) SetValue(key int, value float64)

func (*ArrayVector) SoftMaxNorm

func (v *ArrayVector) SoftMaxNorm() *ArrayVector

func (*ArrayVector) Sum

func (v *ArrayVector) Sum() float64

func (*ArrayVector) ToString

func (v *ArrayVector) ToString() []byte

type CombinedFeature

type CombinedFeature []string

type DataSet

type DataSet struct {
	Samples []*Sample
	// contains filtered or unexported fields
}

DataSet

func LinearDataSet

func LinearDataSet(n int) *DataSet

func NewDataSet

func NewDataSet() *DataSet

func XORDataSet

func XORDataSet(n int) *DataSet

func (*DataSet) AddSample

func (d *DataSet) AddSample(sample *Sample)

func (*DataSet) Load

func (d *DataSet) Load(path string, global_bias_feature_id int64) error

func (*DataSet) Split

func (d *DataSet) Split(f func(int) bool) *DataSet

type ElemOperation

type ElemOperation func(float64) float64

type Feature

type Feature struct {
	Id    int64
	Value float64
}

type FeatureGoalDistribution

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

func NewFeatureGoalDistribution

func NewFeatureGoalDistribution() *FeatureGoalDistribution

func (*FeatureGoalDistribution) AddWeightGoal

func (f *FeatureGoalDistribution) AddWeightGoal(weight float64, goal float64)

func (*FeatureGoalDistribution) BestSplitByVariance

func (f *FeatureGoalDistribution) BestSplitByVariance(sum_left, sum_left2, count_left, sum_right, sum_right2, count_right float64) (float64, float64)

func (*FeatureGoalDistribution) Len

func (f *FeatureGoalDistribution) Len() int

func (*FeatureGoalDistribution) Less

func (f *FeatureGoalDistribution) Less(i, j int) bool

func (*FeatureGoalDistribution) Swap

func (f *FeatureGoalDistribution) Swap(i, j int)

func (*FeatureGoalDistribution) Variance

func (f *FeatureGoalDistribution) Variance(sum_left, sum_left2, count_left, sum_right, sum_right2, count_right float64) float64

type FeatureLabelDistribution

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

func NewFeatureLabelDistribution

func NewFeatureLabelDistribution() *FeatureLabelDistribution

func (*FeatureLabelDistribution) AddWeightLabel

func (f *FeatureLabelDistribution) AddWeightLabel(weight float64, label int)

func (*FeatureLabelDistribution) BestSplitByGini

func (self *FeatureLabelDistribution) BestSplitByGini(total_dis *ArrayVector) (float64, float64)

func (*FeatureLabelDistribution) InformationValue

func (f *FeatureLabelDistribution) InformationValue(global_total, global_positive int) float64

func (*FeatureLabelDistribution) LabelDistribution

func (f *FeatureLabelDistribution) LabelDistribution() *ArrayVector

func (*FeatureLabelDistribution) Len

func (f *FeatureLabelDistribution) Len() int

func (*FeatureLabelDistribution) Less

func (f *FeatureLabelDistribution) Less(i, j int) bool

func (*FeatureLabelDistribution) PositiveCount

func (f *FeatureLabelDistribution) PositiveCount() int

func (*FeatureLabelDistribution) Swap

func (f *FeatureLabelDistribution) Swap(i, j int)

type FeatureSplit

type FeatureSplit []float64

type FeatureType

type FeatureType int

func GetFeatureType

func GetFeatureType(key string) FeatureType

type IntEncoder

type IntEncoder struct {
	Mapping        map[int]int
	InverseMapping map[int]int
}

func NewIntEncoder

func NewIntEncoder() *IntEncoder

func (*IntEncoder) Decoded

func (e *IntEncoder) Decoded(encoded int) (int, error)

func (*IntEncoder) Encoded

func (e *IntEncoder) Encoded(original int) int

type LabelEncoder

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

func NewLabelEncoder

func NewLabelEncoder() *LabelEncoder

func (*LabelEncoder) InverseTransformDataset

func (e *LabelEncoder) InverseTransformDataset(dataset *DataSet) *DataSet

func (*LabelEncoder) InverseTransformSample

func (e *LabelEncoder) InverseTransformSample(s *Sample) *Sample

func (*LabelEncoder) TransformDataset

func (e *LabelEncoder) TransformDataset(dataset *DataSet) *DataSet

func (*LabelEncoder) TransformSample

func (e *LabelEncoder) TransformSample(s *Sample) *Sample

type MapBasedSample

type MapBasedSample struct {
	Label      int
	Prediction float64
	Features   map[int64]float64
}

MapBasedSample

func (*MapBasedSample) LabelDoubleValue

func (s *MapBasedSample) LabelDoubleValue() float64

type Matrix

type Matrix struct {
	Data map[int64]*Vector
}

func NewMatrix

func NewMatrix() *Matrix

func (*Matrix) AddValue

func (m *Matrix) AddValue(k1, k2 int64, v float64)

func (*Matrix) ElemWiseAddMatrix

func (m *Matrix) ElemWiseAddMatrix(n *Matrix) *Matrix

func (*Matrix) GetRow

func (m *Matrix) GetRow(k1 int64) *Vector

func (*Matrix) GetValue

func (m *Matrix) GetValue(k1, k2 int64) float64

func (*Matrix) MultiplyVector

func (m *Matrix) MultiplyVector(v *Vector) *Vector

func (*Matrix) Scale

func (m *Matrix) Scale(scale float64) *Matrix

func (*Matrix) SetValue

func (m *Matrix) SetValue(k1, k2 int64, v float64)

func (*Matrix) Trans

func (m *Matrix) Trans() *Matrix

type RawDataSet

type RawDataSet struct {
	Samples     []*RawSample
	FeatureKeys map[string]bool
}

RawDataSet

func NewRawDataSet

func NewRawDataSet() *RawDataSet

func (*RawDataSet) AddSample

func (d *RawDataSet) AddSample(sample *RawSample)

func (*RawDataSet) Load

func (d *RawDataSet) Load(path string) error

func (*RawDataSet) ToDataSet

func (d *RawDataSet) ToDataSet(splits map[string][]float64, combinations []CombinedFeature) *DataSet

type RawSample

type RawSample struct {
	Label      int
	Prediction float64
	Features   map[string]string
}

RawSample

func NewRawSample

func NewRawSample() *RawSample

func (*RawSample) GetFeatureValue

func (s *RawSample) GetFeatureValue(key string) string

type RealDataSet

type RealDataSet struct {
	Samples []*RealSample
}

Real valued DataSet

func NewRealDataSet

func NewRealDataSet() *RealDataSet

func SinusoidalDataSet

func SinusoidalDataSet(n int) *RealDataSet

func (*RealDataSet) AddSample

func (d *RealDataSet) AddSample(sample *RealSample)

func (*RealDataSet) Load

func (d *RealDataSet) Load(path string, global_bias_feature_id int64) error

type RealSample

type RealSample struct {
	Features   []Feature
	Prediction float64
	Value      float64
}

RealSample Real valued samples for regression

func NewRealSample

func NewRealSample() *RealSample

func (*RealSample) AddFeature

func (s *RealSample) AddFeature(f Feature)

func (*RealSample) GetFeatureVector

func (rs *RealSample) GetFeatureVector() *Vector

type Sample

type Sample struct {
	Features   []Feature
	Label      int
	Prediction float64
}

Sample - for classification Here, label should be int value started from 0

func NewSample

func NewSample() *Sample

func (*Sample) AddFeature

func (s *Sample) AddFeature(f Feature)

func (*Sample) Clone

func (s *Sample) Clone() *Sample

func (*Sample) GetFeatureVector

func (s *Sample) GetFeatureVector() *Vector

func (*Sample) LabelDoubleValue

func (s *Sample) LabelDoubleValue() float64

func (*Sample) ToMapBasedSample

func (s *Sample) ToMapBasedSample() *MapBasedSample

func (*Sample) ToString

func (s *Sample) ToString(includePrediction bool) []byte

type Vector

type Vector struct {
	Data map[int64]float64
}

func NewVector

func NewVector() *Vector

func (*Vector) AddValue

func (v *Vector) AddValue(key int64, value float64)

func (*Vector) AddVector

func (v *Vector) AddVector(v2 *Vector, alpha float64)

func (*Vector) ApplyElemWiseMultiplyAccumulation

func (v *Vector) ApplyElemWiseMultiplyAccumulation(u *Vector, s float64)

func (*Vector) ApplyOnElem

func (v *Vector) ApplyOnElem(fn ElemOperation) *Vector

func (*Vector) ApplyScale

func (v *Vector) ApplyScale(scale float64)

func (*Vector) Copy

func (v *Vector) Copy() *Vector

func (*Vector) Dot

func (v *Vector) Dot(v2 *Vector) float64

func (*Vector) DotFeatures

func (v *Vector) DotFeatures(fs []Feature) float64

func (*Vector) ElemWiseAddVector

func (v *Vector) ElemWiseAddVector(u *Vector) *Vector

func (*Vector) ElemWiseMultiply

func (v *Vector) ElemWiseMultiply(u *Vector) *Vector

func (*Vector) ElemWiseMultiplyAdd

func (v *Vector) ElemWiseMultiplyAdd(u *Vector, s float64) *Vector

func (*Vector) FromString

func (v *Vector) FromString(buf string)

func (*Vector) GetValue

func (v *Vector) GetValue(key int64) float64

func (*Vector) KeyWithMaxValue

func (v *Vector) KeyWithMaxValue() (int64, float64)

func (*Vector) MultiplyMatrix

func (v *Vector) MultiplyMatrix(m *Matrix) *Vector

func (*Vector) NormL2

func (v *Vector) NormL2() float64

func (*Vector) OuterProduct

func (v *Vector) OuterProduct(u *Vector) *Matrix

func (*Vector) RandomInit

func (v *Vector) RandomInit(key int64, c float64)

func (*Vector) Scale

func (v *Vector) Scale(scale float64) *Vector

func (*Vector) SetValue

func (v *Vector) SetValue(key int64, value float64)

func (*Vector) SoftMaxNorm

func (v *Vector) SoftMaxNorm() *Vector

func (*Vector) Sum

func (v *Vector) Sum() float64

func (*Vector) ToString

func (v *Vector) ToString() []byte

type WeightGoal

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

type WeightLabel

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

func (*WeightLabel) LabelDoubleValue

func (self *WeightLabel) LabelDoubleValue() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL