บทนำ
Abalone dataset โหลดผ่าน Google Cloud Storage URL ด้วย pandas read_csv แล้วระบุ column names เอง
โค้ดตัวอย่าง
import pandas as pd
import numpy as np
print("The below line makes it easier to read NumPy values")
np.set_printoptions(precision=3, suppress=True)
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.layers.experimental import preprocessing
print("Reading the csv data")
abalone_train = pd.read_csv(
"https://storage.googleapis.com/download.tensorflow.org/data/abalone_train.csv",
names=["Length", "Diameter", "Height", "Whole weight", "Shucked weight",
"Viscera weight", "Shell weight", "Age"])ผลลัพธ์
The below line makes it easier to read NumPy values Reading the csv data
คำอธิบาย
- URL:
https://storage.googleapis.com/download.tensorflow.org/data/abalone_train.csv names=[...]: CSV ไม่มี header ต้องระบุชื่อคอลัมน์เองnp.set_printoptions(precision=3, suppress=True): แสดงค่า float สวยขึ้น (3 ตำแหน่ง, ไม่ใช้ scientific notation)- ขั้นตอนต่อไป: copy → pop 'Age' → np.array → normalization → model
ข้อมูล Dataset
Features: 7 คอลัมน์ตัวเลข (continuous) | Target: Age (integer)
ขนาด: ~4000 samples (train)