Page 1 of 1

this assignment, you'll be coding up decision trees for classification and regression from scratch. Write a program in P

Posted: Thu Jul 14, 2022 2:17 pm
by answerhappygod
this assignment, you'll be coding up decision trees for classification and regression from scratch.
Write a program in Python to implement the ID3 decision tree algorithm. You should read in a tab delimited dataset, and output to the screen your decision tree and the training set accuracy in some readable format. Use the text files provided
When you run your program, it should take a command-line parameter that contains the name of the file containing the data. For example:
python decisiontree.py tennis.txt
The first line of the file will contain the name of the fields. The last column is the classification attribute, and will always contain the values yes or no. All files are tab delimited.
For output, you can choose how to draw the tree so long as it is clear what the tree is. Alternatively, you can use text. You might find it easier if you turn the decision tree on its side, and use indentation to show levels of the tree as it grows from the left. For example:
outlook = sunny
| humidity = high: no
| humidity = normal: yes
outlook = overcast: yes
outlook = rainy
| windy = TRUE: no
| windy = FALSE: yes
You don't need to make your tree output look exactly like above: feel free to print out something similarly readable if you think it is easier to code.
You may find Python dictionaries especially useful here, as they will give you a quick an easy way to help manage counting the number of times you see a particular attribut