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);
        }
Пример #2
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());
 }