private static PredictionViewModel ConvertToViewModel(Prediction model) { if (model == null) { return(null); } PredictionViewModel viewModel = new PredictionViewModel { DaysInFuture = model.DaysInFuture, Prices = new List <double>(), Probabilities = new List <double>() }; if (model.Prices.IsNullOrEmpty() || model.Probabilities.IsNullOrEmpty()) { return(viewModel); } for (int i = 0; i < model.Prices.Count; i++) { if (model.Probabilities[i] > 1e-5) { viewModel.Prices.Add(model.Prices[i]); viewModel.Probabilities.Add(model.Probabilities[i]); } } return(viewModel); }
public ActionResult Index(PredictionViewModel model) { try { ViewBag.Statistics = _mapper.Map <PredictionStatisticsViewModel>(_predictionStatisticsService.GetStatistics(_mapper.Map <Prediction>(model))); ViewBag.SearchModel = model; var request = new FilteredModel <Prediction>(); var offset = (model.ThisPageIndex - 1) * model.ThisPageSize; var result = _mapper.Map <IList <PredictionViewModel> >(_predictionService.GetPaging(_mapper.Map <Prediction>(model), out long totalCount, model.PageOrderBy, model.PageOrder, offset, model.ThisPageSize)); ViewBag.OnePageOfEntries = new StaticPagedList <PredictionViewModel>(result, model.ThisPageIndex, model.ThisPageSize, (int)totalCount); ViewBag.EventsList = new SelectList(_dropDownService.GetEvents(), "id", "name", null); } catch (Exception ex) { _logger.Error(ex); if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } } return(View()); }
public MainWindowViewModel() { GdalConfiguration.ConfigureGdal(); Dictionary <int, LandcoverTypeViewModel> landcoverTypes = new Dictionary <int, LandcoverTypeViewModel>(); foreach (LandcoverTypeViewModel landcoverType in LandcoverTypeViewModel.DefaultLandcoverTypesViewModel) { landcoverTypes.Add(landcoverType.Id, landcoverType); } LandcoverTypes = landcoverTypes.ToImmutableDictionary(); ExitCommand = new RelayCommand(() => Application.Current.Shutdown(), () => true); CreateSlopeFromHeightmapCommand = new RelayCommand(() => new CreateSlopeFromHeightmapDialog().ShowDialog(), () => true); CreateTiledHeightmapCommand = new RelayCommand(() => new CreateTiledHeightmapDialog().ShowDialog(), () => true); AddLayersCommand = new RelayCommand(AddBands, () => PredictionViewModel.NotBlocking); FlattenWaterDEMCommand = new RelayCommand(FlattenWaterDEM, () => true); FillDEMHolesCommand = new RelayCommand(FillDEMHoles, () => true); MoveLayerDownCommand = new RelayCommand(MoveLayerDown, CanMoveDown); MoveLayerUpCommand = new RelayCommand(MoveLayerUp, CanMoveUp); LandcoverTypesCommand = new RelayCommand(ChangeLandCoverTypes, () => true); Layers = new ObservableCollection <LayerViewModel>(); Layers.CollectionChanged += (sender, args) => { FeatureLayerView = new ObservableCollection <LayerViewModel>(Layers.Where(l => l.UseFeature).ToList()); }; ClassifierViewModel = new ClassifierViewModel(this); PredictionViewModel = new PredictionViewModel(this); }
public IActionResult Place(PredictionViewModel vm) { string username = HttpContext.Session.GetString("Account"); if (username != null) { Prediction p = new Prediction(); p.Competition = CompRepo.GetCompetition(vm.Competition_id); p.User = UserRepo.GetUser(username); int position = 1; foreach (int id in vm.Driver_id) { PredictionComponent pc = new PredictionComponent(); pc.Driver_id = id; pc.Position = position; position++; p.Components.Add(pc); } try { repo.Place(p); return(RedirectToAction("Index", "Prediction")); } catch (Exception) { return(View("Error")); } } return(RedirectToAction("LogIn", "User")); }
//[HttpGet] public async Task <IActionResult> SearchItem(int?id) { if (id == null) { return(NotFound()); } var productDetails = await _context.ProductDetails.FindAsync(id); if (productDetails == null) { return(NotFound()); } //var productDetails = await _context.ProductDetails // .FirstOrDefaultAsync(m => m.ID == Int32.Parse(id)); //if (productDetails == null) //{ // return NotFound(); //} lstProduct.Add(productDetails); PredictionViewModel predictionViewModel = new PredictionViewModel(); predictionViewModel.lstProductDetails = lstProduct; return(View("Predict", predictionViewModel)); }
public PredictionViewModel GetPrediction(string underlying, int daysInFuture, double?volatility = null) { OptionChain optionChain = GetOptionChainWithPredefinedVolatility(underlying, volatility); Prediction result = _predictionAndStdDevService.GetPrediction(optionChain, daysInFuture); PredictionViewModel viewModel = Mapper.Map <Prediction, PredictionViewModel>(result); return(viewModel); }
private PredictionViewModel GetModel(SaleDataInputModel inputModel) { var displayModel = new PredictionViewModel(); SetMlDisplayPredictionData(displayModel, inputModel); SetFourthDisplayPredictionData(displayModel); return(displayModel); }
public ActionResult List(PredictionViewModel collection) { try { if (collection.HomeClubId.HasValue && collection.HomeClubId.Value == 0) { collection.HomeClubId = null; } if (collection.MatchId.HasValue && collection.MatchId.Value == 0) { collection.MatchId = null; } var request = new FilteredModel <PredictionViewModel> { PageIndex = collection.ThisPageIndex, Order = collection.PageOrder, OrderBy = collection.PageOrderBy, PageSize = collection.ThisPageSize }; var offset = (request.PageIndex - 1) * request.PageSize; var result = _mapper.Map <IList <PredictionViewModel> >(_predictionService.GetPaging(_mapper.Map <Prediction>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize)); if (!result.Any() && totalCount > 0 && request.PageIndex > 1) { request.PageIndex = (int)(totalCount / request.PageSize); if (totalCount % request.PageSize > 0) { request.PageIndex++; } offset = (request.PageIndex - 1) * request.PageSize; result = _mapper.Map <IList <PredictionViewModel> >(_predictionService.GetPaging(_mapper.Map <Prediction>(collection), out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize)); } ViewBag.OnePageOfEntries = new StaticPagedList <PredictionViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount); ViewBag.SearchModel = collection; ViewBag.Statistics = _mapper.Map <PredictionStatisticsViewModel>(_predictionStatisticsService.GetStatistics(_mapper.Map <Prediction>(collection))); } catch (Exception ex) { _logger.Error(ex); if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } } return(Request.IsAjaxRequest() ? (ActionResult)PartialView("_PredictionGrid", ViewBag.OnePageOfEntries) : View()); }
private static void SetFourthDisplayPredictionData(PredictionViewModel model) { //Garlic Bread first week of May data double[] garlicBreadMay = new double[] { 3, 3, 2, 2, 0, 0, 0 }; //Garlic Bread April data double[] estimated = new double[] { 2, 3, 5, 5, 2, 1, 2, 1, 2 }; //double[] estimated = new double[] { 1, 1, 1, 1, 1, 1, 1 }; model.FourthMeanAbsoluteError = MLMathFormulas.MeanAbsoluteError(garlicBreadMay, estimated); model.FourthMeanSquaredError = MLMathFormulas.MeanSquaredError(garlicBreadMay, estimated); model.FourthCoefficientOfDetermination = Math.Round(MLMathFormulas.CoefficientOfDetermination(garlicBreadMay, estimated), 6); }
public async Task <IActionResult> EditPrediction(PredictionViewModel model) { Prediction edited = new Prediction { PredictionId = model.PredictionId, Odds = model.Odds, Chance = model.Chance, MatchId = model.MatchId, TipId = model.TipId }; await predictionRepository.EditPredictionAsync(edited); return(await CreateViewModel()); }
private static void SetMlDisplayPredictionData(PredictionViewModel displayModel, SaleDataInputModel inputModel) { var uri = Properties.Settings.Default.Uri; var key = Properties.Settings.Default.Key; var client = new SalesDemandService(uri, key); var estimatedSales = new List <double>(); double[] garlicBreadMay = new double[] { 3, 3, 2, 2, 0, 0, 0 }; var tempDate = inputModel.StartDate; while (tempDate <= inputModel.EndDate) { var data = new Dictionary <string, string>() { { "Locationid", "69" }, { "RecipeName", "" }, { "PLU", inputModel.PLU }, // "2549"}, { "Salesdate", tempDate.ToString() }, { "Quantity", "1" }, { "NetSalesPrice", "1" }, { "CostPrice", "1" }, { "Year", tempDate.Year.ToString() }, { "Month", tempDate.Month.ToString() }, { "Day", tempDate.Day.ToString() }, { "WeekDay", "1" }, { "YearDay", "1" } }; var task = client.GetPrediction1(data); task.Wait(); var predictionResult = GetScoredLabelsValue(task.Result); estimatedSales.Add(predictionResult); tempDate = tempDate.AddDays(1); } displayModel.MeanAbsoluteError = MLMathFormulas.MeanAbsoluteError(garlicBreadMay, estimatedSales.ToArray()); displayModel.MeanSquaredError = MLMathFormulas.MeanSquaredError(garlicBreadMay, estimatedSales.ToArray()); var coeff = MLMathFormulas.CoefficientOfDetermination(garlicBreadMay, estimatedSales.ToArray()); displayModel.CoefficientOfDetermination = //coeff > 0 //? Math.Round(coeff, 6) //: estimatedSales.First(); }
public async Task <IActionResult> EditPrediction(int PredictionId) { Prediction p = await predictionRepository.GetPredictionByIdAsync(PredictionId); PredictionViewModel predictionViewModel = new PredictionViewModel() { PredictionId = p.PredictionId, Odds = p.Odds, Chance = p.Chance, MatchId = p.MatchId, TipId = p.TipId, Matches = await matchRepository.GetMatches(), Tips = await tipRepository.GetTips(), Roles = await accountRepository.GetRoles() }; return(View("Prediction", predictionViewModel)); }
public IActionResult Prediction(PredictionViewModel data) { var input = new PredictionViewModel { Dept = data.Dept, StaffID = data.StaffID, Date = data.Date, Day = data.Day, Event = data.Event, Session = data.Session, Weather = data.Weather, PotentialDay = data.PotentialDay, jobSatisfaction = data.jobSatisfaction, }; PredictionServices ps = new PredictionServices(); TempData["result"] = ps.ServiceCall(input); return(RedirectToAction("Result")); }
public IActionResult Details(int id) { try { DetailsViewModel vm = new DetailsViewModel(); vm.Competition = repo.GetCompetition(id); vm.Drivers = repo.GetDrivers(); ViewBag.Reactions = repo.GetReactions(id); if (vm.Competition.Date < DateTime.Now) { vm.Results = repo.GetResultsFromRace(vm.Competition.ID); } ViewBag.CompetitionData = vm; PredictionViewModel p = new PredictionViewModel(); return(View(p)); } catch (Exception) { return(View("Error")); } }
static async Task <string> InvokeRequestResponseService(PredictionViewModel user) { using (var client = new HttpClient()) { var scoreRequest = new { Inputs = new Dictionary <string, List <Dictionary <string, string> > >() { { "input1", new List <Dictionary <string, string> >() { new Dictionary <string, string>() { { "Staff ID", user.StaffID.ToString() }, { "Dept ID", user.Dept.ToString() }, { "Date", user.Date.ToString("yyyy-MM-dd") }, { "Day", user.Date.ToString("ddd") }, { "Event", user.Event.ToString() }, { "Potential Days", user.PotentialDay.ToString() }, { "Session", user.Session.ToString() }, { "Weather", user.Weather.ToString() }, { "jobSatisfaction", user.jobSatisfaction.ToString() }, } } }, }, GlobalParameters = new Dictionary <string, string>() { } }; const string apiKey = "+8aJ+VW/gC5ImiZn+Uk0JhUM7YOiHGOSF5PPs2s6EILGXCnu+9Hn2h+SupdFyh/2HHPtef8Q2mS3RkamxZwFig=="; // Replace this with the API key for the web service client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); client.BaseAddress = new Uri("https://ussouthcentral.services.azureml.net/workspaces/dbc7a4587f874d97886dab4e20cfc6dc/services/cb43f8aef93c43629a153e275af1e559/execute?api-version=2.0&format=swagger"); HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest); if (response.IsSuccessStatusCode) { string result = await response.Content.ReadAsStringAsync(); dynamic stuff = JObject.Parse(result); var r = stuff.Results.output1[0]["Scored Labels"]; string apiresult = r.ToString(); return(apiresult); } else { // Console.WriteLine(string.Format("The request failed with status code: {0}", response.StatusCode)); string responseContent = await response.Content.ReadAsStringAsync(); return(responseContent); } } }
////////////// public string ServiceCall(PredictionViewModel user) { string r = InvokeRequestResponseService(user).Result; return(r); }
public PredictionTask(PredictionViewModel predictionViewModel) : base("Prediction") { _predictionViewModel = predictionViewModel; }
public PredictionViewModel GetPrediction(string symbol, int daysInFuture, double?volatility = null) { PredictionViewModel r = _predictionOrchestrator.GetPrediction(symbol, daysInFuture, volatility); return(r); }
public IActionResult Prediction() { PredictionViewModel predictionViewModel = new PredictionViewModel(); List <string> alist = new List <string>(); List <string> blist = new List <string>(); List <string> clist = new List <string>(); List <string> dlist = new List <string>(); List <string> elist = new List <string>(); string a1 = "Greetings, I hope you are well. "; string a2 = "Salutations. A great day, isn't it? "; string a3 = "Ah, what a nice day to say, 'Hello'. "; alist.Add(a1); alist.Add(a2); alist.Add(a3); string b1 = "Today, let's focus on love. "; string b2 = "Today, let's think about money. "; string b3 = "Today, let's pense on emotions. "; blist.Add(b1); blist.Add(b2); blist.Add(b3); string c1 = "Things are looking good in that department. "; string c2 = "Things are looking not so hot in that department. "; string c3 = "Things are so/so in that regard. "; clist.Add(c1); clist.Add(c2); clist.Add(c3); string d1 = "Keep trying to put effort in that direction. "; string d2 = "If you give up, it will get worse. "; string d3 = "You may ask for help, but do not quit. "; dlist.Add(d1); dlist.Add(d2); dlist.Add(d3); string e1 = "Remember, all things can change. "; string e2 = "Remember, some things are always like that. "; string e3 = "Remember, whatever happens-- there you are. "; elist.Add(e1); elist.Add(e2); elist.Add(e3); StringBuilder Horoscope = new StringBuilder(); Random random = new Random(); int apart = random.Next(0, 3); int bpart = random.Next(0, 3); int cpart = random.Next(0, 3); int dpart = random.Next(0, 3); int epart = random.Next(0, 3); Horoscope.Append(alist[apart]); Horoscope.Append(blist[bpart]); Horoscope.Append(clist[cpart]); Horoscope.Append(dlist[dpart]); Horoscope.Append(elist[epart]); string Today = Horoscope.ToString(); predictionViewModel.Prediction = Today; return(View(predictionViewModel)); }