資源簡(jiǎn)介
python決策樹的實(shí)例代碼,相應(yīng)的文件和詳細(xì)的注釋說明,直接運(yùn)行test_tree文件即可顯示結(jié)果

代碼片段和文件信息
import?tree
import?treeplot
fr=open(‘D:/python/tree/lenses.txt‘)
#?將每一行的文本單詞,提取出來
lenses=[inst.strip().split(‘\t‘)?for?inst?in?fr.readlines()]
lensesLabels=[‘a(chǎn)ge‘‘prescript‘‘a(chǎn)stigmatic‘‘tearRate‘]
lensesTree=tree.createTree(lenseslensesLabels)
treeplot.createPlot(lensesTree)
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????????795??2012-01-09?21:40??lenses.txt
?????文件?????????322??2015-08-15?14:29??test_tree.py
?????文件????????6214??2015-08-15?11:16??tree.py
?????文件????????3722??2015-08-15?11:16??tree.pyc
?????文件?????????112??2015-07-10?15:17??treeclassify.txt
?????文件????????4021??2015-08-15?11:13??treeplot.py
?????文件????????3080??2015-08-15?11:14??treeplot.pyc
評(píng)論
共有 條評(píng)論