private void OnDeleteColumn(object parameter)
        {
            if (parameter is DataGrid dataGrid && SelectedColumnIndex >= 0 && ColumnsDictionary.Any())
            {
                foreach (var cleanDataItem in CleanDataItems)
                {
                    cleanDataItem.Data.Remove(ColumnsDictionary.ElementAt(SelectedColumnIndex).Key);
                }
                dataGrid.Columns.Remove(dataGrid.Columns.FirstOrDefault(x =>
                                                                        string.Equals(x.Header.ToString(), ColumnsDictionary.ElementAt(SelectedColumnIndex).Value, StringComparison.OrdinalIgnoreCase)));
                ColumnsDictionary.Remove(ColumnsDictionary.ElementAt(SelectedColumnIndex).Key);

                ColumnsDictionary = new Dictionary <int, string>(ColumnsDictionary);
            }
        }
        private void OnVisualiseColumnn()
        {
            if (SelectedVisualisationColumnIndex >= 0 && ColumnsDictionary.Any())
            {
                try
                {
                    SelectedColumnItemsCount = new ObservableCollection <KeyValuePair <string, int> >();
                    var selectedColumnKey   = ColumnsDictionary.ElementAt(SelectedVisualisationColumnIndex).Key;
                    var visualiseColumnData = CleanDataItems.SelectMany(x => x.Data).Where(c => c.Key == selectedColumnKey);

                    foreach (var visualColumnData in visualiseColumnData.Select(x => x.Value).Distinct())
                    {
                        Application.Current.Dispatcher.Invoke(() => SelectedColumnItemsCount.Add(new KeyValuePair <string, int>(visualColumnData,
                                                                                                                                visualiseColumnData.Select(x => x).Where(c => string.Equals(c.Value, visualColumnData, StringComparison.OrdinalIgnoreCase)).Count())));
                    }
                }
                catch (Exception ex)
                {
                    _exceptionLogDataAccess.LogException(ex.ToString());
                }
            }
        }
        private void OnShowPredictions(object parameter)
        {
            lock (_lockPredictionValuesObject)
            {
                if (parameter is DataGrid dataGrid && SelectedPredictionColumnIndex >= 0 && ColumnsDictionary.Any())
                {
                    PredictionValues = new List <Dictionary <int, string> >();
                    var selectedPredictionColumnKey = ColumnsDictionary.ElementAt(SelectedPredictionColumnIndex).Key;
                    var distinctPredicitonValues    = CleanDataItems.SelectMany(x => x.Data.Where(z => z.Key == selectedPredictionColumnKey))
                                                      .Select(c => c.Value).Distinct();

                    foreach (var prediction in distinctPredicitonValues)
                    {
                        var columns = new Dictionary <int, string>();

                        for (var colIndex = 0; colIndex < ColumnsDictionary.Count; colIndex++)
                        {
                            var keyValuePairs = CleanDataItems.Select(x => x.Data).Where(c => c.Values.Contains(prediction));

                            var allPredictionsForColumn = keyValuePairs.SelectMany(x => x).Where(c => c.Key == ColumnsDictionary.ElementAt(colIndex).Key)
                                                          .GroupBy(z => z.Value)
                                                          .OrderByDescending(v => v.Count()).FirstOrDefault();

                            if (allPredictionsForColumn != null)
                            {
                                foreach (var c in allPredictionsForColumn)
                                {
                                    columns.Add(ColumnsDictionary.ElementAt(colIndex).Key, c.Value);
                                    break;
                                }
                            }
                        }
                        PredictionValues.Add(columns);
                    }

                    Application.Current.Dispatcher.Invoke(() => dataGrid.ItemsSource = PredictionValues);
                    Application.Current.Dispatcher.Invoke(() => dataGrid.Columns.Clear());
                    var colCount = 0;
                    foreach (var prediction in ColumnsDictionary)
                    {
                        Application.Current.Dispatcher.Invoke(() => dataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header       = prediction.Value,
                            Binding      = new Binding($".[{prediction.Key}]"),
                            DisplayIndex = colCount
                        }));

                        colCount++;
                    }
                }
            }
        }