Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1426 for trunk/sources


Ignore:
Timestamp:
03/26/09 11:02:09 (15 years ago)
Author:
gkronber
Message:

Implemented mapping from categorical values to double values. Ordering can't be changed and is more or less random. #544 (Values of categorical model attributes are not visualized correctly in the CEDMA bubble chart)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Core/Results.cs

    r1424 r1426  
    6565      }
    6666    }
     67
     68    private Dictionary<string, Dictionary<object, double>> categoricalValueIndices = new Dictionary<string, Dictionary<object, double>>();
    6769
    6870    private Entity dataSetEntity;
     
    139141
    140142    public double IndexOfCategoricalValue(string variable, object value) {
    141       return 1.0; // TODO
     143      if (value == null) return double.NaN;
     144      Dictionary<object, double> valueToIndexMap;
     145      if (categoricalValueIndices.ContainsKey(variable)) {
     146        valueToIndexMap = categoricalValueIndices[variable];
     147      } else {
     148        valueToIndexMap = new Dictionary<object, double>();
     149        categoricalValueIndices[variable] = valueToIndexMap;
     150      }
     151      if (!valueToIndexMap.ContainsKey(value)) {
     152        if (valueToIndexMap.Values.Count == 0) valueToIndexMap[value] = 1.0;
     153        else valueToIndexMap[value] = 1.0 + valueToIndexMap.Values.Max();
     154      }
     155      return valueToIndexMap[value];
    142156    }
    143157  }
Note: See TracChangeset for help on using the changeset viewer.