Created
November 8, 2012 07:09
-
-
Save versae/4037344 to your computer and use it in GitHub Desktop.
Function is_vampire for CS2110
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
def is_vampire(row): | |
""" | |
Decides if the element given by row is a vampire or not | |
Analyzing the box plots, we see that the first and second columns, | |
height(cm) and weight(kg), don't give us much information. | |
However, the third, 4th, 5th and 6th, stake aversion, garlic aversion, | |
reflectance, and shiny, provide decissive information. | |
:param rom: A vector with measures | |
:return: A probability of being a vampier, between 0 and 1 | |
""" | |
stake, garlic, reflectance, shiny = row[2:6] | |
if stake >= 1.72: | |
probability = 0.99 | |
elif stake < -0.27: | |
probability = 0.01 | |
elif garlic >= 0.84: | |
probability = 0.99 | |
elif garlic <= 0.34: | |
probability = 0.01 | |
elif reflectance >= 0.89: | |
probability = 0.01 | |
elif reflectance < 0.72: | |
probability = 0.99 | |
elif shiny >= 1.48: | |
probability = 0.01 | |
elif shiny <= -0.54: | |
probability = 0.01 | |
else: | |
# We use here just the reflectance and the max and min values | |
probability = 1 - numpy.clip(reflectance, -0.56, 0.89) | |
probability = numpy.clip(probability, 0.01, 0.99) | |
return probability |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment