Skip to content

Instantly share code, notes, and snippets.

@isaacarroyov
Last active November 20, 2020 02:50
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 isaacarroyov/8c0059d2bf7a38fb68a391acf091e62a to your computer and use it in GitHub Desktop.
Save isaacarroyov/8c0059d2bf7a38fb68a391acf091e62a to your computer and use it in GitHub Desktop.
relevant code for the preprocessing
#select the relevant variables
variables = np.array( [ 'HOMICIDES', 'CAR_THEFT',
'EXTORTION', 'STREET_TRANSPORT_THEFT' ] )
#Here we standardize a dataset along any axis.
#Center to the mean and component wise scale to unit variance.
from sklearn import preprocessing
df_standardized = preprocessing.scale( df[variables] )
df_standardized = pd.DataFrame( df_standardized )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment