public Example numerize(Hashtable attrValueToNumber) { Hashtable numerizedExampleData = new Hashtable(); foreach (string key in attributes.Keys) { Attribute attribute = (Attribute)attributes[key]; if (attribute is StringAttribute) { int correspondingNumber = int.Parse(((Hashtable)(attrValueToNumber[key]))[attribute.valueAsString()].ToString()); NumericAttributeSpecification spec = new NumericAttributeSpecification(key); if (numerizedExampleData.Contains(key)) { numerizedExampleData[key] = new NumericAttribute((double)correspondingNumber, spec); } else { numerizedExampleData.Add(key, new NumericAttribute((double)correspondingNumber, spec)); } } else { //Numeric Attribute if (numerizedExampleData.Contains(key)) { numerizedExampleData[key] = attribute; } else { numerizedExampleData.Add(key, attribute); } } } return(new Example(numerizedExampleData, (Attribute)numerizedExampleData[targetAttribute.name()])); }
public Example numerize(Hashtable attrValueToNumber) { Hashtable numerizedExampleData = new Hashtable(); foreach (string key in attributes.Keys) { Attribute attribute = (Attribute)attributes[key]; if ( attribute is StringAttribute) { int correspondingNumber = int.Parse(((Hashtable)(attrValueToNumber[key]))[attribute.valueAsString()].ToString()); NumericAttributeSpecification spec = new NumericAttributeSpecification(key); if (numerizedExampleData.Contains(key)) numerizedExampleData[key] = new NumericAttribute((double)correspondingNumber,spec); else numerizedExampleData.Add(key,new NumericAttribute((double)correspondingNumber,spec)); } else {//Numeric Attribute if (numerizedExampleData.Contains(key)) numerizedExampleData[key] = attribute; else numerizedExampleData.Add(key,attribute); } } return new Example(numerizedExampleData,(Attribute)numerizedExampleData[targetAttribute.name()]); }