MCPcopy
hub / github.com/MingchaoZhu/DeepLearning / calculate_gini

Function calculate_gini

code/chapter5.py:423–430  ·  view source on GitHub ↗
(y)

Source from the content-addressed store, hash-verified

421
422
423def calculate_gini(y):
424 unique_labels = np.unique(y)
425 var = 0
426 for label in unique_labels:
427 count = len(y[y == label])
428 p = count / len(y)
429 var += p ** 2
430 return 1 - var
431
432
433class ClassificationTree(DecisionTree):

Callers 1

_calculate_gini_indexMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected