Created
August 7, 2013 20:26
-
-
Save iskandr/6178289 to your computer and use it in GitHub Desktop.
gini score
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
LeftCounts = np.array([150,150]) | |
RightCounts = np.array([200,200]) | |
NLeft = sum(LeftCounts) | |
NRight = sum(RightCounts) | |
NTotal = float(NLeft + NRight) | |
LL = np.dot(LeftCounts,LeftCounts) | |
RR = np.dot(RightCounts,RightCounts) | |
LeftScore = 1.0 - LL/NLeft**2 | |
RightScore = 1.0 - RR/NRight**2 | |
Score = (NLeft/NTotal) * LeftScore + (NRight / NTotal) * RightScore | |
print NLeft, NRight, Score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment