Documentation ¶
Overview ¶
Package cofire is a generated protocol buffer package.
It is generated from these files:
cofire.proto
It has these top-level messages:
Features Entry Rating Message Update
Index ¶
- Variables
- func NewLearner(group goka.Group, validator Validator, params Parameters) *goka.GroupGraph
- func NewRefeeder(cofireGroup goka.Group, delay time.Duration) *goka.GroupGraph
- type Entry
- type EntryCodec
- type ErrorValidator
- type Features
- func (*Features) Descriptor() ([]byte, []int)
- func (m *Features) GetBias() float64
- func (m *Features) GetV() []float64
- func (f *Features) Predict(o *Features, bias float64) float64
- func (*Features) ProtoMessage()
- func (f *Features) Randomize() *Features
- func (f *Features) Rank() int
- func (m *Features) Reset()
- func (m *Features) String() string
- type Learner
- type Message
- type Parameters
- type Rating
- type RatingCodec
- type SGD
- type Stage
- type Update
- type UpdateCodec
- type Validator
Constants ¶
This section is empty.
Variables ¶
var Stage_name = map[int32]string{
0: "ENTRY",
1: "PRODUCT",
2: "USER",
}
var Stage_value = map[string]int32{
"ENTRY": 0,
"PRODUCT": 1,
"USER": 2,
}
Functions ¶
func NewLearner ¶
func NewLearner(group goka.Group, validator Validator, params Parameters) *goka.GroupGraph
NewLearner returns the GroupGraph for a learner processor.
func NewRefeeder ¶
NewRefeeder returns the GroupGraph for a processor that refeeds the input of the learner after a specified delay.
Types ¶
type Entry ¶
type Entry struct { U *Features `protobuf:"bytes,1,opt,name=u" json:"u,omitempty"` P *Features `protobuf:"bytes,2,opt,name=p" json:"p,omitempty"` }
Entry are the factors (either U or P) for a user or product.
func (*Entry) Descriptor ¶
func (*Entry) ProtoMessage ¶
func (*Entry) ProtoMessage()
type EntryCodec ¶
type EntryCodec struct{}
func (*EntryCodec) Decode ¶
func (c *EntryCodec) Decode(b []byte) (interface{}, error)
func (*EntryCodec) Encode ¶
func (c *EntryCodec) Encode(v interface{}) ([]byte, error)
type ErrorValidator ¶
type ErrorValidator struct {
// contains filtered or unexported fields
}
ErrorValidator validates each prediction calculating the root mean square error.
func NewErrorValidator ¶
func NewErrorValidator() *ErrorValidator
NewErrorValidator create a new ErrorValidator.
func (*ErrorValidator) Count ¶
func (v *ErrorValidator) Count() int
Count returns the number of values validated.
func (*ErrorValidator) RMSE ¶
func (v *ErrorValidator) RMSE() float64
RMSE returns the current root mean square error.
func (*ErrorValidator) Reset ¶
func (v *ErrorValidator) Reset() float64
Reset resets the state of the ErrorValidator and returns the last value.
func (*ErrorValidator) Validate ¶
func (v *ErrorValidator) Validate(prediction, score float64)
Validate validates the prediction given a score.
type Features ¶
type Features struct { V []float64 `protobuf:"fixed64,1,rep,packed,name=v" json:"v,omitempty"` Bias float64 `protobuf:"fixed64,2,opt,name=bias" json:"bias,omitempty"` }
Features are the factors and a bias for a user or product.
func NewFeatures ¶
NewFeatures creates a feature vector with rank features.
func (*Features) Descriptor ¶
func (*Features) ProtoMessage ¶
func (*Features) ProtoMessage()
type Learner ¶
type Learner struct {
// contains filtered or unexported fields
}
Learner factorizes a user-prodcut rating matrix by learning latent features for users and products.
type Message ¶
type Message struct { Stage Stage `protobuf:"varint,1,opt,name=stage,enum=cofire.Stage" json:"stage,omitempty"` Rating *Rating `protobuf:"bytes,2,opt,name=rating" json:"rating,omitempty"` F *Features `protobuf:"bytes,3,opt,name=f" json:"f,omitempty"` Iters uint32 `protobuf:"varint,4,opt,name=iters" json:"iters,omitempty"` }
Message are internal messages of the Cofire Learner.
func (*Message) Descriptor ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
type Parameters ¶
type Parameters struct { // Rank is the number of latent factors (features). Rank int // Gamma is the learning step. Gamma float64 // Lambda is the regularization parameter. Lambda float64 // Iterations is the number of times the data will be used for training. Iterations int }
Parameters configure the SGD algorithm.
func DefaultParams ¶
func DefaultParams() Parameters
DefaultParams return the default parameters of SGD.
type Rating ¶
type Rating struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId" json:"user_id,omitempty"` ProductId string `protobuf:"bytes,2,opt,name=product_id,json=productId" json:"product_id,omitempty"` Score float64 `protobuf:"fixed64,3,opt,name=score" json:"score,omitempty"` }
Rating represents the score that a user gives to a product. Cofire Learner accepts Rating messages to factorize the rating matrix.
func (*Rating) Descriptor ¶
func (*Rating) GetProductId ¶
func (*Rating) ProtoMessage ¶
func (*Rating) ProtoMessage()
type RatingCodec ¶
type RatingCodec struct{}
func (*RatingCodec) Decode ¶
func (c *RatingCodec) Decode(b []byte) (interface{}, error)
func (*RatingCodec) Encode ¶
func (c *RatingCodec) Encode(v interface{}) ([]byte, error)
type SGD ¶
type SGD struct { // Gamma constant for learning speed Gamma float64 // Lambda constant for regularization Lambda float64 // contains filtered or unexported fields }
SGD is a helper to apply stochastic gradient descent.
func (*SGD) Add ¶
Add adds bias to the prediction error. If Add is called multiple times, the average bias is computed.
func (*SGD) Apply ¶
Apply applies the stochastic gradient descent on features f with o and a score. Apply also adds the score to the bias.
func (*SGD) ApplyError ¶
ApplyError applies the stochastic gradient descent on features f with o and error e.
type Stage ¶
type Stage int32
Stage are the internal stages of the cofire learner.
func (Stage) EnumDescriptor ¶
type Update ¶
type Update struct { U *Features `protobuf:"bytes,1,opt,name=u" json:"u,omitempty"` P *Features `protobuf:"bytes,2,opt,name=p" json:"p,omitempty"` }
Update messages overwrite the U or P features of in the user/product's entry.
func (*Update) Descriptor ¶
func (*Update) ProtoMessage ¶
func (*Update) ProtoMessage()
type UpdateCodec ¶
type UpdateCodec struct{}
func (*UpdateCodec) Decode ¶
func (c *UpdateCodec) Decode(b []byte) (interface{}, error)
func (*UpdateCodec) Encode ¶
func (c *UpdateCodec) Encode(v interface{}) ([]byte, error)