Skip to content

Instantly share code, notes, and snippets.

@missflash
Created March 23, 2019 10:29
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 missflash/29578dc5eeaef7bcc65e4ad9d4f35eef to your computer and use it in GitHub Desktop.
Save missflash/29578dc5eeaef7bcc65e4ad9d4f35eef to your computer and use it in GitHub Desktop.
def normalize_feature(data, f_min=-1.0, f_max=1.0):
d_min, d_max = min(data), max(data)
factor = (f_max - f_min) / (d_max - d_min)
normalized = f_min + (data - d_min)*factor
return normalized, factor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment