- Timestamp:
- 07/18/17 14:19:29 (7 years ago)
- Location:
- branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Content/DataCompletenessChartContent.cs
r15110 r15269 32 32 } 33 33 34 public SearchLogic SearchLogic{ get; private set; }34 public ITransactionalPreprocessingData PreprocessingData { get; private set; } 35 35 36 public DataCompletenessChartContent( SearchLogic searchLogic) {37 SearchLogic = searchLogic;36 public DataCompletenessChartContent(ITransactionalPreprocessingData preprocessingData) { 37 PreprocessingData = preprocessingData; 38 38 } 39 39 40 40 public DataCompletenessChartContent(DataCompletenessChartContent content, Cloner cloner) 41 41 : base(content, cloner) { 42 SearchLogic = content.SearchLogic;42 PreprocessingData = content.PreprocessingData; 43 43 } 44 44 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Content/ManipulationContent.cs
r15110 r15269 33 33 34 34 public ManipulationLogic ManipulationLogic { get; private set; } 35 public SearchLogic SearchLogic { get; private set; }36 35 public FilterLogic FilterLogic { get; private set; } 37 36 38 public ManipulationContent(ManipulationLogic manipulationLogic, SearchLogic searchLogic,FilterLogic filterLogic) {37 public ManipulationContent(ManipulationLogic manipulationLogic, FilterLogic filterLogic) { 39 38 ManipulationLogic = manipulationLogic; 40 SearchLogic = searchLogic;41 39 FilterLogic = filterLogic; 42 40 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs
r15110 r15269 28 28 29 29 namespace HeuristicLab.DataPreprocessing { 30 public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {30 public sealed class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData { 31 31 private readonly ITransactionalPreprocessingData originalData; 32 32 private ITransactionalPreprocessingData filteredData; … … 83 83 } 84 84 85 pr otectedFilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner)85 private FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner) 86 86 : base(original, cloner) { 87 87 originalData = original.originalData; … … 90 90 public override IDeepCloneable Clone(Cloner cloner) { 91 91 return new FilteredPreprocessingData(this, cloner); 92 } 93 94 public bool IsCellEmpty(int columnIndex, int rowIndex) { 95 return ActiveData.IsCellEmpty(columnIndex, rowIndex); 92 96 } 93 97 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs
r15110 r15269 28 28 namespace HeuristicLab.DataPreprocessing { 29 29 public interface IPreprocessingData : INamedItem { 30 bool IsCellEmpty(int columnIndex, int rowIndex); 30 31 T GetCell<T>(int columnIndex, int rowIndex); 31 32 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs
r15110 r15269 160 160 } 161 161 162 public static bool IsMissingValue(object value) { 163 if (value is double) return double.IsNaN((double)value); 164 if (value is string) return string.IsNullOrEmpty((string)value); 165 if (value is DateTime) return ((DateTime)value).Equals(DateTime.MinValue); 166 throw new ArgumentException(); 167 } 162 168 163 169 #region IPreprocessingData Members 170 public abstract bool IsCellEmpty(int columnIndex, int rowIndex); 164 171 public abstract T GetCell<T>(int columnIndex, int rowIndex); 165 172 … … 173 180 174 181 public abstract bool VariableHasType<T>(int columnIndex); 175 176 [Obsolete("use the index based variant, is faster")]177 public abstract IList<T> GetValues<T>(string variableName, bool considerSelection);178 182 179 183 public abstract IList<T> GetValues<T>(int columnIndex, bool considerSelection); -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/TransactionalPreprocessingData.cs
r15110 r15269 88 88 89 89 #region Overridden IPreprocessingData Members 90 public override bool IsCellEmpty(int columnIndex, int rowIndex) { 91 var value = variableValues[columnIndex][rowIndex]; 92 return IsMissingValue(value); 93 } 94 90 95 public override T GetCell<T>(int columnIndex, int rowIndex) { 91 96 return (T)variableValues[columnIndex][rowIndex]; … … 119 124 public override bool VariableHasType<T>(int columnIndex) { 120 125 return columnIndex >= variableValues.Count || variableValues[columnIndex] is List<T>; 121 }122 123 [Obsolete("use the index based variant, is faster")]124 public override IList<T> GetValues<T>(string variableName, bool considerSelection) {125 return GetValues<T>(GetColumnIndex(variableName), considerSelection);126 126 } 127 127 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r15268 r15269 146 146 <Compile Include="PreprocessingContext.cs" /> 147 147 <Compile Include="Data\TransactionalPreprocessingData.cs" /> 148 <Compile Include="Logic\SearchLogic.cs" />149 148 <Compile Include="Logic\StatisticsLogic.cs" /> 150 149 <Compile Include="Data\ITransactionalPreprocessingData.cs" /> -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/FilterLogic.cs
r15110 r15269 73 73 } 74 74 75 p ublicbool Result(bool current, bool addition, bool isAndCombination) {75 private bool Result(bool current, bool addition, bool isAndCombination) { 76 76 return isAndCombination ? current || addition : current && addition; 77 77 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs
r15110 r15269 30 30 private readonly ITransactionalPreprocessingData preprocessingData; 31 31 private readonly StatisticsLogic statisticsLogic; 32 private readonly SearchLogic searchLogic;33 32 34 33 public IEnumerable<string> VariableNames { … … 40 39 } 41 40 42 public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, S earchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) {41 public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, StatisticsLogic theStatisticsLogic) { 43 42 this.preprocessingData = preprocessingData; 44 searchLogic = theSearchLogic;45 43 statisticsLogic = theStatisticsLogic; 46 44 } … … 187 185 private int indexOfPrevPresentValue(int columnIndex, int start) { 188 186 int offset = start - 1; 189 while (offset >= 0 && searchLogic.IsMissingValue(columnIndex, offset)) {187 while (offset >= 0 && preprocessingData.IsCellEmpty(columnIndex, offset)) { 190 188 offset--; 191 189 } … … 196 194 private int indexOfNextPresentValue(int columnIndex, int start) { 197 195 int offset = start + 1; 198 while (offset < preprocessingData.Rows && searchLogic.IsMissingValue(columnIndex, offset)) {196 while (offset < preprocessingData.Rows && preprocessingData.IsCellEmpty(columnIndex, offset)) { 199 197 offset++; 200 198 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/StatisticsLogic.cs
r15110 r15269 28 28 public class StatisticsLogic { 29 29 private readonly ITransactionalPreprocessingData preprocessingData; 30 private readonly SearchLogic searchLogic; 31 32 public StatisticsLogic(ITransactionalPreprocessingData thePreprocessingData, SearchLogic theSearchLogic) { 33 preprocessingData = thePreprocessingData; 34 searchLogic = theSearchLogic; 30 31 public StatisticsLogic(ITransactionalPreprocessingData preprocessingData) { 32 this.preprocessingData = preprocessingData; 35 33 } 36 34 37 35 public int GetColumnCount() { 38 return searchLogic.Columns;36 return preprocessingData.Columns; 39 37 } 40 38 41 39 public int GetRowCount() { 42 return searchLogic.Rows;40 return preprocessingData.Rows; 43 41 } 44 42 … … 46 44 int count = 0; 47 45 48 for (int i = 0; i < searchLogic.Columns; ++i) {46 for (int i = 0; i < preprocessingData.Columns; ++i) { 49 47 if (preprocessingData.VariableHasType<double>(i)) { 50 48 ++count; … … 55 53 56 54 public int GetNominalColumnCount() { 57 return searchLogic.Columns - GetNumericColumnCount();55 return preprocessingData.Columns - GetNumericColumnCount(); 58 56 } 59 57 60 58 public int GetMissingValueCount() { 61 59 int count = 0; 62 for (int i = 0; i < searchLogic.Columns; ++i) {60 for (int i = 0; i < preprocessingData.Columns; ++i) { 63 61 count += GetMissingValueCount(i); 64 62 } … … 67 65 68 66 public int GetMissingValueCount(int columnIndex) { 69 return searchLogic.GetMissingValueIndices(columnIndex).Count(); 67 return Enumerable.Range(0, preprocessingData.Rows).Count(rowIndex => preprocessingData.IsCellEmpty(columnIndex, rowIndex)); 68 } 69 70 public int GetRowMissingValueCount(int rowIndex) { 71 var columnIndexes = Enumerable.Range(0, preprocessingData.Columns); 72 return columnIndexes.Count(columnIndex => !preprocessingData.IsCellEmpty(columnIndex, rowIndex)); 73 } 74 75 private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection = false) { 76 return preprocessingData.GetValues<T>(columnIndex, considerSelection).Where(x => !PreprocessingData.IsMissingValue(x)).ToList(); 70 77 } 71 78 … … 185 192 } 186 193 187 public int GetRowMissingValueCount(int rowIndex) { 188 int count = 0; 189 for (int i = 0; i < preprocessingData.Columns; ++i) { 190 if (searchLogic.IsMissingValue(i, rowIndex)) { 191 ++count; 192 } 193 } 194 return count; 195 } 196 197 public string GetVariableName(int columnIndex) { 198 return preprocessingData.GetVariableName(columnIndex); 199 } 194 200 195 201 196 public bool VariableHasType<T>(int columnIndex) { … … 218 213 } 219 214 220 private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection = false) {221 return searchLogic.GetValuesWithoutNaN<T>(columnIndex, considerSelection);222 }223 215 224 216 private DateTime GetSecondsAsDateTime(double seconds) {
Note: See TracChangeset
for help on using the changeset viewer.