Ejemplo n.º 1
0
        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()]));
        }
Ejemplo n.º 2
0
		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()]);
		}