pyMAISE.preprocessing.scale_data
- pyMAISE.preprocessing.scale_data(train_data, test_data, scaler)[source]
Scale training and testing data using the scaler provided. This method returns the fit scalar which can be used to scale any additional data.
Example
Given the following 2D
xarray.DataArraysof shape (samples, features/labels),xtrainandxtest, we can apply thepyMAISE.preprocessing.scale_data()method,from pyMAISE.preprocessing import scale_data from sklearn.preprocessing import MinMaxScaler xtrain, xtest, xscaler = scale_data(xtrain, xtest, MinMaxScaler)
We can then scale an additional dataset,
xvalid, that matches the format ofxtrainandxtestby runningxvalid.values = xscaler.transform(xvalid.values)
- Parameters:
train_data (xarray.DataArray) – Training data.
test_data (xarray.DataArray) – Testing data.
scaler (callable) – An object with
fit_transformandtransformmethods such as min-max scaler from sklearn [PVG+11].
- Returns:
train_data (xarray.DataArray) – Scaled training data.
test_data (xarray.DataArray) – Scaled testing data based on
scalerfit ontrain_data.scaler (callable) – The scaler given, fit and used to scale the given data.