Example #1
0
    void predictMLPMulticlass()
    {
        int    bestModel = 0;
        double bestValue = 0.0f;

        IntPtr pointerToValues = MlDllWrapper.PredictMLPModel(MyModel, requestInput, _inputSize,
                                                              numberLayer, npl, isClassification);

        string[] arrayValuesasString = Marshal.PtrToStringAnsi(pointerToValues).Split(';');

        for (int i = 0; i < _outputSize; i++)
        {
            double currentValue = Convert.ToDouble(arrayValuesasString[i].Replace('.', ','));


            print($"{currentValue} and model {i}");
            //print($"{currentValue} and model {i}");
            if (currentValue > bestValue)
            {
                bestModel = i;
                bestValue = currentValue;
            }
        }

        print($"The best value is {bestValue} with the model {bestModel}");

        //Regression Lineaire

        /*if(pointerToValues != IntPtr.Zero)
         *  MlDllWrapper.DeleteLinearModel(pointerToValues);*/
    }
Example #2
0
    void predictMLPMulticlassRegression()
    {
        for (int j = 0; j < testDataSet.Count; j++)
        {
            _multiclassResult.Clear();

            int    bestModel = 0;
            double bestValue = 0.0f;

            IntPtr pointerToValues = MlDllWrapper.PredictMLPModel(MyModel, testDataSet[j], _inputSize,
                                                                  numberLayer, npl, isClassification);

            string[] arrayValuesasString = Marshal.PtrToStringAnsi(pointerToValues).Split(';');

            for (int i = 0; i < _outputSize; i++)
            {
                double currentValue = Convert.ToDouble(arrayValuesasString[i].Replace('.', ','));


                print($"{currentValue} and model {i}");
                if (currentValue > bestValue)
                {
                    bestModel = i;
                    bestValue = currentValue;
                }
            }

            print(arrayValuesasString[0]);

            //Regression Lineaire
            spheres[j].changeZ((float)Convert.ToDouble(arrayValuesasString[0].Replace('.', ',')));


            /*if(pointerToValues != IntPtr.Zero)
             *  MlDllWrapper.DeleteLinearModel(pointerToValues);*/
        }
    }
Example #3
0
    void predictMLPMulticlass()
    {
        for (int j = 0; j < testDataSet.Count; j++)
        {
            _multiclassResult.Clear();

            int    bestModel = 0;
            double bestValue = 0.0f;

            IntPtr pointerToValues = MlDllWrapper.PredictMLPModel(MyModel, testDataSet[j], _inputSize,
                                                                  numberLayer, npl, isClassification);

            string[] arrayValuesasString = Marshal.PtrToStringAnsi(pointerToValues).Split(';');


            for (int i = 0; i < _outputSize; i++)
            {
                double currentValue = Convert.ToDouble(arrayValuesasString[i].Replace('.', ','));


                if (currentValue > 0)
                {
                    spheres[j].ChangeMaterial(blueMat);
                }
                else
                {
                    spheres[j].ChangeMaterial(redMat);
                }
            }



            /*if(pointerToValues != IntPtr.Zero)
             *  MlDllWrapper.DeleteLinearModel(pointerToValues);*/
        }
    }
Example #4
0
    int predictDatasetSample(int k)
    {
        int           bestModel = 0;
        double        bestValue = 0.0f;
        List <double> tmp       = new List <double>();

        for (int i = k * npl[0]; i < npl[0] * (k + 1); i++)
        {
            tmp.Add(trainningInput[i]);
        }

        double[] tmp2 = tmp.ToArray();



        IntPtr pointerToValues = MlDllWrapper.PredictMLPModel(MyModel, tmp2, _inputSize,
                                                              numberLayer, npl, isClassification);

        string[] arrayValuesasString = Marshal.PtrToStringAnsi(pointerToValues).Split(';');

        for (int i = 0; i < _outputSize; i++)
        {
            double currentValue = Convert.ToDouble(arrayValuesasString[i].Replace('.', ','));


            // print($"{currentValue} and model {i}");
            //print($"{currentValue} and model {i}");
            if (currentValue > bestValue)
            {
                bestModel = i;
                bestValue = currentValue;
            }
        }

        return(bestModel);
    }