Assignment:. Write a python program to implement the Hu
Added on -2019-09-16
| 1 pages
| 431 words
| 174 views
Trusted by 2+ million users, 1000+ happy students everyday
Assignment:Writeapython program toimplementthe Hunt’s algorithm fordecision tree:1. Function 1 to build a decision tree:a. Theinputis alist of tuples:i. Thefirst tuple ofthis list isto describethe attributetypeof theitems inthe rest of the list. The attributetypescould be ‘n’, ‘o’, ‘c’,and ’l’for nominal, ordinal, continuous, and label, respectively. Notethat wecan assumethe label attribute ‘l’ is alwaysthe lastattributein thetuple, and it’s value is always either 0 or 1.ii. Therest of the list is of fixed sized integer-tuples.iii. For example, [(‘n’,’n’,’c’,’l’),(1,0,125,0),(0,2,100,0), ...]iv. Notethat allthe input values areof integer. For example, we canconvert ourexample in theppt file,yes/no to be1/0.b. Theoutputis a tree-likestructurewhichcould be atupleof tuples asdescribedin the class. (left-child, information of current node, right-child). Pleasenote that nullpointer is the keywordNone in Python.c. The choiceof attribute for next node is in the same order ofinputattribute.That is, root nodeis based on first attribute, and its child nodes aretheattribute2.d. Assume that each nodecan haveat most two children.e. We can assumethe inputlist is legitimate. That is, wedo not need to checkthe qualityof theinput.f.You might need tocreatemorefunctionsto be called to completethe tasks forthis function.2. Function 2 returnsalabel(class)for a given tuplewhich is same structure(withoutlabel) as the tuple in thelistof thefirst function.a. For example, the input could be (1,0,120) compared to the exampleoffunction 1 above.b. Theoutputis eitherthe label which is 0 or 1 for this assignment.3. Create oneexamplebyconvertingourexamplefrom theppt file, and test theresultswith newtuples.
Found this document preview useful?
You are reading a preview Upload your documents to download or Become a Desklib member to get accesss