public Example numerize(IMap <string, IMap <string, int> > attrValueToNumber) { IMap <string, IAttribute> numerizedExampleData = CollectionFactory.CreateInsertionOrderedMap <string, IAttribute>(); foreach (string key in attributes.GetKeys()) { IAttribute attribute = attributes.Get(key); if (attribute is StringAttribute) { int correspondingNumber = attrValueToNumber.Get(key).Get(attribute.ValueAsString()); NumericAttributeSpecification spec = new NumericAttributeSpecification(key); numerizedExampleData.Put(key, new NumericAttribute(correspondingNumber, spec)); } else {// Numeric Attribute numerizedExampleData.Put(key, attribute); } } return(new Example(numerizedExampleData, numerizedExampleData.Get(targetAttribute.Name()))); }
public NumericAttribute(double rawValue, NumericAttributeSpecification spec) { this.value = rawValue; this.spec = spec; }