Skip to content

Instantly share code, notes, and snippets.

@aagnone3
Created October 30, 2020 00:16
Show Gist options
  • Save aagnone3/23328d32bb283b49703405fe97497447 to your computer and use it in GitHub Desktop.
Save aagnone3/23328d32bb283b49703405fe97497447 to your computer and use it in GitHub Desktop.
sf_crime_7.py
# with the street probabilities, we can now assign them to each sample.
# as mentioned before, samples on street corners receive the mean of each street probability.
def assign_street_probabilities(address, probabilities):
return np.mean([
probabilities[clean_road(road)]
for road in address.split(" / ")
])
train["RoadProba"] = train["Address"].map(partial(assign_street_probabilities, probabilities=log_probas))
train.drop("Address", axis=1, inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment