Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

DecisionTrees\Pruning\ErrorBasedPruning: The getMaxChild method returns the max grandchild #235

@YaronK

Description

@YaronK

There's possibly an issue is with the ErrorBasedPruning class - the getMaxChild method returns the max grandchild.

The algorithm referenced in the comments indeed considers replacing the node with its 'max child'.

This is the implementation of getMaxChild:

private DecisionNode getMaxChild(DecisionNode tree)
{
    DecisionNode max = null;
    int maxCount = 0;

    foreach (var child in tree.Branches)
    {
        if (child.Branches != null)
        {
            foreach (var node in child.Branches)
            {
                var list = subsets[node];
                if (list.Count > maxCount)
                {
                    max = node;
                    maxCount = list.Count;
                }
            }
        }
    }

    return max;
}

If I'm not mistaken, this implementation doesn't achieve the required result; Instead of returning the max child, it returns the max grandchild.
(Also, if I understood the implementation, getMaxChild is never executed on leaves, so the current node always has branches).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions