📄 first_node.m
字号:
load tree.mat;
age;
income;
student;
credit_rating;
if G_age>=G_income
Gain=G_age;
else
Gain=G_income;
end
if Gain<G_student
Gain=G_student;
elseif Gain<G_credit_rating
Gain=G_credit_rating;
end
disp(sprintf('第一个节点选为信息增益为:%d的节点',Gain));
[rows,cols]=size(client);
K=0;
for I=1:rows
if strcmp(client(I,1),'<=30')
for J=1:cols-1
age_1(I-K,J)=client(I,J+1);
end
else
K=K+1;
I=I-1;
end
end
K=0;
for I=1:rows
if strcmp(client(I,1),'>31and<=40')
for J=1:cols-1
age_2(I-K,J)=client(I,J+1);
end
else
K=K+1;
I=I-1;
end
end
K=0;
for I=1:rows
if strcmp(client(I,1),'>40')
for J=1:cols-1
age_3(I-K,J)=client(I,J+1);
end
else
K=K+1;
I=I-1;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -