Exemple #1
0
        private void Rm_DataStreamUpdate(string dataStream, string preprocessedDataStream)
        {
            var stream             = dataStream.Split(",");
            var preprocessedStream = preprocessedDataStream.Split(",");

            if (isPrediction)
            {
                string pred = "";

                var values = preprocessedDataStream.Split(',');
                for (int i = 0; i < values.Length - 1; i++)
                {
                    dataVals.Add(float.Parse(values[i]));
                }
                if (dataVals.Count == 12300)
                {
                    PredictionEngine.InputData input = new PredictionEngine.InputData()
                    {
                        PixelValues = dataVals.ToArray()
                    };
                    pred = preditionEngine.PredictSingle(input);

                    Invoke(new AppendTextOnTextBox(SetPredictionLabel), new object[] { pred });

                    dataVals.Clear();
                }
                else if (dataVals.Count > 12420)
                {
                    dataVals.Clear();
                }

                if (isEvaluating && (pred != null))
                {
                    CountPredition(pred);
                    Invoke(new AppendTextOnTextBox(SetText), new object[] { EvaluationText() });
                }
                else
                {
                    Invoke(new AppendTextOnTextBox(SetText), new object[] { pred });
                }
            }
            else
            {
                Invoke(new ShowDataStream(ShowDataStreamOnTextBox), new object[] { "raw_data", dataStream });
                Invoke(new ShowDataStream(ShowPreprocessedData), new object[] { "preprocessed_data", preprocessedDataStream });
            }
        }
Exemple #2
0
        private static void DoEvaluation()
        {
            string title = "Light GBM";
            ISignPreditionEngine preditionEngine = new MLNetHierarchicalSignPrediciton(MLNetClassifier.LightGBM);

            float[]  input_feature = new float[12300];
            string[] lines         = File.ReadAllLines(Environment.CurrentDirectory + "\\SignTestData.csv");
            int      count         = 0;
            int      totalPred     = 0;

            foreach (string line in lines)
            {
                var input  = line.Split(',');
                var output = input[input.Length - 1];
                for (int i = 0; i < input.Length - 1; i++)
                {
                    input_feature[i] = float.Parse(input[i]);
                }

                var inputData = new PredictionEngine.InputData {
                    PixelValues = input_feature
                };

                var pred = preditionEngine.PredictSingle(inputData);
                if (pred != null)
                {
                    if (pred.ToLower().Equals(output.ToLower()))
                    {
                        count++;
                    }
                    Console.WriteLine($"Real : {output} ; Pred : {pred}");
                    totalPred++;
                }
            }

            var accuracy = (float)count / totalPred;

            Console.WriteLine("====================================");
            Console.WriteLine($"Evaluation for {title}");
            Console.WriteLine("====================================");
            Console.WriteLine($"Accuracy : {accuracy}");
        }
        private void Rm_DataStreamUpdate(string dataStream, string preprocessedDataStream)
        {
            var values = preprocessedDataStream.Split(',');

            for (int i = 0; i < values.Length - 1; i++)
            {
                dataVals.Add(float.Parse(values[i]));
            }

            if (dataVals.Count == 12300)
            {
                PredictionEngine.InputData input = new PredictionEngine.InputData()
                {
                    PixelValues = dataVals.ToArray()
                };

                var pred = preditionEngine.Predict(input);

                //Invoke(new AppendTextOnTextBox(AppendText), new object[] { pred });
                Dispatcher.Invoke(new AppendTextOnTextBox(SetText), new object[] { pred });
                dataVals.Clear();
            }
        }