Scaling your data

If one value of your dataset varies a lot more than another, it may heavily impact your model. For that reason, we will want to scale our data.

Creating a scaler

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()
scaler.fit(data)
scaled = scaler.transform(data)

# If we want to apply this to future code below:
data = scaled

NOTE: We need to keep this standard scaler when predicting future values

Using the scaler

# If required, load the same scaler as was created, for this dataset
scaled = scaler.transform(data)