/// <summary> /// Task 2.7 /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task ReducedAnalysisDataDependentsAndTypeOfEvent(TypeEvents type) { //var firstTypeEvent = (TypeEvent)type; //var typeEventValues = Enum.GetValues(typeof(TypeEvent)) // .Cast<TypeEvent>() // .Where(x => x != firstTypeEvent); //var dbData = await _context // .Employee // .Include(x => x.EventEmployees) // .ThenInclude(x => x.IdEventNavigation) // .Include(x => x.Children) // .Include(x => x.GrandChildren) // .Select(x => new DeterminingPrincipalComponentModel // { // X1 = x.EventEmployees.Count(c => c.IdEventNavigation.Type == firstTypeEvent), // X2 = x.EventEmployees.Count(c => c.IdEventNavigation.Type == typeEventValues.ElementAt(0)), // X3 = x.EventEmployees.Count(c => c.IdEventNavigation.Type == typeEventValues.ElementAt(1)), // X4 = x.Children.Count, // X5 = x.GrandChildren.Count // }) // .ToListAsync(); //var apiData = _determiningService.PrincipalComponentAnalysis(dbData, 2).ToList(); }
/// <summary> /// Task 2.4 - 2.6 /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task RegressionModelInfluenceDependentsAndTypeOfEvent(TypeEvents type) { //var firstTypeEvent = (TypeEvent)type; //var typeEventValues = Enum.GetValues(typeof(TypeEvent)) // .Cast<TypeEvent>() // .Where(x => x != firstTypeEvent); //var dbData = await _context // .Employee // .Include(x => x.EventEmployees) // .ThenInclude(x => x.IdEventNavigation) // .Include(x => x.AwardEmployees) // .Include(x => x.MaterialAidEmployees) // .Include(x => x.Children) // .Include(x => x.GrandChildren) // .Select(x => new DeterminingMultiFactorModel // { // Y = x.EventEmployees.Count(c => c.IdEventNavigation.Type == firstTypeEvent), // X1 = x.EventEmployees.Count(c => c.IdEventNavigation.Type == typeEventValues.ElementAt(0)), // X2 = x.EventEmployees.Count(c => c.IdEventNavigation.Type == typeEventValues.ElementAt(1)), // X3 = x.AwardEmployees.Count, // X4 = x.MaterialAidEmployees.Count, // X5 = x.Children.Count, // X6 = x.GrandChildren.Count // }) // .ToListAsync(); //var apiData = _determiningService.MultiFactorModel(dbData); }
/// <summary> /// Task 2.2 /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task <ChartResult <IEnumerable <BubbleChart <Bubble> > > > ClusterAnalysisSignHavingChildrenAndTypeOfEvent(TypeEvents type) { //var dbData = await _context // .Employee // .Include(x => x.EventEmployees) // .ThenInclude(x => x.IdEventNavigation) // .Include(x => x.Children) // .Select(x => new ForecastingClusterModel // { // X = x.EventEmployees.Count(c => c.IdEventNavigation.Type == (TypeEvent)type), // Y = x.Children.Count // }) // .ToListAsync(); //const int countClusters = 3; //var apiData = _forecastingService.ClusterAnalysis(dbData, countClusters); //var clusterColors = GetRandomBubbleColors(countClusters * 2).ToList(); //var result = new List<BubbleChart<Bubble>>(); //for (var i = 0; i < countClusters; i++) //{ // var x = apiData.X.ElementAt(i).ToList(); // var y = apiData.Y.ElementAt(i); // result.Add(new BubbleChart<Bubble> // { // Label = $"{x.Min()}-{x.Max()}", // BackgroundColor = clusterColors.ElementAt(i), // BorderColor = clusterColors.ElementAt(i + 2), // Data = x.Zip(y, (a, b) => new Bubble { X = a, Y = b, R = 4 }) // }); //} //return new ChartResult<IEnumerable<BubbleChart<Bubble>>> { Chart = result }; return(new ChartResult <IEnumerable <BubbleChart <Bubble> > > { Chart = null }); }
/// <summary> /// Task 2.1 /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task <ChartResult <BarChart <double> > > MultiCorrelationBetweenTypeOfEventAndDependents(TypeEvents type) { //var dbData = await _context // .Employee // .Include(x => x.EventEmployees) // .ThenInclude(x => x.IdEventNavigation) // .Include(x => x.Children) // .Include(x => x.GrandChildren) // .Select(x => new DeterminingMultiCorrelationModel // { // Y = x.EventEmployees.Count(c => c.IdEventNavigation.Type == (TypeEvent)type), // X1 = x.Children.Count, // X2 = x.GrandChildren.Count // }) // .ToListAsync(); //var apiData = _determiningService.MultiCorrelationCoefficient(dbData); //return new ChartResult<BarChart<double>> //{ // Chart = new BarChart<double> // { // Data = new List<double> { apiData }, // Labels = new List<string> { "Multi correlation coefficient" } // } //}; return(null); }
/// <summary> /// Task 2.1 /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task <ChartResult <BarChart <double> > > MultiCorrelationBetweenTypeOfEventAndDependents(TypeEvents type) { var dbData = await _context .Employee .Include(x => x.EventEmployees) .ThenInclude(x => x.IdEventNavigation) .Include(x => x.Children) .Include(x => x.GrandChildren) .Select(x => new DeterminingMultiCorrelationModel { Y = x.EventEmployees.Count(c => c.IdEventNavigation.Type == (TypeEvent)type), X1 = x.Children.Count, X2 = x.GrandChildren.Count }) .ToListAsync(); var apiData = await _determiningService.MultiCorrelationCoefficient(dbData); return(new ChartResult <BarChart <double> > { Chart = new BarChart <double> { Data = new List <double> { apiData }, Labels = new List <string> { "Multi correlation coefficient" } } }); }
/// <summary> /// Task 1.3 /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task <ChartResult <IEnumerable <BubbleChart <Bubble> > > > ClusterAnalysisAgeTeacherAndTypeOfEvent(TypeEvents type) { try { var dbData = await _context .Employee .Include(x => x.EventEmployees) .ThenInclude(x => x.IdEventNavigation) .Select(x => new ForecastingClusterModel { X = x.BirthDate.CalculateAge(), Y = x.EventEmployees.Count(c => c.IdEventNavigation.Type == (TypeEvent)type), }) .ToListAsync(); const int countClusters = 6; var apiData = await _forecastingService.ClusterAnalysis(dbData, countClusters); var clusterColors = GetRandomBubbleColors(countClusters * 2).ToList(); var result = new List <BubbleChart <Bubble> >(); for (var i = 0; i < countClusters; i++) { var x = apiData.X.ElementAt(i).ToList(); var y = apiData.Y.ElementAt(i); result.Add(new BubbleChart <Bubble> { Label = $"{x.Min()}-{x.Max()}", BackgroundColor = clusterColors.ElementAt(i), BorderColor = clusterColors.ElementAt(i + 2), Data = x.Zip(y, (a, b) => new Bubble { X = a, Y = b, R = 4 }) }); } return(new ChartResult <IEnumerable <BubbleChart <Bubble> > > { Chart = result }); } catch (Exception exception) { Console.WriteLine(exception); throw; } }