欢迎来到天天文库
浏览记录
ID:32408390
大小:151.50 KB
页数:3页
时间:2019-02-04
《决策树模型分类的例子》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、选择wine的例子(DM6中),共178个样本,每个样本测得13个指标,共分成3类。由决策树得到分类规则:(Matlab程序在2012B中运行实现.)>>loadwine>>ctree=ClassificationTree.fit(wine,wine_labels)文本方式显示决策树>>view(ctree)%%returnsatextdescriptionofthetree.图形方式显示决策树:>>view(ctree,'mode','graph')预测新样本的类别可以用%Ynew=predict(tree,Xnew)如:>>Ynew=predict(ctree,mean(wine)
2、)Ynew=2计算误判率>>resuberrorc = resubLoss(ctree)resuberrorc = 0.0281>>Ypredict=predict(ctree,wine);>>mse(Ypredict-wine_labels)ans = 0.0281>>A1=dummyvar(Ypredict)>>A2=dummyvar(wine_labels)>>[c,cm,ind,per] =confusion(A1',A2')c=0.0281cm=570026910247ind = [1x57 double] []
3、 [] [1x2 double] [1x69 double] [ 162] [] [1x2 double] [1x47 double]
此文档下载收益归作者所有