Created
May 23, 2014 03:20
-
-
Save scw/efddb2a0cc7f5f9883fe to your computer and use it in GitHub Desktop.
Logic for vessel validation scores
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 jaro_cost(inputs, weight=1): | |
min_score = 1.0 | |
for a,b in list(itertools.combinations(inputs, 2)): | |
jaro_score = jellyfish.jaro_distance(a, b) | |
if jaro_score < min_score: | |
min_score = jaro_score | |
return (1 - min_score)*weight | |
def attr_score(attribute): | |
score = 0.0 | |
if len(attribute) > 1: | |
attr_set= list_to_set(attribute) | |
if len(attr_set) == 1: | |
score += 1 | |
else: | |
score -= jaro_cost(attr_set) | |
return score | |
# some logic here to pull the data from the right database, then we start weighting based on the attributes... | |
for vessel in the_vessel_list: | |
score += attr_score(names) | |
score += attr_score(callsigns) | |
if len(mmsis) > 2: | |
score -= (len(mmsis) - 2) | |
if input_count > 5: | |
score -= (input_count - 5) | |
for label in ship_class: | |
if label in reverse_classified_ships.keys(): | |
val = reverse_classified_ships[label] | |
observed_types[val] += 1 | |
if len(observed_types) == 1: | |
score += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment