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(); }
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); }
public void ImportData(RecSysContext recSysContext, Dataset datasetRecord) { var itemRatings = (new MovieLensReader(_datasetPath)).ReadSamples(); recSysContext.ImportItemRatings(itemRatings, datasetRecord); }
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); }