bayesianFilter

package
v0.0.0-...-ed64787 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2014 License: MIT Imports: 3 Imported by: 0

README

Bayesian Collaborative-Filtering in Go

Inspired by this link and uses Skelterjohn's go.matrix package.

Bayesian CF is a model based recommendation algorithm and utilizes a laplace smoother.

To use:

  • Install: go get github.com/timkaye11/goCF/bayesianFilter
  • Pass in a dense matrix with user and item indices:
import (
	"github.com/skelterjohn/go.matrix"
	. "github.com/timkaye11/goCF/bayesianFilter"
)

func main() {

	mat := MakeRatingMatrix([]float64{
		4, NA, 5, 5,
		4, 2, 1, NA,
		3, NA, 2, 4,
		4, 4, NA, NA,
		2, 1, 3, 5}, 5, 4)
	
	// 
	_, predictedValue, err := BayesianFilter(mat, 0, 1)
	// do something with err
	fmt.Println(predictedValue)

}

More Info

Some more information about BCF can be found at

Documentation

Overview

Bayesian Filter collaborative filtering in Go

Index

Constants

This section is empty.

Variables

View Source
var (
	ClassSet = []int{1, 2, 3, 4, 5}
	NA       = m.NaN()
)

Functions

func BayesianFilter

func BayesianFilter(mat *DenseMatrix, user, item int) (preds []float64, max int, err error)

/ Bayesian filter recommendation returns rating for a given user, item pair. Returns predictions, the index of the max prediction and an error if required.

func LaplaceSmoother

func LaplaceSmoother(count, countUser int) float64

Laplace smoother for the bayesian filter.

func MakeRatingMatrix

func MakeRatingMatrix(ratings []float64, rows, cols int) *DenseMatrix

returns the matrix of ratings.

func NumOccurences

func NumOccurences(row []float64, val float64) int

returns the # of occurences a value occured in a vector.

func PercentOccurences

func PercentOccurences(row []float64, val float64) (percent float64)

returns the % a value occured in a vector.

func Prod

func Prod(values []float64) float64

returns the product of elements in a vector.

func ToMap

func ToMap(col []float64) map[float64]float64

Types

This section is empty.

Jump to

Keyboard shortcuts

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