Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/09 10:46:56 (15 years ago)
Author:
gkronber
Message:
  • Renamed VariableImpactCalculator to VariableQualityImpactCalculator and calculate the ratio of new quality value to old quality value to get an idea how the quality value is influenced by each variable.
  • Changes in Dataset to improve the speed of SetValue (only set a dirty flag instead of reallocating the caches)

#644 (Variable impact of CEDMA models should be calculated and stored in the result DB)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs

    r2012 r2038  
    3939    private double[] scalingFactor;
    4040    private double[] scalingOffset;
     41    private bool cachedValuesInvalidated = true;
     42
     43    private bool fireChangeEvents = true;
     44    public bool FireChangeEvents {
     45      get { return fireChangeEvents; }
     46      set { fireChangeEvents = value; }
     47    }
    4148
    4249    public string Name {
     
    7481      if (v != samples[columns * i + j]) {
    7582        samples[columns * i + j] = v;
    76         CreateDictionaries();
    77         FireChanged();
     83        cachedValuesInvalidated = true;
     84        if (fireChangeEvents) FireChanged();
    7885      }
    7986    }
     
    8996        }
    9097        samples = value;
    91         CreateDictionaries();
    92         FireChanged();
     98        cachedValuesInvalidated = true;
     99        if (fireChangeEvents) FireChanged();
    93100      }
    94101    }
     
    104111      scalingOffset = new double[] { 0.0 };
    105112      scalingFactor = new double[] { 1.0 };
    106     }
    107 
    108     private void CreateDictionaries() {
    109       // keep a means and ranges dictionary for each column (possible target variable) of the dataset.
    110       cachedMeans = new Dictionary<int, Dictionary<int, double>>[columns];
    111       cachedRanges = new Dictionary<int, Dictionary<int, double>>[columns];
    112       for (int i = 0; i < columns; i++) {
    113         cachedMeans[i] = new Dictionary<int, Dictionary<int, double>>();
    114         cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>();
    115       }
     113      cachedValuesInvalidated = true;
     114      fireChangeEvents = true;
    116115    }
    117116
     
    206205        }
    207206      }
    208       CreateDictionaries();
    209207    }
    210208
     
    270268
    271269    public double GetMean(int column, int from, int to) {
     270      if (cachedValuesInvalidated) CreateDictionaries();
    272271      if (!cachedMeans[column].ContainsKey(from) || !cachedMeans[column][from].ContainsKey(to)) {
    273272        double[] values = new double[to - from];
     
    289288
    290289    public double GetRange(int column, int from, int to) {
     290      if (cachedValuesInvalidated) CreateDictionaries();
    291291      if (!cachedRanges[column].ContainsKey(from) || !cachedRanges[column][from].ContainsKey(to)) {
    292292        double[] values = new double[to - from];
     
    329329        else ScaleVariable(column, 1.0 / range, -min);
    330330      }
    331       CreateDictionaries();
    332       FireChanged();
     331      cachedValuesInvalidated = true;
     332      if (fireChangeEvents) FireChanged();
    333333    }
    334334
     
    340340        samples[i * columns + column] = (origValue + offset) * factor;
    341341      }
    342       CreateDictionaries();
    343       FireChanged();
     342      cachedValuesInvalidated = true;
     343      if (fireChangeEvents) FireChanged();
    344344    }
    345345
     
    353353        scalingOffset[column] = 0.0;
    354354      }
     355      cachedValuesInvalidated = true;
     356      if (fireChangeEvents) FireChanged();
     357    }
     358
     359    private void CreateDictionaries() {
     360      // keep a means and ranges dictionary for each column (possible target variable) of the dataset.
     361      cachedMeans = new Dictionary<int, Dictionary<int, double>>[columns];
     362      cachedRanges = new Dictionary<int, Dictionary<int, double>>[columns];
     363      for (int i = 0; i < columns; i++) {
     364        cachedMeans[i] = new Dictionary<int, Dictionary<int, double>>();
     365        cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>();
     366      }
    355367    }
    356368  }
Note: See TracChangeset for help on using the changeset viewer.