Beispiel #1
0
        public IActionResult Data(DataService dataService)
        {
            PredictionData predictionData = dataService.getPredictionData();
            DataViewModel  viewModel      = new DataViewModel(predictionData);

            return(View(viewModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PredictionID,TipsterID,MatchID,predictionDate,matchOutcome")] PredictionData prediction)
        {
            if (id != prediction.PredictionID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prediction);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PredictionExists(prediction.PredictionID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MatchID"]   = new SelectList(_context.Match, "MatchID", "MatchName", prediction.MatchID);
            ViewData["TipsterID"] = new SelectList(_context.Tipster, "TipsterId", "Email", prediction.TipsterID);
            return(View(prediction));
        }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();
            ModelThreat    = new ModelPrediction.View.ModelThreat.ModelThreat();
            AnaliticData   = new AnaliticData();
            PredictionData = new PredictionData();
            OutputePanel   = new OutputePanel();

            ModelThreatVM.SetLabels(nameModel, countThreat, dateCreate, nameThreat, number, countData);
        }
        public async Task <IActionResult> Create([Bind("PredictionID,TipsterID,MatchID,predictionDate,matchOutcome")] PredictionData prediction)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prediction);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MatchID"]   = new SelectList(_context.Match, "MatchID", "MatchName", prediction.MatchID);
            ViewData["TipsterID"] = new SelectList(_context.Tipster, "TipsterId", "Email", prediction.TipsterID);
            return(View(prediction));
        }
Beispiel #5
0
        public IList <double> Execute(IList <double> source)
        {
            var count = source.Count;

            if (count == 0)
            {
                return(new double[0]);
            }

            var res = new double[count];

            var context = Context;

            Contract.Assert(context != null);

            var size = count / 2;
            var data = source.Take(size).Select(PredictionData.MakePredictionData);

            var ml       = new MLContext();
            var dataView = ml.Data.LoadFromEnumerable(data);

            const string outputColumnName = "Prediction";
            const string inputColumnName  = "Value";
            var          args             = new SsaChangePointDetector.Arguments()
            {
                Source              = inputColumnName,
                Name                = outputColumnName,
                Confidence          = Confidence,              // The confidence for spike detection in the range [0, 100]
                ChangeHistoryLength = size / 4,                // The length of the sliding window on p-values for computing the martingale score.
                TrainingWindowSize  = size / 2,                // The number of points from the beginning of the sequence used for training.
                SeasonalWindowSize  = size / 8,                // An upper bound on the largest relevant seasonality in the input time - series."
            };

            // Train the change point detector.
            ITransformer model = new SsaChangePointEstimator(ml, args).Fit(dataView);

            // Create a prediction engine from the model for feeding new data.
            var engine = model.CreateTimeSeriesPredictionFunction <PredictionData, ChangePointPrediction>(ml);

            for (var i = size; i < count; i++)
            {
                var prediction = engine.Predict(PredictionData.MakePredictionData(source[i]));
                res[i] = prediction.Prediction[OutputNumber];
            }

            return(res);
        }
Beispiel #6
0
        private async void MessageCenterSubmitAsync(RecorderViewModel arg1, PredictionData data)
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                if (data == null)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "No data returned. Please record your command again or contact support", "Cancel", "ok");
                }


                if (data.ClassId.Trim() == "Back or Go back" && data.Probability > 70.0)
                {
                    await Application.Current.MainPage.Navigation.PopAsync();
                }
                else if (data.ClassId.Trim() == "item 1 or 1" && data.Probability > 70.0)
                {
                    ItemSelectedCommand.Execute(Products[0]);
                }
                else if (data.ClassId.Trim() == "Item 2 or 2" && data.Probability > 70.0)
                {
                    ItemSelectedCommand.Execute(Products[1]);
                }
                else if (data.ClassId.Trim() == "Item 3 or 3" && data.Probability > 70.0)
                {
                    ItemSelectedCommand.Execute(Products[2]);
                }
                else if (data.ClassId.Trim() == "Item 4 or 4" && data.Probability > 70.0)
                {
                    ItemSelectedCommand.Execute(Products[3]);
                }
                else if (data.ClassId.Trim() == "Item 5 or 5" && data.Probability > 70.0)
                {
                    ItemSelectedCommand.Execute(Products[4]);
                }
                else if (data.ClassId.Trim() == "Open Cart" && data.Probability > 70.0)
                {
                    CardItemCommand.Execute(null);
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Please record your command again. Recording is not clear enough", "Cancel", "ok");
                }
            });
        }
 public DataViewModel(PredictionData data)
 {
     TotalPredictions             = data.TotalPredictions;
     TotalHomeWinsPredicted       = data.TotalHomeWinsPredicted;
     TotalAwayWinsPredicted       = data.TotalAwayWinsPredicted;
     TotalStrongHomeWinsPredicted = data.TotalStrongHomeWinsPredicted;
     TotalStrongAwayWinsPredicted = data.TotalStrongAwayWinsPredicted;
     TotalStrongWinsPredicted     = data.TotalStrongWinsPredicted;
     TotalDrawsPredicted          = data.TotalDrawsPredicted;
     TotalCorrect               = data.TotalCorrect;
     TotalCorrectScores         = data.TotalCorrectScores;
     TotalCorrectDraws          = data.TotalCorrectDraws;
     TotalCorrectStrongWins     = data.TotalCorrectStrongWins;
     TotalCorrectHomeWins       = data.TotalCorrectHomeWins;
     TotalCorrectStrongHomeWins = data.TotalCorrectStrongHomeWins;
     TotalCorrectAwayWins       = data.TotalCorrectAwayWins;
     TotalCorrectStrongAwayWins = data.TotalCorrectStrongAwayWins;
     SetPercentages();
 }
        public PredictionData getPredictionData()
        {
            PredictionData predictionData = new PredictionData();

            try
            {
                using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                {
                    using (SqlCommand sqlCommand = new SqlCommand("SELECT * from PredictionTally as data ", connection))
                    {
                        connection.Open();
                        using (SqlDataReader reader = sqlCommand.ExecuteReader())
                        {
                            reader.Read();
                            predictionData.TotalPredictions             = int.Parse(reader["TotalPredictions"].ToString());
                            predictionData.TotalHomeWinsPredicted       = int.Parse(reader["TotalPredictedHomeWins"].ToString());
                            predictionData.TotalAwayWinsPredicted       = int.Parse(reader["TotalPredictedAwayWins"].ToString());
                            predictionData.TotalStrongHomeWinsPredicted = int.Parse(reader["TotalPredictedStrongHomeWins"].ToString());
                            predictionData.TotalStrongAwayWinsPredicted = int.Parse(reader["TotalPredictedStrongAwayWins"].ToString());
                            predictionData.TotalStrongWinsPredicted     = int.Parse(reader["TotalPredictedStrongWins"].ToString());
                            predictionData.TotalDrawsPredicted          = int.Parse(reader["TotalPredictedDraws"].ToString());
                            predictionData.TotalCorrect               = int.Parse(reader["TotalCorrect"].ToString());
                            predictionData.TotalCorrectScores         = int.Parse(reader["TotalCorrectScores"].ToString());
                            predictionData.TotalCorrectDraws          = int.Parse(reader["CorrectDraws"].ToString());
                            predictionData.TotalCorrectStrongWins     = int.Parse(reader["TotalOverallCorrectStrongWins"].ToString());
                            predictionData.TotalCorrectHomeWins       = int.Parse(reader["TotalOverallCorrectHomeWins"].ToString());
                            predictionData.TotalCorrectStrongHomeWins = int.Parse(reader["TotalCorrectStrongHomeWins"].ToString());
                            predictionData.TotalCorrectAwayWins       = int.Parse(reader["TotalOverallCorrectAwayWins"].ToString());
                            predictionData.TotalCorrectStrongAwayWins = int.Parse(reader["TotalCorrectStrongAwayWins"].ToString());
                            reader.Close();
                        }
                        connection.Close();
                    }
                }
                return(predictionData);
            }catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public IList <double> Execute(ISecurity source)
        {
            var count = source.Bars.Count;

            if (count == 0)
            {
                return(new double[0]);
            }
            var size = HistoryBarsBack * HorizontalLines;

            var scheme    = GetSchemaDefinition(size);
            var mlContext = MakeMlContext();

            var file = new FileInfo(ModelPath);

            if (!file.Exists)
            {
                throw new ScriptException($"File '{ModelPath}' isn't found!");
            }
            var key = $"{file.LastWriteTime}:{ModelPath}";

            var trainedModel = Context.LoadGlobalObject(key, () => mlContext.Model.Load(ModelPath, out _));

            var predictionEngine =
                mlContext.Model.CreatePredictionEngine <PredictionData, PredictionResult>(trainedModel,
                                                                                          inputSchemaDefinition: scheme);
            var res = Context.GetArray <double>(count) ?? new double[count];

            for (var i = TestStartBar; i < count; i++)
            {
                var chart = MakeChart(source, i, size, 1);
                var data  = new PredictionData {
                    Features = new VBuffer <float>(size, chart)
                };
                var predictedPreview = predictionEngine.Predict(data);
                res[i] = predictedPreview.Score;
            }

            return(res);
        }
 private void MessageCenterSubmitAsync(RecorderViewModel arg1, PredictionData data)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (data == null)
         {
             await Application.Current.MainPage.DisplayAlert("Error", "No data returned. Please record your command again or contact support", "Cancel", "ok");
         }
         if (data.ClassId.Trim() == "Add to cart" && data.Probability > 70.0)
         {
             AddToCartCommand.Execute(this);
         }
         else if (data.ClassId.Trim() == "Open Cart" && data.Probability > 70.0)
         {
             CardItemCommand.Execute(null);
         }
         else
         {
             await Application.Current.MainPage.DisplayAlert("Error", "Please record your command again. Recording is not clear enough", "Cancel", "ok");
         }
     });
 }
        private async void MessageCenterSubmitAsync(RecorderViewModel arg1, PredictionData data)
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                if (data == null)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "No data returned. Please record your command again or contact support", "Cancel", "ok");
                }
                if (data.ClassId.Trim() == "Men's shoes" && data.Probability > 70.0)
                {
                    var cat = Categories.FirstOrDefault(x => x.EngName.Trim() == "Men's Shoes");


                    CategorySelectedCommand.Execute(cat);
                }
                else if (data.ClassId.Trim() == "Men's watches" && data.Probability > 70.0)
                {
                    var cat = Categories.FirstOrDefault(x => x.EngName.Trim() == "Men's Watches");

                    CategorySelectedCommand.Execute(cat);
                }
                else if (data.ClassId.Trim() == "Women's bags" && data.Probability > 70.0)
                {
                    var cat = Categories.FirstOrDefault(x => x.EngName.Trim() == "Women's Bags");

                    CategorySelectedCommand.Execute(cat);
                }
                else if (data.ClassId.Trim() == "Women's shoes" && data.Probability > 70.0)
                {
                    var cat = Categories.FirstOrDefault(x => x.EngName.Trim() == "Women's Shoes");

                    CategorySelectedCommand.Execute(cat);
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Please record your command again. Recording is not clear enough", "Cancel", "ok");
                }
            });
        }
Beispiel #12
0
    private void giveTop3ToSceneManager(PredictionData prediction)
    {
        List <int> temp = new List <int>();

        for (int i = 0; i < 5; i++)
        {
            if (ItemEventManager.Instance.ItemData[prediction.numbers[i]].Tag2 != "Filtered")
            {
                temp.Add(prediction.numbers[i]);
                Debug.Log(prediction.numbers[i] + " : " + prediction.names[i]);
            }
        }

        if (temp.Count >= 3)
        {
            for (int k = 0; k < 3; k++)
            {
                scene1Manager.top3PredictionIds[k] = temp[k];
            }
            UIManager.Instance.ActiveChoiceBtns(true);
            scene1Manager.SetBtnsName();
        }
    }
 private async void MessageCenterSubmitAsync(RecorderViewModel source, PredictionData data)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (data == null)
         {
             await Application.Current.MainPage.DisplayAlert("Error", "No data returned. Please record your command again or contact support", "Cancel", "ok");
         }
         //if english
         if (data.ClassId.Trim() == "Place order" && data.Probability > 70.0)
         {
             PlaceOrderCommand.Execute(null);
         }
         else if (data.ClassId == "Back or Go back" && data.Probability > 70.0)
         {
             await Application.Current.MainPage.Navigation.PopAsync();
         }
         else
         {
             await Application.Current.MainPage.DisplayAlert("Error", "Please record your command again. Recording is not clear enough", "Cancel", "ok");
         }
     });
 }
Beispiel #14
0
        public IList <double> Execute(ISecurity source)
        {
            var count = source.Bars.Count;

            if (count == 0)
            {
                return(new double[0]);
            }
            var context = Context;

            Contract.Assert(context != null);

            /*            var usedVars = 1;
             *          if (UseHigh)
             *              usedVars++;
             *          if (UseLow)
             *              usedVars++;
             *          if (UseVolume)
             *              usedVars++;
             *
             *          var size = HistoryBarsBack * usedVars;*/
            var key  = $"PredictionData.{source.CacheName}.{HighOrLow}.{Period}.{HistoryBarsBack}";
            var data = context.LoadObject <PredictionData[]>(key, () => null);

            if (data?.Length != count)
            {
                data = null;
            }

            int size = 6;

            if (data == null)
            {
                var preview = MakeHighLowCache(context, source, Period);
                var closes  = source.ClosePrices;

                var rsi   = Make(Series.RSI, closes, HistoryBarsBack);
                var cci   = Make(Series.CCI, source.Bars, HistoryBarsBack);
                var stDev = Make(Series.StDev, closes, HistoryBarsBack);
                var highs = Make(Series.Highest, source.HighPrices, HistoryBarsBack);
                var lows  = Make(Series.Lowest, source.LowPrices, HistoryBarsBack);
                var ema   = Make(Series.EMA, closes, HistoryBarsBack);
                var ema2  = Make(Series.EMA, closes, HistoryBarsBack / 2);
                var ema3  = Make(Series.EMA, closes, HistoryBarsBack * 2);

                data = context.GetArray <PredictionData>(count) ?? new PredictionData[count];
                for (var i = 0; i < data.Length; i++)
                {
                    var label  = (float)(HighOrLow ? preview[i].V1 : -preview[i].V2);
                    var values = new[]
                    {
                        (float)(ema[i] - closes[i]), (float)(ema3[i] - closes[i]),
                        (float)(ema3[i] - closes[i]), (float)rsi[i], (float)(ema[i] - ema2[i]),
                        (float)cci[i], (float)stDev[i], (float)(highs[i] - closes[i]),
                        (float)(lows[i] - closes[i])
                    };
                    size = values.Length;

                    data[i] = new PredictionData
                    {
                        Features = new VBuffer <float>(values.Length, values), Preview = label
                    };
                }

                context.StoreObject(key, data);
            }
            else
            {
                size = data[0].Features.Length;
            }

            var splitInterval = new Interval(ChangeMinutes, DataIntervals.MINUTE);
            var helper        = new SeparatedModelHelper <PredictionData, PredictionResult>(context, TrainDays,
                                                                                            splitInterval, CalcLastNumModels);

            return(helper.Build(key, source.Bars, data, size, Period,
                                res => res.PredictedPreview * (HighOrLow ? 1 : -1)));
        }