Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created November 3, 2015 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyerrington/ff6e3353754d24d869bc to your computer and use it in GitHub Desktop.
Save dyerrington/ff6e3353754d24d869bc to your computer and use it in GitHub Desktop.
Another simple scaler found in scipy
from scipy.interpolate import interp1d
# params: [from_min, from_max], [to_min, to_max]
m = interp1d([1,100],[1,7])
m(99.234)
# output: array(6.9535757575757575)
@dyerrington
Copy link
Author

Interpolate from probability units to 1-5 ratings:

from scipy.interpolate import interp1d
import numpy as np

# params: [from_min, from_max], [to_min, to_max]
m = interp1d([0,1],[1,5])
for n in np.linspace(0,1,10):
    print(m(n), "rounded:", np.round(m(n)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment