Github 项目推荐 | 基于 ID3 算法的 ML 决策树的实现

2018 年 5 月 2 日 AI研习社 AI 研习君

本库是实现用于决策树学习的 ID3 算法的 Ruby 库,目前能够学习连续和离散的数据集。

Github 链接:

https://github.com/igrigorik/decisiontree

  特点

  • 用于连续和离散情况的 ID3 算法,支持不一致的数据集。

  • Graphviz 组件可视化学习树

  • 支持多个符号输出和连续树形图。

  • 当没有分支适合输入时返回默认值

  实现

Ruleset 是一个用 2/3 训练数据训练 ID3Tree 的类,并将其转换为一组规则,然后用剩下的 1/3 数据(以 C4.5 的方式,https://en.wikipedia.org/wiki/C4.5_algorithm)修剪规则。

Bagging 是一个基于 Bagging 的训练器,它可以训练 10 个 Ruleset 训练器,并通过投票预测最佳的输出结果。

详细信息请访问以下链接:

https://www.igvita.com/2007/04/16/decision-tree-learning-in-ruby/

  示例

require 'decisiontree'

attributes = ['Temperature']
training = [
[36.6'healthy'],
[37'sick'],
[38'sick'],
[36.7'healthy'],
[40'sick'],
[50'really sick'],
]

# Instantiate the tree, and train it based on the data (set default to '1')
dec_tree = DecisionTree::ID3Tree.new(attributes, training, 'sick':continuous)
dec_tree.train

test = [37'sick']
decision = dec_tree.predict(test)
puts "Predicted: #{decision} ... True decision: #{test.last}"

# => Predicted: sick ... True decision: sick

# Specify type ("discrete" or "continuous") in the training data
labels = ["hunger""color"]
training = [
      [8"red""angry"],
      [6"red""angry"],
      [7"red""angry"],
      [7"blue""not angry"],
      [2"red""not angry"],
      [3"blue""not angry"],
      [2"blue""not angry"],
      [1"red""not angry"]
]

dec_tree = DecisionTree::ID3Tree.new(labels, training, "not angry"color: :discretehunger: :continuous)
dec_tree.train

test = [7"red""angry"]
decision = dec_tree.predict(test)
puts "Predicted: #{decision} ... True decision: #{test.last}"

# => Predicted: angry ... True decision: angry

从Python入门-如何成为AI工程师

BAT资深算法工程师独家研发课程

最贴近生活与工作的好玩实操项目

班级管理助学搭配专业的助教答疑

学以致用拿offer,学完即推荐就业


新人福利


关注 AI 研习社(okweiwu),回复  1  领取

【超过 1000G 神经网络 / AI / 大数据资料】


开发者自述:我是如何理解决策树的

登录查看更多
1

相关内容

专知会员服务
137+阅读 · 2020年5月19日
【干货书】真实机器学习,264页pdf,Real-World Machine Learning
【新书】Pro 机器学习算法Python实现,379页pdf
专知会员服务
197+阅读 · 2020年2月11日
计算机视觉最佳实践、代码示例和相关文档
专知会员服务
17+阅读 · 2019年10月9日
《机器学习实战》代码(基于Python3)
专知
32+阅读 · 2019年10月14日
Github项目推荐 | PyTorch文本分类教程
AI研习社
7+阅读 · 2019年6月7日
GitHub标星2.6万!Python算法新手入门大全
量子位
3+阅读 · 2019年4月27日
Github 项目推荐 | 用 PyTorch 0.4 实现的 YoloV3
AI研习社
9+阅读 · 2018年8月11日
Github 项目推荐 | YOLOv3 的最小化 PyTorch 实现
AI研习社
25+阅读 · 2018年5月31日
基于机器学习方法的POI品类推荐算法
全球人工智能
3+阅读 · 2017年11月22日
【推荐】决策树/随机森林深入解析
机器学习研究会
5+阅读 · 2017年9月21日
Arxiv
6+阅读 · 2019年9月4日
Embedding Logical Queries on Knowledge Graphs
Arxiv
3+阅读 · 2019年2月19日
Adaptive Neural Trees
Arxiv
4+阅读 · 2018年12月10日
Arxiv
4+阅读 · 2018年7月4日
Adversarial Reprogramming of Neural Networks
Arxiv
3+阅读 · 2018年6月28日
Arxiv
10+阅读 · 2018年3月23日
Arxiv
26+阅读 · 2018年2月27日
VIP会员
相关资讯
《机器学习实战》代码(基于Python3)
专知
32+阅读 · 2019年10月14日
Github项目推荐 | PyTorch文本分类教程
AI研习社
7+阅读 · 2019年6月7日
GitHub标星2.6万!Python算法新手入门大全
量子位
3+阅读 · 2019年4月27日
Github 项目推荐 | 用 PyTorch 0.4 实现的 YoloV3
AI研习社
9+阅读 · 2018年8月11日
Github 项目推荐 | YOLOv3 的最小化 PyTorch 实现
AI研习社
25+阅读 · 2018年5月31日
基于机器学习方法的POI品类推荐算法
全球人工智能
3+阅读 · 2017年11月22日
【推荐】决策树/随机森林深入解析
机器学习研究会
5+阅读 · 2017年9月21日
相关论文
Arxiv
6+阅读 · 2019年9月4日
Embedding Logical Queries on Knowledge Graphs
Arxiv
3+阅读 · 2019年2月19日
Adaptive Neural Trees
Arxiv
4+阅读 · 2018年12月10日
Arxiv
4+阅读 · 2018年7月4日
Adversarial Reprogramming of Neural Networks
Arxiv
3+阅读 · 2018年6月28日
Arxiv
10+阅读 · 2018年3月23日
Arxiv
26+阅读 · 2018年2月27日
Top
微信扫码咨询专知VIP会员