Skip to content

Instantly share code, notes, and snippets.

@pytholabsbot1
Created February 15, 2019 06:01
Show Gist options
  • Save pytholabsbot1/4c5151fd9f785b4105188b16e025f8c9 to your computer and use it in GitHub Desktop.
Save pytholabsbot1/4c5151fd9f785b4105188b16e025f8c9 to your computer and use it in GitHub Desktop.
##1. claculate entropy o the whole dataset
entropy_node = 0 #Initialize Entropy
values = df.play.unique() #Unique objects - 'Yes', 'No'
for value in values:
fraction = df.play.value_counts()[value]/len(df.play)
entropy_node += -fraction*np.log2(fraction)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment