Ejemplo n.º 1
0
    public void RunMachineLearningTestCase()
    {
        double[] resultMLTestCase;

        if (testCaseOption == TestCaseOption.USE_IMAGES && (images == null || images.Count == 0))
        {
            Debug.LogError("Images not loaded");
        }

        if (totalWantedImagesToTest == 0)
        {
            imagesToTest = null;
        }

        TestCaseParameters param = MachineLearningTestCase.GetTestOption(testCaseOption, algoUsed);

        if (testCaseOption == TestCaseOption.USE_IMAGES)
        {
            param.neuronsPerLayer[0] = nbPixelInImage;
            param.neuronsPerLayer[param.neuronsPerLayer.Count - 1] = 1;
            param.X           = images;
            param.Y           = imageOutputs;
            param.sampleSize  = nbImagesLoaded;
            param.gamma       = (float)gamma;
            param.nbCentroids = nbCentroid;
        }

        if (algoUsed == AlgoUsed.RBF)
        {
            resultMLTestCase = RBFController.TrainRBFodel(this, param, imagesToTest, nbImagesToTestLoaded);
        }
        else
        {
            resultMLTestCase = MachineLearningTestCase.RunMachineLearningTestCase(algoUsed == AlgoUsed.LINEAR, param, epochs, learningRate, simulateTestCaseParameters, algoUsed, imagesToTest, nbImagesToTestLoaded);
        }

        if (testCaseOption != TestCaseOption.USE_IMAGES && testCaseOption != TestCaseOption.IMAGES_TEST)
        {
            DisplayOutput(resultMLTestCase);
        }
        else
        {
            foreach (var data in resultMLTestCase)
            {
                Debug.Log(data < 0.1 ? "Druid" : "Paladin");
            }
        }

        simulateTestCaseParameters = null;
    }