数据挖掘算法R语言实现之决策树
最近,看到很多朋友问我如何用数据挖掘算法R语言实现之决策树,想要了解这方面的内容如下:
>
library("party")导入数据包
> str(iris) 集中展示数据文件的结构
'data.frame': 150 obs. of 5 variables: 150条观测值,5个变量
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5
...
$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1
...
$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1
1 1 1 1 1 ...
Call functionctreeto build a decision tree. The first parameter is a formula, which defines a target variable and a list of independent variables.
> iris_ctree <- ctree(Species ~
Sepal.Length Sepal.Width Petal.Length Petal.Width, data=iris)
> print(iris_ctree)
Conditional inference tree with 4 terminal nodes
Response: Species
Inputs: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width
Number of observations: 150
1) Petal.Length <= 1.9; criterion = 1, statistic =
140.264
2)* weights = 50
1) Petal.Length > 1.9
3) Petal.Width <= 1.7; criterion = 1, statistic =
67.894
4) Petal.Length <= 4.8; criterion = 0.999, statistic
= 13.865
5)* weights = 46
4) Petal.Length > 4.8
6)* weights = 8
3) Petal.Width > 1.7
7)* weights = 46
> plot(iris_ctree)
plot(iris_ctree, type="simple")
相关文章
- Java 蓝桥杯 算法训练 字符串的展开 (JAVA语言实现)
- PageRank算法R语言实现
- PageRank算法R语言实现
- 机器学习&深度学习基础(tensorflow版本实现的算法概述0)
- 数据挖掘算法R语言实现之决策树
- 数据挖掘算法R语言实现之决策树
- PageRank算法R语言实现
- 协同过滤算法 R/mapreduce/spark mllib多语言实现
- NLP之NNLM:NNLM神经语言模型算法(词向量法的始祖)的简介、网络结构、案例应用、代码实现之详细攻略
- Algorithm:C+语言实现之数组相关算法(和为定值的两个数、和为定值的m个数、荷兰国旗、长度为2n的洗牌算法、任意长度数组的洗牌算法)
- ML之SVM:利用Js语言设计SVM算法(SMO算法+线性核/高斯核)
- DL之RNN:人工智能为你写代码——基于TF利用RNN算法实现生成编程语言代码(C++语言)、训练&测试过程全记录
- Interview:人工智能岗位—校招真题—算法工程师(计算机视觉方向)选择题——C++语言、sql语言编程相关习题的部分笔记
- Interview:算法岗位面试—10.11下午—上海某公司算法岗位(偏数据分析,证券金融行业)技术面试考点之sqlserver语言相关考察点复习
- 基于CNN卷积神经网络的语音信号识别算法matlab仿真
- 分割等和子集-c语言动态规划算法和改进算法同时提升时间复杂度和空间复杂度
- 选择建筑的方案数-c语言前缀和算法
- .删除子字符串的最大得分-c语言贪心算法
- 爬楼梯-c语言力扣最快算法
- sift算法c语言实现