public void SetFilter(bool[] remainingRows)
        {
            filteredData = (IPreprocessingData)originalData.Clone();
            filteredData.InTransaction(() => {
                var remainingIndices = Enumerable.Range(0, remainingRows.Length).Where(x => remainingRows[x]);

                foreach (var v in filteredData.VariableNames)
                {
                    var ci = filteredData.GetColumnIndex(v);
                    if (filteredData.VariableHasType <double>(ci))
                    {
                        var values         = filteredData.GetValues <double>(ci);
                        var filteredValues = remainingIndices.Select(x => values[x]).ToList();
                        filteredData.SetValues(ci, filteredValues);
                    }
                    else if (filteredData.VariableHasType <DateTime>(ci))
                    {
                        var values         = filteredData.GetValues <DateTime>(ci);
                        var filteredValues = remainingIndices.Select(x => values[x]).ToList();
                        filteredData.SetValues(ci, filteredValues);
                    }
                    else if (filteredData.VariableHasType <string>(ci))
                    {
                        var values         = filteredData.GetValues <string>(ci);
                        var filteredValues = remainingIndices.Select(x => values[x]).ToList();
                        filteredData.SetValues(ci, filteredValues);
                    }
                }
            });
            OnFilterChanged();
        }
 public void PersistFilter()
 {
     originalData.InTransaction(() => {
         for (int i = 0; i < filteredData.Columns; ++i)
         {
             if (filteredData.VariableHasType <double>(i))
             {
                 originalData.SetValues <double>(i, filteredData.GetValues <double>(i));
             }
             else if (filteredData.VariableHasType <string>(i))
             {
                 originalData.SetValues <string>(i, filteredData.GetValues <string>(i));
             }
             else if (filteredData.VariableHasType <DateTime>(i))
             {
                 originalData.SetValues <DateTime>(i, filteredData.GetValues <DateTime>(i));
             }
             else
             {
                 throw new ArgumentException("Data types of columns do not match");
             }
         }
     });
     ResetFilter();
 }
        public static IEnumerable <string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData, int maxDistinctValues = 20)
        {
            var variableNames = new List <string>();

            for (int i = 0; i < preprocessingData.Columns; ++i)
            {
                int distinctValues = Int32.MaxValue;
                if (preprocessingData.VariableHasType <double>(i))
                {
                    distinctValues = preprocessingData.GetValues <double>(i).GroupBy(x => x).Count();
                }
                else if (preprocessingData.VariableHasType <string>(i))
                {
                    distinctValues = preprocessingData.GetValues <string>(i).GroupBy(x => x).Count();
                }
                else if (preprocessingData.VariableHasType <DateTime>(i))
                {
                    distinctValues = preprocessingData.GetValues <DateTime>(i).GroupBy(x => x).Count();
                }

                if (distinctValues <= maxDistinctValues)
                {
                    variableNames.Add(preprocessingData.GetVariableName(i));
                }
            }
            return(variableNames);
        }
 private void PreserveColumns(IEnumerable <Transformation <double> > transformations)
 {
     foreach (var transformation in transformations)
     {
         if (!originalColumns.ContainsKey(transformation.Column))
         {
             int colIndex     = preprocessingData.GetColumnIndex(transformation.Column);
             var originalData = preprocessingData.GetValues <double>(colIndex);
             originalColumns.Add(transformation.Column, originalData);
         }
     }
 }
 public IList <T> GetValues <T>(int columnIndex, bool considerSelection)
 {
     return(ActiveData.GetValues <T>(columnIndex, considerSelection));
 }