examples

package
v0.0.0-...-2c1810d Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Examples

This directory contains a few examples of how to use Cofire.

examples.go contains examples of how to start 4 component types:

  1. The learner consumes ratings from an input topic and applies SGD to learn the latent features of users and products (ie, factorizes the ratings matrix). It also periodically prints to stdout the RMSE of its predictions.
  2. The producer simply takes a list of ratings and emits them into the learner's input topic.
  3. The refeeder reemits already learnt ratings into the learner's input topic after a predefined delay and for a number of iterations.
  4. The validator takes a set of ratings (eg, a test set) and calculates the RMSE using a view on the learnt model (technically, a view of the learner's group table).

Besides these generic starters, there are two concrete examples of recommendation:

  • movielens: the classic Movie Lens example, where users are watchers, products are movies and scores are the number of stars each user gives to each movie.
  • pixelreco: a funny example that maps the x axis of an image as the users, the y axis as the products and the gray level of the pixel as the score. Any image can be used as input.

Both examples contain the Kafka-based implementation as well as a simple local runner.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateView

func CreateView(brokers []string, group goka.Group) (*goka.View, func(ctx context.Context) func() error)

CreateView creates a view of the cofire table and a function to start it if no error occurred.

func StartLearner

func StartLearner(ctx context.Context, brokers []string, group goka.Group, params cofire.Parameters) func() error

StartLearner starts a Cofire processor that factorizes a rating matrix with SGD. A simple validator prints to stdout the RMSE every second.

func StartProducer

func StartProducer(ctx context.Context, brokers []string, group goka.Group, ratings []cofire.Rating) func() error

StartProducer starts a producer that emits a slice of ratings into the input of the learner, one rating every 5 milliseconds.

func StartRefeeder

func StartRefeeder(ctx context.Context, brokers []string, group goka.Group, delay time.Duration) func() error

StartRefeeder starts a Cofire refeeder processor, ie, a process that refeeds the stream into the learner's input after a delay. This can be used to train for multiple iterations.

func StartValidator

func StartValidator(ctx context.Context, view *goka.View, ratings []cofire.Rating, params cofire.Parameters) func() error

StartValidator starts a go routine that loops over all given ratings and calculates the RSME calculating the ratings with the error predicted from the model.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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