lundi 31 octobre 2016

Python : How to hash strings into a float in [0:1]?

I have a dataset with multiple strings.

I want to associate each of these strings to a float, "randomly" distributed in the [0;1] range.

=> I am looking for myfunction. myfunction is expected to give me a float between 0 and 1, for each of my strings. Examples :

myfunction(string_1) = 0.26756754
myfunction(string_2) = 0.86764534

NB : random() does not fulfill my need because it does not take any string as input / deterministic parameter. I am looking for something more like a hash function




Aucun commentaire:

Enregistrer un commentaire