示例#1
0
func main() {
	// Populate data list
	_, prefs := data.Populate()
	_, prefs2 := data.Populate()

	// ITEM-BASED Filtering
	//itemId := 2
	userId := 2

	simlist := reco.GetSimilar(&prefs, algo.Pearson)

	// recommendation list using Pearson
	recolist, err := reco.ItemBasedRecommend(&prefs, &simlist, userId)
	if err != nil {
		fmt.Println(err)
	}

	// Print user's recommended list
	fmt.Println("Item-based Pearson: ", recolist)

	simlist = reco.GetSimilar(&prefs2, algo.Euclidean)

	// recommendation list using Euclidean
	recolist, err = reco.ItemBasedRecommend(&prefs2, &simlist, userId)
	if err != nil {
		fmt.Println(err)
	}

	// Print user's recommended list
	fmt.Println("Item-based Euclidean: ", recolist)
}
示例#2
0
func main() {
	// Populate data list
	_, prefs := data.Populate()

	// USER-BASED Filtering
	userId := 2

	// recommendation list using Pearson
	recolist, err := reco.UserBasedRecommend(&prefs, userId, algo.Pearson)
	if err != nil {
		fmt.Println(err)
	}

	// Print user's recommended list
	fmt.Println("User-based Pearson: ", recolist[userId])

	// recommendation list using Euclidean
	recolist, err = reco.UserBasedRecommend(&prefs, userId, algo.Euclidean)
	if err != nil {
		fmt.Println(err)
	}

	// Print user's recommended list
	fmt.Println("User-based Euclidean: ", recolist[userId])

}