Assignment:. Write a python program to implement the Hu

Added on - Sep 2019

Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 1 of 1 pages
Assignment:Writeapython programtoimplementthe Huntsalgorithm fordecision tree:1.Function 1 to build a decision tree:a.Theinputis alist of tuples:i. Thefirsttuple ofthis lististo describetheattributetypeof theitemsinthe rest of the list. Theattributetypescould ben, ‘o, ‘c’,and ’l’fornominal, ordinal,continuous,and label, respectively. Notethat wecanassumethelabel attributel’ is alwaysthe lastattributeinthetuple,and it’s value isalwayseither 0or 1.ii. Therest of the listis offixed sized integer-tuples.iii.Forexample,[(n’,n’,c’,’l),(1,0,125,0),(0,2,100,0), ...]iv. Notethatallthe input valuesareof integer.Forexample, wecanconvert ourexample intheppt file,yes/noto be1/0.b. Theoutputis a tree-likestructurewhichcould be atupleof tuplesasdescribedintheclass.(left-child, information ofcurrent node, right-child). Pleasenotethat nullpointer is the keywordNoneinPython.c.Thechoiceofattribute for next node isin the same order ofinputattribute.Thatis, root nodeis based on first attribute,and itschild nodesaretheattribute2.d. Assume that each nodecan haveatmosttwochildren.e.Wecanassumethe inputlistis legitimate. Thatis, wedo not need to checkthe qualityof theinput.f.You might need tocreatemorefunctionsto becalled to completethe tasksforthis function.2.Function 2returnsalabel(class)for agiven tuplewhich issame structure(withoutlabel)as the tuple inthelistof thefirst function.a.Forexample, the inputcould be(1,0,120)compared totheexampleoffunction 1above.b. Theoutputis eitherthe label which is 0 or 1for this assignment.3. Create oneexamplebyconvertingourexamplefromtheppt file,and test theresultswith newtuples.
Desklib Logo
You are reading a preview
Upload your documents to download or

Become a Desklib member to get access