コード例 #1
0
ファイル: Dataset.cs プロジェクト: WisonHuang/WrapRec
 public Dataset(IDatasetReader <T> trainReader, IDatasetReader <T> testReader)
 {
     _trainSamples = trainReader.ReadAll().AsQueryable();
     _testSamples  = testReader.ReadAll().AsQueryable();
     _evalSamples  = Enumerable.Empty <T>().AsQueryable();
     _allSamples   = _trainSamples.Concat(_testSamples);
 }
コード例 #2
0
ファイル: Dataset.cs プロジェクト: WisonHuang/WrapRec
        public Dataset(IDatasetReader <T> reader, Func <IEnumerable <T>, Tuple <IEnumerable <T>, IEnumerable <T>, IEnumerable <T> > > trainTestEvalSplitter)
        {
            _allSamples = reader.ReadAll().AsQueryable();

            var splits = trainTestEvalSplitter(_allSamples);

            _trainSamples = splits.Item1.AsQueryable();
            _testSamples  = splits.Item2.AsQueryable();
            _evalSamples  = splits.Item3.AsQueryable();
        }
コード例 #3
0
ファイル: Dataset.cs プロジェクト: WisonHuang/WrapRec
        public Dataset(IDatasetReader <T> reader, double testPortion, double evalPortion)
        {
            if (testPortion + evalPortion > 1)
            {
                throw new Exception("Sum of test and evaluation portions should be less than 1.");
            }

            _allSamples = reader.ReadAll().AsQueryable();

            if (testPortion == 0 && evalPortion == 0)
            {
                _trainSamples = _allSamples;
                _testSamples  = _evalSamples = Enumerable.Empty <T>().AsQueryable();
                return;
            }

            int trainCount = Convert.ToInt32(_allSamples.Count() * (1 - testPortion - evalPortion));
            int testCount  = Convert.ToInt32(_allSamples.Count() * testPortion);

            _trainSamples = _allSamples.Take(trainCount);
            _testSamples  = _allSamples.Skip(trainCount).Take(testCount);
            _evalSamples  = _allSamples.Skip(trainCount + testCount);
        }
コード例 #4
0
 public override IEnumerable <ItemRatingWithRelations> ReadWithoutFiltering()
 {
     return(_itemRatingsReader.ReadAll().Select(ir => new ItemRatingWithRelations(ir, _relations)).ToList());
 }