AIMA.Core.Learning.Framework.DataSet.calculateGainFor C# (CSharp) Method

calculateGainFor() public method

public calculateGainFor ( String parameterName ) : double
parameterName String
return double
        public double calculateGainFor(String parameterName)
        {
            Dictionary<String, DataSet> hash = splitByAttribute(parameterName);
            double totalSize = examples.Count;
            double remainder = 0.0;
            foreach (String parameterValue in hash.Keys)
            {
                double reducedDataSetSize = hash[parameterValue].examples
                        .Count;
                remainder += (reducedDataSetSize / totalSize)
                        * hash[parameterValue].getInformationFor();
            }
            return getInformationFor() - remainder;
        }

Usage Example

Ejemplo n.º 1
0
        private String chooseAttribute(DataSet ds, List<String> attributeNames)
        {
            double greatestGain = 0.0;
            String attributeWithGreatestGain = attributeNames[0];
            foreach (String attr in attributeNames)
            {
                double gain = ds.calculateGainFor(attr);
                if (gain > greatestGain)
                {
                    greatestGain = gain;
                    attributeWithGreatestGain = attr;
                }
            }

            return attributeWithGreatestGain;
        }