Пример #1
0
 public CollaborativeFilteringModel(Users users, Items items, SimilarityEngine similarityEngine, ISimilarityMethod predictionMethod)
 {
     this.similarityEngine = similarityEngine;
     this.users            = users;
     this.items            = items;
     this.predictionMethod = predictionMethod;
 }
Пример #2
0
        public void Load(string sFileName)
        {
            Tuple <Users, Items> data = dataLoaderEngine.Load(sFileName);

            users                 = data.Item1;
            items                 = data.Item2;
            similarityEngine      = new SimilarityEngine(users, MAX_SIMILAR_USERS, logger);
            TRAIN_DATA_PERCENTAGE = 0.95; // double.Parse(ConfigurationManager.AppSettings["train_data_percentage"]);
        }
 public StereotypesModel(SimilarityEngine similarityEngine, ISimilarityMethod similarityMethod, Users users, Items items, int cStereotypes)
 {
     this.randomGenerator  = new RandomGenerator();
     this.similarityEngine = similarityEngine;
     this.similarityMethod = similarityMethod;
     this.CENTROIDS_SIMILARITY_THRESHOLD = 0.99; // double.Parse(ConfigurationManager.AppSettings["CentroidsSimilarityThreshold"]);
     this.MAX_ITERATION          = 20;           // int.Parse(ConfigurationManager.AppSettings["maxNumIterationStereotype"]);
     this.minimumRatingThreshold = 50;           // int.Parse(ConfigurationManager.AppSettings["minimumRatingThreshold"]);
     this.users        = users;
     this.items        = items;
     this.cStereotypes = cStereotypes;
     similarityDic     = new Dictionary <User, User>();
 }
Пример #4
0
        public void Load(string sFileName, double dTrainSetSize)
        {
            Dictionary <RecommenderSystem.DatasetType, Tuple <Users, Items> > splittedData;

            Tuple <Users, Items> data = dataLoaderEngine.Load(sFileName);

            users = data.Item1;
            items = data.Item2;

            this.dsSize  = dataLoaderEngine.GetDataSetSize();
            splittedData = dataUtils.Split(dTrainSetSize, dsSize, data, DatasetType.Test, DatasetType.Train);

            trainUsers = splittedData[DatasetType.Train].Item1;
            trainItems = splittedData[DatasetType.Train].Item2;
            testUsers  = splittedData[DatasetType.Test].Item1;
            testItems  = splittedData[DatasetType.Test].Item2;

            double trainSize = Math.Round(dsSize * dTrainSetSize);

            splittedData = dataUtils.Split(dTrainSetSize, trainSize, new Tuple <Users, Items>(this.trainUsers, this.trainItems), DatasetType.Validation, DatasetType.Train);

            trainUsers      = splittedData[DatasetType.Train].Item1;
            trainItems      = splittedData[DatasetType.Train].Item2;
            validationUsers = splittedData[DatasetType.Validation].Item1;
            validationItems = splittedData[DatasetType.Validation].Item2;

            //calculate the overall average rating
            CalculateAverageRatingForTrainingSet();

            similarityEngine = new SimilarityEngine(trainUsers, MAX_SIMILAR_USERS, logger);  //TODO - check whether it should be train/test users
            evaluationEngine = new EvaluationEngine(averageTrainRating);

            predictionEngine.addModel(PredictionMethod.Cosine, new CollaborativeFilteringModel(trainUsers, trainItems, similarityEngine, new CosineMethod()));
            predictionEngine.addModel(PredictionMethod.Pearson, new CollaborativeFilteringModel(trainUsers, trainItems, similarityEngine, new PearsonMethod()));
            predictionEngine.addModel(PredictionMethod.Random, new CollaborativeFilteringModel(trainUsers, trainItems, similarityEngine, new RandomMethod()));

            itemBasedEngine = new ItemBasedEngine(trainItems); //TODO - check that we need to use test items...
        }