没有合适的资源?快使用搜索试试~ 我知道了~
机器学习实验报告.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 117 浏览量
2022-06-16
09:24:13
上传
评论
收藏 45KB DOCX 举报
温馨提示
试读
17页
机器学习实验报告.docx机器学习实验报告.docx机器学习实验报告.docx机器学习实验报告.docx机器学习实验报告.docx机器学习实验报告.docx机器学习实验报告.docx机器学习实验报告.docx
资源详情
资源评论
资源推荐
I / /
XI1 AW 4J NIU E RSFTY 0 F ^0^ li
TELECtMIHUNI CATIONS
《机器学
习》
课内实验报
告
(1 ID
) 算法实现决策
树
2015 - 2016
2
学年第 学期
智能科学与技
术
专业:
班级:
学号:
智能
1301
班
061330
29
一、 实验目
的:
理解 算法的基本原理,并且编程
实现
ID3
二、 实验要
求:
使用 实现 算
法。
ID3
C/C++/
MATLAB
输入:
若干行,每行 个字符串,
表示
5
Outlook Temperature Humidity Wind
Play ball
如上表。
输出:
决策树
实验结果如
下:
输入:
Sunn
y
Hot
Hot
High
High
Weak 1
Stro ng
Weak
No
Sunn
y
No
Overcas
t
Hot High Yes
Rai n
Rai n
Mild
Cool
High Weak
Yes
Weak
Norma
l
Yes
Rai n Cool Norma
l
Stro ng No
Overcas
t
Sunny
Cool Norma
l
Stro ng
Yes
Mild
Cool
High Wea
k
No
Sunn
y
Norma
l
Weak
Yes
Rai n
Sunn
y
Mild Norma
l
Wea
k
Yes
Mild Norma
l
Stro ng
Stro ng
Weak
Yes
Yes
Yes
Overcas
t
Overcas
t
Rai n
Mild
Hot
High
Norma
l
Mild High Stro ng No
输出:
Outloo
k
Ra in Wind
Stro ng
Wea
k
No
Yes
Overcas
t
Yes
Sunn
y
Humidit
y
Normal
Yes
High
No
三、具体实
现:
实现算法如
下:
#i nclude
<iostream>
#in elude
<fstream>
#in elude
<math.h>
#in elude <stri ng> using n
amespace std;
#de@ne
ROW 14
#de@ne
COL 5
#de@ne log2
0.69314718055
typedef struct
TNode
{
char data[15];
char
weight[15];
TNode * @rstchild,* nextsibli
ng;
}*tree;
typedef struct
LNode
{
char OutLook[15];
char
Temperature[15];
char
Humidity[15];
char Wind[15];
char
PlayTennis[5];
LNode *n
ext;
}*li nk;
typedef struct
AttrNode
{
char
attributes[15];
〃 属
性
int
attr_Num;
〃属性的个
数
AttrNode *n
ext;
}*Attributes;
char * Examples[ROW][COL] = {//"OverCast","Cool","High","Stro
ng","No", // "Rai
n","Hot","Normal","Stro ng","Yes",
"Sunn y","Hot","High","Weak","No", "Sunn
y","Hot","High","Stro ng","No",
"OverCast","Hot","High","Weak","Yes",
"Rai
n","Mild","High","Weak","Yes",
"Rai n","Cool","Normal","Weak","Yes", "Rai
n","Cool","Normal","Stro ng","No",
"OverCast","Cool","Normal","Stro ng","Yes",
"Sunn y","Mild","High","Weak","No", "Su nn
y","Cool","Normal","Weak","Yes", "Rai
n","Mild","Normal","Weak","Yes", "Su nn y","Mild","Normal","Stro
ng","Yes",
"OverCast","Mild","Normal","Stro ng","Yes",
"OverCast","Hot","Normal","Weak","Yes",
"Rai n","Mild","High","Stro ng","No"
};
char * Attributes_ki nd[4] = {"OutLook","Temperature","Humidity","Wi nd"}; int
Attr_ki nd[4] =
{3,3,2,2};
char * OutLook_ki nd[3] = {"Su nn
y","OverCast","Rai n"};
char * Temperature_ki nd[3] =
{"Hot","Mild","Cool"};
char * Humidity_ki nd[2] = {"High","Normal"};
char * Win d_ki nd[2] = {"Weak","Stro ng"};
/*int i_Exampple[14][5] =
{0,0,0,0,1,
0,0,0,1,1,
1,0,0,1,0,
2,1,0,0,0,
2,2,1,0,0,
2,2,1,1,1,
121,1,0,
0,1,0,0,1,
0,2,1,0,0,
2,1,1,0,0,
0,1,1,1,0,
1,1,1,1,0,
1,1,1,0,0,
2,1,0,0,1 };*/
void treelists(tree
T);
void Ini tAttr(Attributes & attr_li nk,char * Attributes_ki nd[],i nt Attr_ki
nd[]);
void In itLi nk(li nk & L,char * Examples[][COL]);
void ID3(tree &T,link L,link Target_Attr,Attributes
attr);
void PN_Num(link L,int &positve,int &negative);
double Gain(int positive,int negative,char * atrribute,link L,Attributes
attr_L);
void
main()
{
link LL,p;
Attributes
attr_L,q;
tree T;
T = new
TNode;
T->@rstchild = T-> nextsibli ng = NULL; strcpy(T-
>weight,"");
strcpy(T->data,"");
剩余16页未读,继续阅读
苦茶子12138
- 粉丝: 1w+
- 资源: 6万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0