CART算法实现之可视化
2013-12-24 11:59
369 查看
function filename = viz_tree( tree ) %UNTITLED Summary of this function goes here % Visualiz the tree using graphviz global index; index = 0; fid = fopen('Visualization.dot','w+'); fprintf(fid, 'digraph G {\n'); fprintf(fid, 'fontname = "Bitstream Vera Sans"\n'); fprintf(fid, 'fontsize = 8\n'); fprintf(fid, 'node[fontname = "Bitstream Vera Sans"\n'); fprintf(fid, ' fontsize = 8\n'); fprintf(fid, ' shape = "record"]\n'); fprintf(fid, 'edge [fontname = "Bitstream Vera Sans"\n'); fprintf(fid, ' fontsize = 8]\n'); visual( tree ,fid); fprintf(fid,'}'); fclose(fid); filename = 'Visualization.dot'; function nodename = visual( tree ,fid) global index; index = index + 1; nodename = ['node' num2str(index)]; if isnumeric(tree.Raction) %Reached an end node fprintf(fid, '%s[label ="{class = %d|+Error Rate : %5f}"]\n',nodename, tree.Raction(1),tree.Resub); else fprintf(fid, '%s[label ="{Left : %s|+Right : %s|+Alpha : %6f}"]\n',nodename, tree.Laction, tree.Raction, tree.Alpha); nl = visual(tree.left, fid); nr = visual(tree.right, fid); fprintf(fid, '%s -> %s\n',nodename, nl); fprintf(fid, '%s -> %s\n',nodename, nr); %fprintf(fid, 'nodename[label =%s|+Leafcnt : %d|+Alpha : %6f]\n', tree.Raction, tree.Leafcnt, tree.Alpha); %Rl = visual(tree.left, fid); %RR = visual(tree.right, fid); end
相关文章推荐
- 常见数据结构和算法 的图形界面可视化实现
- CART算法实现之建树篇
- Python使用Matplotlib和Imagemagick实现感知器算法可视化与GIF导出
- 基于opencv的神经网络算法实现两类分类问题的可视化演示
- d3.js+react实现算法可视化:排序篇
- CART算法的原理以及实现
- 聚类之 FCM 算法原理及应用(Java可视化实现)
- 决策树之CART算法原理及python实现
- CART分类决策树、回归树和模型树算法详解及Python实现
- d3.js+react实现算法可视化:排序篇
- 经典内部排序算法学习总结(算法思想、可视化、Java代码实现、改进、复杂度分析、稳定性分析)
- 机器学习之CART算法python实现
- 机器学习经典算法详解及Python实现--CART分类决策树、回归树和模型树
- CART算法原理及实现
- Alg-4:算法可视化tiny库的实现
- [置顶] 《统计学习方法》 决策树 CART生成算法 分类树 Python实现
- [置顶] 《统计学习方法》 决策树 CART生成算法 回归树 Python实现
- 机器学习经典算法详解及Python实现--CART分类决策树、回归树和模型树
- CART算法原理及实现
- CART算法原理及实现