Skip to content

Instantly share code, notes, and snippets.

@L-Lewis
Last active October 2, 2019 12:13
Show Gist options
  • Save L-Lewis/8bdc3858208d6629b7082883eb101db7 to your computer and use it in GitHub Desktop.
Save L-Lewis/8bdc3858208d6629b7082883eb101db7 to your computer and use it in GitHub Desktop.
from sklearn.preprocessing import MinMaxScaler
def process_structured_data(df, train, test):
"""
Pre-processes the given dataframe by minmaxscaling the continuous features
(fit-transforming the training data and transforming the test data)
"""
continuous = ["population_per_hectare", "bicycle_aadf", "motor_vehicle_aadf"]
cs = MinMaxScaler()
trainX = cs.fit_transform(train[continuous])
testX = cs.transform(test[continuous])
return (trainX, testX)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment