Tests for assignment10

Disclaimer: Dieser Thread wurde aus dem alten Forum importiert. Daher werden eventuell nicht alle Formatierungen richtig angezeigt. Der ursprüngliche Thread beginnt im zweiten Post dieses Threads.

Tests for assignment10
If anyone wants to compare his or her implementation, here is my solution for the given test case:

Temperature? {
 - Hot => Outlook? {
 -  - Sunny => No
 -  - Overcast => Yes
 - }
 - Mild => Yes
 - Cool => No
}

I also made a new test case for the table from last weeks assignment:

    static Attribute furniture = new Attribute("furniture",Arrays.asList("Yes", "No"));
    static Attribute rooms = new Attribute("rooms",Arrays.asList("3", "4"));
    static Attribute kitchen = new Attribute("kitchen",Arrays.asList("Yes", "No"));
    static Attribute acceptable = new Attribute("acceptable",Arrays.asList("Yes", "No"));

    static TableRow h1 = new TableRow("h1", Arrays.asList(
            furniture.set("No"),
            rooms.set("3"),
            kitchen.set("Yes"),
            acceptable.set("Yes")
    ));
    static TableRow h2 = new TableRow("h2", Arrays.asList(
            furniture.set("Yes"),
            rooms.set("3"),
            kitchen.set("No"),
            acceptable.set("No")
    ));
    static TableRow h3 = new TableRow("h3", Arrays.asList(
            furniture.set("No"),
            rooms.set("4"),
            kitchen.set("No"),
            acceptable.set("Yes")
    ));
    static TableRow h4 = new TableRow("h4", Arrays.asList(
            furniture.set("No"),
            rooms.set("3"),
            kitchen.set("No"),
            acceptable.set("No")
    ));
    static TableRow h5 = new TableRow("h5", Arrays.asList(
            furniture.set("Yes"),
            rooms.set("4"),
            kitchen.set("No"),
            acceptable.set("Yes")
    ));
2 „Gefällt mir“

I think your solution is not quite correct, as [m]Outlook[/m] has three possible values. In your solution, the value [m]Rain[/m] is missing.

I have this as a solution for the given test case:

Temperature? {
 - Hot => Outlook? {
 -  - Sunny => No
 -  - Overcast => Yes
 -  - Rain => Yes
 - }
 - Mild => Yes
 - Cool => No
}
1 „Gefällt mir“

You’re right, thank you. Is it correct that the classification of “Rain” can be both “Yes” or “No” in this example, or am I mistaken?


No, the Decision Tree algorithm on the lecture slide stats that in such cases the most frequent value should be used.

Edit: Yes, you are right. Generally speaking, in such cases the most frequent value should be used. But in this example both „Yes“ and „No“ occur equally often, so the classification can be both.


I ended up with the same solution as Jonas. The tree is based on the given data. In the data, whenever Temperature was Hot, it never rained.
So if I traverse the resulting tree and select Temperature=Hot and I introduce Outlook=Rain, the tree will behave weird either way, no?
I don’t know whether I should play tennis if it’s hot and rainy!

Not sure whether I’m supposed to alter my solution according to atomico, IMO Jonas’ (and my) output is correct.

Here the table of the test for a quick check:

Outlook  Temperature Humidity Wind   Tennis
-------------------------------------------
Sunny    Hot         High     Weak   No
Overcast Hot         High     Weak   Yes
Rain     Mild        High     Weak   Yes
Rain     Cool        Normal   Strong No
Rain     Mild        Normal   Weak   Yes

But I think the algorithm from slide 765 says, when there are no examples left, like in our case for Temperature = Hot and Outlook=Rain we should return the default variable, which is the mode of the layer above.

So we have to make a decision for that case, mean an own branch in the tree, although we have no examples. Remember we create the tree for future examples and it may be the case in future that it is hot and rainy and which decsion you will made then, when you leave out the branch?