first_node.m

来自「数据挖掘里的判定树算法」· M 代码 · 共 57 行

M
57
字号

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 + =
减小字号Ctrl + -
显示快捷键?