Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
290 B
1
Indexable
Never
entropy=0 #Store initial value of the entropy node 
obj=df.Play.unique() #To ensure only unique values for 'Play' attribute
for i in obj:
  f=df.Play.value_counts()[i]/len(df.Play) #calculate the fraction to use for entropy formula
  entropy = -f*np.log2(f) + entropy #entropy formula