Documentation
¶
Overview ¶
Package vw implements golang bindings for Vowpal Wabbit Online Learning library. API is designed to closely resemble the C API of Vowpal Wabbit with minor changes done to make it more convinient to be used from go. Library is not thread safe and additional locking is required if libary is being called from multiple goroutines.
Index ¶
- type Error
- type Example
- func (ex *Example) Finish()
- func (ex *Example) GetAction(i int) int
- func (ex *Example) GetActionScore(i int) float32
- func (ex *Example) GetActionScoreLength() int
- func (ex *Example) GetActionScores() []float32
- func (ex *Example) GetActions() []int
- func (ex *Example) GetConfidence(i int) float32
- func (ex *Example) GetCostSensitivePrediction() float32
- func (ex *Example) GetFeatureNumber() int
- func (ex *Example) GetImportance() float32
- func (ex *Example) GetInitial() float32
- func (ex *Example) GetLabel() float32
- func (ex *Example) GetPrediction() float32
- func (ex *Example) GetTag() string
- func (ex *Example) GetTagLength() int
- func (ex *Example) GetTopicPrediction(i int) float32
- type ExampleList
- type PerformanceStatistics
- type VW
- func (vw *VW) CopyModelData() []byte
- func (vw *VW) EndOfPass() error
- func (vw *VW) EndParser() error
- func (vw *VW) Finish()
- func (vw *VW) FinishPasses() error
- func (vw *VW) Learn(ex *Example) float32
- func (vw *VW) MultiLineLearn(exs []*Example) error
- func (vw *VW) MultiLinePredict(exs []*Example) error
- func (vw *VW) PerformanceStatistics() (PerformanceStatistics, error)
- func (vw *VW) Predict(ex *Example) float32
- func (vw *VW) PredictCostSensitive(ex *Example) float32
- func (vw *VW) ReadDecisionServiceJSON(json string) (ExampleList, error)
- func (vw *VW) ReadDecisionServiceJSONFromBytes(json []byte) (ExampleList, error)
- func (vw *VW) ReadExample(example string) (*Example, error)
- func (vw *VW) ReadJSON(json string) (ExampleList, error)
- func (vw *VW) SaveModel()
- func (vw *VW) StartParser() error
- func (vw *VW) SyncStats() error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error errors returned by vowpal wabbig functions
type Example ¶
type Example struct {
// contains filtered or unexported fields
}
Example a single Vowpal Wabbit example
func (*Example) GetActionScore ¶
GetActionScore returns action score for index
func (*Example) GetActionScoreLength ¶
GetActionScoreLength get action score length
func (*Example) GetActionScores ¶
GetActionScores returns all action scores as a slice
func (*Example) GetActions ¶
GetActions returns all actions as a slice
func (*Example) GetConfidence ¶
GetConfidence returns confidence
func (*Example) GetCostSensitivePrediction ¶
GetCostSensitivePrediction returns initial
func (*Example) GetFeatureNumber ¶
GetFeatureNumber returns number of features
func (*Example) GetImportance ¶
GetImportance returns importance
func (*Example) GetPrediction ¶
GetPrediction returns prediction
func (*Example) GetTagLength ¶
GetTagLength returns tag length
func (*Example) GetTopicPrediction ¶
GetTopicPrediction returns topic prediction for index
type PerformanceStatistics ¶
type PerformanceStatistics struct {
// Index of current pass
CurrentPass uint64
// The total number of features
NumberOfFeatures uint64
// Total number of examples
NumberOfExamples uint64
// The weighted sum of examples.
WeightedExampleSum float64
// The weighted sum of labels.
WeightedLabelSum float64
// The average loss since instance creation.
AverageLoss float64
// The best constant since instance creation.
BestConstant float64
// The best constant loss since instance creation.
BestConstantLoss float64
}
PerformanceStatistics contains model performance stats
type VW ¶
type VW struct {
// contains filtered or unexported fields
}
VW struct for a single Vowpal Wabbit model
Example ¶
vw, _ := New("-q st --noconstant --quiet")
defer vw.Finish()
// Learn an example
ex, _ := vw.ReadExample("1 |s p^the_man w^the w^man |t p^un_homme w^un w^homme")
vw.Learn(ex)
// Predict with features
ex, _ = vw.ReadExample("|s p^the_man w^the w^man |t p^un_homme w^un w^homme")
res := vw.Predict(ex)
fmt.Printf("Prediction: %f", res)
Output: Prediction: 0.855723
func NewWithModelData ¶
NewWithModelData returns new Vowpal Wabbit instance with model data
func NewWithSeed ¶
NewWithSeed returns a new Vowpal Wabbit instance seeded with another model
func (*VW) CopyModelData ¶
CopyModelData returns model data as a byte slice
func (*VW) MultiLineLearn ¶
MultiLineLearn learns from a list of example and returns the score
func (*VW) MultiLinePredict ¶
MultiLinePredict predic using a list of examples
func (*VW) PerformanceStatistics ¶
func (vw *VW) PerformanceStatistics() (PerformanceStatistics, error)
PerformanceStatistics writes current performance stats
func (*VW) PredictCostSensitive ¶
PredictCostSensitive returns a cost sensitive prediction using the example
func (*VW) ReadDecisionServiceJSON ¶
func (vw *VW) ReadDecisionServiceJSON(json string) (ExampleList, error)
ReadDecisionServiceJSON reads examples from Decision Service JSON format
func (*VW) ReadDecisionServiceJSONFromBytes ¶
func (vw *VW) ReadDecisionServiceJSONFromBytes(json []byte) (ExampleList, error)
ReadDecisionServiceJSONFromBytes like ReadDecisionServiceJSON but takes in a byte slice (need to be null terminated)
func (*VW) ReadExample ¶
ReadExample parses a single text based example
func (*VW) ReadJSON ¶
func (vw *VW) ReadJSON(json string) (ExampleList, error)
ReadJSON reads examples from format