Exemple #1
0
        public IPredictImage Predict(IPredict predict, Action <IPredictConfiguration> configuration)
        {
            PredictConfiguration predictConfiguration;

            configuration(predictConfiguration = new PredictConfiguration(predict));
            return(predictConfiguration.Predict(_scanImage, predictConfiguration.Alphabet, predictConfiguration.Options));
        }
Exemple #2
0
 public void AddPredictor(IPredict p, string label)
 {
     _predicts.Add(p);
     _predictReporter.Add(new Abcd()
     {
         Label = label
     });
 }
Exemple #3
0
        async void showPrediction()
        {
            IPredict predictions = DependencyService.Get <IPredict>();
            string   a           = await Task.Run(() => predictions.getPrediction(file));

            string value = a;

            System.Console.WriteLine(value);
        }
Exemple #4
0
        public PredictorShould()
        {
            var dataFixture = new DataFixture();

            dataFixture.Init();
            _predict        = new Predict();
            _textClassifier =
                new TextMatcher(dataFixture.Companies, dataFixture.Localities, dataFixture.Classifiers)
            {
                UseCache = false
            };
            _account = dataFixture.GetTestBankAccount();
        }
Exemple #5
0
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            if (_data == null)
            {
                XtraMessageBox.Show("There is no data create model!", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var model = new PerceptronModel <Student>();

            _classifier = model.Generate(_data);
            XtraMessageBox.Show("Done!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #6
0
        public async Task PredictAsync(PredictBankStatement2Command command, IPredict predict)
        {
            var results = await predict.PredictManyAsync(State.PredictionRequests);

            var predictionResults = results as PredictionResult[] ?? results.ToArray();

            if (predictionResults.Any(x => x == null))
            {
                throw new ApplicationException();
            }
            var ev = new BankStatementPredicted2Event
            {
                PredictionResults = predictionResults
            };

            Emit(ev);

            await Task.CompletedTask;
        }
Exemple #7
0
        public static void DrawGrid(double[] extent, double resolution, IPredict predict, string fileName)
        {
            int    width = (int)Math.Round((extent[2] - extent[0]) / resolution) + 1, height = (int)Math.Round((extent[3] - extent[1]) / resolution) + 1;
            Bitmap bitmap = new Bitmap(width, height);
            double lon, lat;

            for (int i = 0; i < width; i++)
            {
                lon = extent[0] + i * resolution;
                for (int j = 0; j < height; j++)
                {
                    lat = extent[3] - j * resolution;
                    int value = (int)Math.Round(predict.Predict(lon, lat));
                    bitmap.SetPixel(i, j, Color.FromArgb(value / 256, value % 256, 0));
                }
            }
            bitmap.Save(fileName);
            bitmap.Dispose();
        }
 public PredictBankStatement2CommandHandler(IPredict predict)
 {
     _predict = predict;
 }
 public PredictConfiguration(IPredict predict)
 {
     Predict = predict.PredictModel;
 }
Exemple #10
0
 public PredictionController(IPredict predictor)
 {
     _predictor = predictor;
 }
Exemple #11
0
        public void Learn(IEnumerable <T> examples)
        {
            Examples = examples;
            var total = Examples.Count();
            // 80% for training
            var trainingCount = (int)System.Math.Ceiling(total * .8);
            // 20% for testing
            var testingSlice = GetTestPoints(total - trainingCount, total)
                               .ToArray();

            var trainingSlice = GetTrainingPoints(testingSlice, total);

            // getting data
            var             data        = Converter.Convert <T>(examples);
            Matrix          x           = data.Item1;
            Vector          y           = data.Item2;
            TypeDescription description = data.Item3;

            // training
            var x_t = x.Slice(trainingSlice, VectorType.Row);
            var y_t = y.Slice(trainingSlice);

            Predictors = new IPredict <T> [Models.Length];

            // run in parallel since they all have
            // read-only references to the data model
            // and update independently to different
            // spots
            //Parallel.For(0, Models.Length, i =>
            //{
            for (int i = 0; i < Models.Length; i++)
            {
                Models[i].X           = x_t;
                Models[i].Y           = y_t;
                Models[i].Description = description;
                Predictors[i]         = Models[i].Generate();
            }
            //});

            // testing
            T[] test = GetTestExamples(testingSlice, examples);
            Accuracy = Vector.Zeros(Predictors.Length);
            for (int i = 0; i < Predictors.Length; i++)
            {
                Accuracy[i] = 0;
                for (int j = 0; j < test.Length; j++)
                {
                    var truth = Conversion.Converter.GetItem <T>(test[j], description.Label);

                    Predictors[i].Predict(test[j]);

                    var pred = Conversion.Converter.GetItem <T>(test[j], description.Label);

                    // need to set it back...
                    Converter.SetItem <T>(test[j], description.Label, truth);

                    if (Object.Equals(truth, pred))
                    {
                        Accuracy[i] += 1;
                    }
                }

                Accuracy[i] /= test.Length;
            }
            ;
        }