Beispiel #1
0
        public void Split(Dataset dataset, RecSysContext context, ref IQueryable <Rating> trainset, ref IQueryable <Rating> testset, ref IQueryable <Rating> evalset)
        {
            int trainCount = Convert.ToInt32(context.Ratings.Where(r => r.DatasetId == dataset.Id).Count() * (1 - _testPortion));

            trainset = context.Ratings.Where(r => r.DatasetId == dataset.Id).Take(trainCount);
            testset  = context.Ratings.Where(r => r.DatasetId == dataset.Id).Skip(trainCount);
            evalset  = Enumerable.Empty <Rating>().AsQueryable();
        }
Beispiel #2
0
        public void ImportData(RecSysContext recSysContext, Dataset datasetRecord)
        {
            // step 1: importing item ratings (users, items and ratings)
            var conf = new CsvConfiguration();

            conf.Delimiter = " ";

            var epinionReader = new CsvReader <ItemRating>(_datasetPath, conf, new ItemRatingMap());

            recSysContext.ImportItemRatings(epinionReader.ReadSamples(), datasetRecord);

            // step 2: importing relations
            var relations = File.ReadAllLines(_relationsPath).ToCsvDictionary(' ')
                            .Select(i => new Relation()
            {
                UserId = i["UserId"], ConnectedId = i["ConnectionId"], ConnectionType = ConnectionType.Trust
            });

            Console.WriteLine("Importing {0} relations ...", relations.Count());

            recSysContext.ImportToTable("Relations", relations);
        }
Beispiel #3
0
        public void ImportData(RecSysContext recSysContext, Dataset datasetRecord)
        {
            var itemRatings = (new MovieLensReader(_datasetPath)).ReadSamples();

            recSysContext.ImportItemRatings(itemRatings, datasetRecord);
        }
Beispiel #4
0
 public RatingDataset(Data.Dataset dataset, RecSysContext context, ISplitter splitter)
 {
     _allSamples = context.Ratings.Where(r => r.DatasetId == dataset.Id);
     splitter.Split(dataset, context, ref _trainSamples, ref _testSamples, ref _evalSamples);
 }