public void TrainModelTest(string trainFile, int chunkSize, int numOfChunk)
        {
            var model = new TrainModel(numOfChunk, 2, 64, 0.1);
            var dataset = new ClassifiedDataset(trainFile, 64, 2);

            int count = 0;

            foreach (var chunk in dataset.GetClassifiedVectorsInChunks(chunkSize))
            {
                model.Train(chunk, count);
                if (++count == numOfChunk)
                {
                    break;
                }
            }

            var weights = model.GetWeights();

            Assert.That(weights.Length, Is.EqualTo(2));

            foreach (var w in weights)
            {
                Assert.IsNotNull(w);
            }
        }
        public void TrainModelAndTestModelTest(string trainFile, string testFile, int chunkSize, int numOfChunk)
        {
            var trainModel = new TrainModel(numOfChunk, 2, 64, 0.1);
            var trainDataset = new ClassifiedDataset(trainFile, 64, 2);

            var testModel = new TestModel(numOfChunk, 2, 0.1, trainModel.GetWeights());
            var testDataset = new UnclassifiedDataset(testFile, 64);

            int count = 0;

            foreach (var chunk in trainDataset.GetClassifiedVectorsInChunks(chunkSize))
            {
                trainModel.Train(chunk, count);
                if (++count == numOfChunk)
                {
                    break;
                }
            }

            var results = testModel.Test(testDataset.GetDataVectors().Select(v => v.FeatureVector).ToArray(), 0);
        }
示例#3
0
 public Machine(int numOfClasses, int numOfFeatures, int numOfTrainChunk, int[] featureSelection, double noise)
     : base(numOfClasses, numOfFeatures, featureSelection, noise)
 {
     this.trainModel = new TrainModel(numOfTrainChunk, numOfClasses, GetNumOfReturnFeatures(), noise);
     this.testModel = new TestModel(1, numOfClasses, noise, this.trainModel.GetWeights());
 }