示例#1
0
    static void ItemItemStart()
    {
        FileReader fReader = new FileReader();
        Dictionary<int, UserPref> userList = fReader.GetData();
        Dictionary<string, float> fileMetaData = fReader.GetMetaData();

        FormulaFactory forFactory = new FormulaFactory();
        ItemComparer itemComparer = new ItemComparer(fReader.allProducts, userList);

        int targetUserID = 186;
        int targetProductID = 172;

        DateTime startTime = DateTime.Now;
        itemComparer.PredictRating(userList[targetUserID], targetProductID);
        // var x = itemComparer.PredictTopRatings(userList[targetUserID], 5);
        DateTime endTime = DateTime.Now;
        Console.WriteLine("Calculating the predicted rating took {0} ms",(endTime-startTime).Milliseconds);
        //itemComparer.AddNewRating(userList[3],105,4);
        //var y = itemComparer.PredictTopRatings(userList[targetUserID], 5);

        Console.Read();
    }
示例#2
0
    static void UserItemStart()
    {
        FileReader fReader = new FileReader();
        Dictionary<int, UserPref> userList = fReader.GetData();
        Dictionary<string, float> fileMetaData = fReader.GetMetaData();

        FormulaFactory forFactory = new FormulaFactory();
        NeighbourFinder nFinder = new NeighbourFinder(forFactory.GetFormula(fileMetaData));

        int targetUserID = 186;
        Dictionary<int, double> neighbourList = nFinder.FindNeighbours(targetUserID, userList);

        foreach (var neighbour in neighbourList)
        {
            Console.WriteLine("Neighbour {0} has a similarity of {1}", neighbour.Key, neighbour.Value);
        }

        RatingPredictor rPredictor = new RatingPredictor();
        rPredictor.PredictRatings(userList, targetUserID, neighbourList);
        rPredictor.GetTopPredictedRatings(8);

        Console.Read();
    }