- Deep Learning Quick Reference
- Mike Bernico
- 140字
- 2021-06-24 18:40:15
Loading data
We can load the data used in this chapter with the following function. It's very similar to the function we used in chapter 2, however it's adapted for this dataset.
from sklearn.preprocessing import StandardScaler
def load_data():
"""Loads train, val, and test datasets from disk"""
train = pd.read_csv(TRAIN_DATA)
val = pd.read_csv(VAL_DATA)
test = pd.read_csv(TEST_DATA)
# we will use a dict to keep all this data tidy.
data = dict()
data["train_y"] = train.pop('y')
data["val_y"] = val.pop('y')
data["test_y"] = test.pop('y')
# we will use sklearn's StandardScaler to scale our data to 0 mean, unit variance.
scaler = StandardScaler()
train = scaler.fit_transform(train)
val = scaler.transform(val)
test = scaler.transform(test)
data["train_X"] = train
data["val_X"] = val
data["test_X"] = test
# it's a good idea to keep the scaler (or at least the mean/variance) so we can unscale predictions
data["scaler"] = scaler
return data
推薦閱讀
- LabVIEW虛擬儀器從入門到測控應用130例
- Canvas LMS Course Design
- Hands-On Cloud Solutions with Azure
- Expert AWS Development
- 最后一個人類
- Windows 7寶典
- Photoshop CS3圖層、通道、蒙版深度剖析寶典
- CompTIA Network+ Certification Guide
- Learn CloudFormation
- 運動控制系統(tǒng)
- 精通LabVIEW程序設(shè)計
- JRuby語言實戰(zhàn)技術(shù)
- 與人共融機器人的關(guān)節(jié)力矩測量技術(shù)
- 電腦故障排除與維護終極技巧金典
- 基于Proteus的PIC單片機C語言程序設(shè)計與仿真