Exemplo n.º 1
0
        public async Task RetrieveTestData_ToMultilayerNetworkClassifier(string fileName)
        {
            var storagePath = GetStorageDir();

            using (var blobs = new BlobStore(storagePath))
            using (var store = new SampleStore(storagePath))
            {
                await blobs.Setup(true);

                var samples = store.ListSamples();

                var item = samples.Where(s => s.SourceDataUrl != null && s.SourceDataUrl.EndsWith(fileName)).FirstOrDefault();

                var sample = await store.RetrieveSample(item.Uri);

                var pipe = sample.CreatePipeline().OutputResultsTo(blobs);
                
                var classifier = pipe.ToMultilayerNetworkClassifier(x => x.Label).Execute(fileName);

                var classOfFirst = classifier.Classify(sample.SampleData.First());

                var blob = blobs.OpenMultilayerNetworkClassifier<DataItem, string>(fileName, sample.CreateFeatureExtractor());

                Assert.That(classOfFirst.Any());
                Assert.That(classOfFirst.First().Score > 0);
            }
        }
Exemplo n.º 2
0
        public async Task StoreAsync_NoDataRows()
        {
            var sample = SetupData();

            sample.SampleData.Clear();

            using (var store = new SampleStore())
            {
                try
                {
                    await store.Setup(true);

                    await store.StoreSample(sample);
                }
                finally
                {
                    store.Destroy();
                }
            }
        }
Exemplo n.º 3
0
        public async Task LoadTestData(string fileName)
        {
            var storagePath = GetStorageDir();
            var dataFile = GetDataFilePath(fileName);

            using (var store = new SampleStore(storagePath.FullName))
            {
                await store.Setup();

                var parser = new CsvSampleParser();

                using (var file = dataFile.OpenRead())
                {
                    var sample = parser.ReadFromStream(file);

                    sample.SourceDataUrl = dataFile.FullName;

                    await store.StoreSample(sample);
                }
            }
        }
Exemplo n.º 4
0
        public async Task RetrieveTestData_ToNaiveBayesClassifier(string fileName)
        {
            var storagePath = GetStorageDir();

            using (var store = new SampleStore(storagePath))
            {
                var samples = store.ListSamples();

                var item = samples.Where(s => s.SourceDataUrl != null && s.SourceDataUrl.EndsWith(fileName)).FirstOrDefault();

                var sample = await store.RetrieveSample(item.Uri);

                var pipe = sample.CreatePipeline();
                
                var classifier = pipe.ToNaiveBayesClassifier(x => x.Label).Execute();

                var classOfFirst = classifier.Classify(sample.SampleData.First());

                Assert.That(classOfFirst.Any());
                Assert.That(classOfFirst.First().Score > 0);
            }
        }
Exemplo n.º 5
0
        public async Task StoreAsync_ThenList()
        {
            var sample = SetupData();

            using (var store = new SampleStore())
            {
                try
                {
                    await store.Setup(true);

                    await store.StoreSample(sample);

                    var samples = store.ListSamples().ToList();

                    Assert.That(samples.Any(s => s.Id == sample.Id));
                }
                finally
                {
                    store.Destroy();
                }
            }
        }
Exemplo n.º 6
0
        public async Task StoreAsync_ExampleDataRows_ThenRetrieve()
        {
            var sample = SetupData();

            using (var store = new SampleStore())
            {
                try
                {
                    await store.Setup(true);

                    var uri = await store.StoreSample(sample);

                    var sample2 = await store.RetrieveSample(uri);

                    Assert.That(sample2, Is.Not.Null);

                }
                finally
                {
                    store.Destroy();
                }
            }
        }