Skip to content

Instantly share code, notes, and snippets.

@lethalbrains
Last active August 8, 2018 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lethalbrains/d11bcd5be8248c13580e0f5c97275253 to your computer and use it in GitHub Desktop.
Save lethalbrains/d11bcd5be8248c13580e0f5c97275253 to your computer and use it in GitHub Desktop.
def __calculate_impurity_score(self, data):
if data is None or data.empty: return 0
p_i, _ = data.value_counts().apply(lambda x: x/len(data)).tolist()
return p_i * (1 - p_i) * 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment