Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10159


Ignore:
Timestamp:
11/27/13 15:20:12 (10 years ago)
Author:
rstoll
Message:

Switched from IDataset to IPreprocessingData

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/DataSetStatisticInfo.cs

    r10148 r10159  
    11using System;
    2 using System.Linq;
    3 using HeuristicLab.Problems.DataAnalysis;
     2using HeuristicLab.DataPreprocessing.Interfaces;
    43
    54namespace HeuristicLab.DataPreprocessing {
    65  class DatasetStatisticInfo : IDatasetStatisticInfo {
    76
    8     private IDataset dataSet;
     7    private IPreprocessingData preprocessingData;
    98
    10     public DatasetStatisticInfo(IDataset theDataSet) {
    11       dataSet = theDataSet;
     9    public DatasetStatisticInfo(IPreprocessingData theDataSet) {
     10      preprocessingData = theDataSet;
    1211    }
    1312
    1413
    1514    public int GetColumnCount() {
    16       return dataSet.Columns;
     15      return preprocessingData.Columns;
    1716    }
    1817
    1918    public int GetRowCount() {
    20       return dataSet.Rows;
     19      return preprocessingData.Rows;
    2120    }
    2221
    2322    public int GetNumericColumnCount() {
    24       return dataSet.DoubleVariables.Count();
     23      int count = 0;
     24      for (int i = 0; i < preprocessingData.Columns; ++i) {
     25        if (preprocessingData.IsType<double>(i)) {
     26          ++count;
     27        }
     28      }
     29      return count;
    2530    }
    2631
    2732    public int GetNominalColumnCount() {
    28       return dataSet.Columns - GetNumericColumnCount();
     33      return preprocessingData.Columns - GetNumericColumnCount();
    2934    }
    3035
    3136    public int GetMissingValueCount() {
    3237      int count = 0;
    33       for (int i = 0; i < dataSet.Columns; ++i) {
     38      for (int i = 0; i < preprocessingData.Columns; ++i) {
    3439        count += GetMissingValueCount(i);
    3540      }
     
    3843
    3944    public int GetMissingValueCount(int columnIndex) {
    40       Func<string, bool> isMissingValueFunc;
    41       if (dataSet.IsType<double>(columnIndex)) {
    42         isMissingValueFunc = IsMissingDoubleValue;
    43       } else if (dataSet.IsType<string>(columnIndex)) {
    44         isMissingValueFunc = IsMissingStringValue;
    45       } else if (dataSet.IsType<DateTime>(columnIndex)) {
    46         isMissingValueFunc = isMissingDateTimeValue;
    47       } else {
    48         throw new ArgumentException("column with index: " + columnIndex + " contains a non supported type.");
    49       }
     45      throw new System.NotImplementedException();
     46      //Func<dynamic, bool> isMissingValueFunc;
     47      //if (preprocessingData.IsType<double>(columnIndex)) {
     48      //  isMissingValueFunc = IsMissingDoubleValue;
     49      //} else if (preprocessingData.IsType<string>(columnIndex)) {
     50      //  isMissingValueFunc = IsMissingStringValue;
     51      //} else if (preprocessingData.IsType<DateTime>(columnIndex)) {
     52      //  isMissingValueFunc = isMissingDateTimeValue;
     53      //} else {
     54      //  throw new ArgumentException("column with index: " + columnIndex + " contains a non supported type.");
     55      //}
    5056
    51       int count = 0;
    52       for (int i = 0; i < dataSet.Rows; ++i) {
    53         if (isMissingValueFunc(dataSet.GetValue(i, columnIndex))) {
    54           ++count;
    55         }
    56       }
    57       return count;
     57      //int count = 0;
     58      //for (int i = 0; i < preprocessingData.Rows; ++i) {
     59      //  if (isMissingValueFunc(preprocessingData.GetCell(i, columnIndex))) {
     60      //    ++count;
     61      //  }
     62      //}
     63      //return count;
    5864    }
    5965
     
    7581
    7682    public T GetMin<T>(int columnIndex) where T : IComparable<T> {
    77       if (!dataSet.IsType<double>(columnIndex)) {
     83      if (!preprocessingData.IsType<double>(columnIndex)) {
    7884        throw new ArgumentException("column with index: " + columnIndex + " was assumed to be of type " + typeof(T).Name + " but was different.");
    7985      }
     
    8894
    8995    public T GetMax<T>(int columnIndex) where T : IComparable<T> {
    90       if (!dataSet.IsType<double>(columnIndex)) {
     96      if (!preprocessingData.IsType<double>(columnIndex)) {
    9197        throw new ArgumentException("column with index: " + columnIndex + " was assumed to be of type " + typeof(T).Name + " but was different.");
    9298      }
     
    101107
    102108    private T GetMin<T>(int columnIndex, T max, Func<string, bool> isMissingValueFunc, Func<string, T> parseFunc) where T : IComparable<T> {
    103       T min = max;
    104       for (int i = 0; i < dataSet.Rows; ++i) {
    105         var value = dataSet.GetValue(i, columnIndex);
    106         if (!isMissingValueFunc(value)) {
    107           T parsedValue = parseFunc(value);
    108           if (parsedValue.CompareTo(min) < 0) {
    109             min = parsedValue;
    110           }
    111         }
    112       }
    113       return min;
     109      throw new System.NotImplementedException();
     110      //T min = max;
     111      //for (int i = 0; i < preprocessingData.Rows; ++i) {
     112      //  var value = preprocessingData.GetValue(i, columnIndex);
     113      //  if (!isMissingValueFunc(value)) {
     114      //    T parsedValue = parseFunc(value);
     115      //    if (parsedValue.CompareTo(min) < 0) {
     116      //      min = parsedValue;
     117      //    }
     118      //  }
     119      //}
     120      //return min;
    114121    }
    115122
    116123    private T GetMax<T>(int columnIndex, T min, Func<string, bool> isMissingValueFunc, Func<string, T> parseFunc) where T : IComparable<T> {
    117       T max = min;
    118       for (int i = 0; i < dataSet.Rows; ++i) {
    119         var value = dataSet.GetValue(i, columnIndex);
    120         if (!isMissingValueFunc(value)) {
    121           T parsedValue = parseFunc(value);
    122           if (parsedValue.CompareTo(min) > 0) {
    123             max = parsedValue;
    124           }
    125         }
    126       }
    127       return max;
     124      throw new System.NotImplementedException();
     125      //T max = min;
     126      //for (int i = 0; i < preprocessingData.Rows; ++i) {
     127      //  var value = preprocessingData.GetValue(i, columnIndex);
     128      //  if (!isMissingValueFunc(value)) {
     129      //    T parsedValue = parseFunc(value);
     130      //    if (parsedValue.CompareTo(min) > 0) {
     131      //      max = parsedValue;
     132      //    }
     133      //  }
     134      //}
     135      //return max;
    128136    }
    129137
    130138
    131139
    132    
     140
    133141
    134142    public double GetMedian(int columnIndex) {
     
    141149
    142150    public double GetMostCommonValue(int columnIndex) {
    143       throw new System.NotImplementedException();
     151      double result = 0;
     152      for (int i = 0; i < preprocessingData.Rows; ++i) {
     153
     154      }
     155      return result;
    144156    }
    145157
    146     public double GeStandardDeviation(int columnIndex) {
     158    public double GetStandardDeviation(int columnIndex) {
    147159      throw new System.NotImplementedException();
    148160    }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10157 r10159  
    8686    <Compile Include="EditableDataset.cs" />
    8787    <Compile Include="DataSetStatisticInfo.cs" />
    88     <Compile Include="IDataSetStatisticInfo.cs" />
     88    <Compile Include="Interfaces\IDataSetStatisticInfo.cs" />
    8989    <Compile Include="Interfaces\IPreprocessingData.cs" />
    9090    <Compile Include="Plugin.cs" />
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataSetStatisticInfo.cs

    r10158 r10159  
    1515    double GetAverage(int columnNumber);
    1616    double GetMostCommonValue(int columnNumber);
    17     double GeStandardDeviation(int columnNumber);
     17    double GetStandardDeviation(int columnNumber);
    1818  }
    1919}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs

    r10158 r10159  
    4040    IList<string> VariableNames { get; }
    4141    bool IsType<T>(int columnIndex);
     42
     43    int Columns { get; }
     44    int Rows { get; }
    4245  }
    4346}
Note: See TracChangeset for help on using the changeset viewer.