Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        7年前关闭。
                                                                                            
                
        
我现在正在自学机器学习。

关于信息获取的一个简单问题。
如何从图片数据中计算信息增益?
我不明白。

谁能解释如何从第一行获得0.992385?

非常感谢!

最佳答案

令g(x)= -x * log(x)/ log(2)

总人数是48842。

H(财富,关系)= g [52/48842] + g [111/48842] + g [309/48842] + g [1093/48842]
  + g [1238/48842] + g [1276/48842] + g [1454/48842] + g [4816/48842] + g [7470/48842]
  + g [8846/48842] + g [10870/48842] + g [11307/48842] = 2.7835

H(财富)= g(贫穷/总计)+ g(富有/总计)= g [0.239282] + g [0.760718] = 0.793844

H(关系)= g(丈夫/总数)+ g(非家庭成员/总数)+ ...
   = g [0.0308341] + g [0.0477253] + g [0.10493] + g [0.155215] + g [0.257627] +
  g [0.403669] = 2.15508

H(财富|关系)= H(财富,关系)-H(关系)= 2.7835-2.15508 = 0.628421

IG = H(财富)-H(财富|关系)= H(财富)+ H(关系)-H(财富,关系)
   = 0.165423

这是用Mathematica编写的源代码。如果您觉得需要用另一种语言查看源代码,请在下面用您的首选语言发表评论。如果有时间,我会输入。 -干杯,汉斯

Mathematica中的源代码

(* ================================================ === *)

m = {{10870, 8846}, {11307, 1276}, {1454, 52}, {7470, 111},
     {4816, 309}, {1238, 1093}};

iTot = Total[ Flatten[m]];

h[x_] := -x * Log[2, x];

fHAll = Sum[  h[ m[[i, j]]/ iTot ], {i, 6}, {j, 2}] // N;

fHWealth = h[ Total[ m[[All, 1]]]/iTot] + h[ Total[ m[[All, 2]]]/iTot] // N ;

fHRelation = Sum[
     h[ Total[ m[[i ]]]/iTot] , {i, Length[m]}] // N;

fWealthGivenRelation = fHAll - fHRelation;

Print[" H(relation, wealth) = ", fHAll];
Print[" H(relation) = ", fHRelation];
Print[" H(wealth) = ", fHWealth];
Print[" H(wealth | relation) = ", fWealthGivenRelation];
Print[" IG = MI = ", fHWealth - fWealthGivenRelation, " = ",
  fHWealth + fHRelation - fHAll];


(* ==================输出=================== *)

 H(relation, wealth) = 2.7835
 H(relation) = 2.15508
 H(wealth) = 0.793844
 H(wealth | relation) = 0.628421
 IG = MI = 0.165423 = 0.165423


糟糕,我没有回答您的主要问题。这就是答案。

H(财富|关系=丈夫)
= g(10870 /(10870 + 8846))+ g(8846 /(10870 + 8846))
= 0.992385

关于machine-learning - 从安德鲁·摩尔的教程中获得的信息 yield ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12719091/

10-12 19:41