การทำให้ฟีเจอร์เป็นมาตรฐาน

การพยากรณ์ CTR ด้วย Machine Learning ใน Python

Kevin Huo

Instructor

ทำไม Standardization จึงสำคัญ

  • Standardization: การปรับข้อมูลให้ตรงกับสมมติฐานของโมเดล
  • ฟีเจอร์บางตัวอาจมีความแปรปรวนสูงเกินไป ซึ่งอาจส่งผลต่อโมเดลอย่างไม่สมดุล
  • ตัวอย่าง: ค่าบางตัวมีช่วงกว้างมากเนื่องจากผู้ใช้สแปมรายเดียว
  • ไม่ใช้กับตัวแปรเชิงหมวดหมู่ เช่น site_id, app_id, device_id เป็นต้น
การพยากรณ์ CTR ด้วย Machine Learning ใน Python

Log normalization

df.var()
click                   1.294270e-01
hour                    1.123316e-01
df.var().median()
0.7108583771671939
print(df['click'].var())
df['device_id_count'] = df[
  'device_id_count'].apply(
  lambda x: np.log(x))
print(df['click'].var())
249362570.10134825
15.628476003312514
การพยากรณ์ CTR ด้วย Machine Learning ใน Python

การปรับสเกลข้อมูล

  • Standard scaling แปลงฟีเจอร์ทั้งหมดให้มีค่าเฉลี่ย 0 และส่วนเบี่ยงเบนมาตรฐาน 1

ตัวอย่างของ standard scaling

  • เป็นแนวปฏิบัติที่ดีสำหรับโมเดล machine learning โดยทั่วไป
การพยากรณ์ CTR ด้วย Machine Learning ใน Python

วิธีทำ Standard Scaling กับข้อมูล

  • ปรับสเกลข้อมูลได้โดยใช้ StandardScaler() ดังนี้:
scaler = StandardScaler()
X[numeric_cols] = scaler.fit_transform(X[numeric_cols])
dtype: float64
1    10.5 -> 0.85
2    32.3 -> 1.54
การพยากรณ์ CTR ด้วย Machine Learning ใน Python

มาฝึกกันเถอะ!

การพยากรณ์ CTR ด้วย Machine Learning ใน Python

Preparing Video For Download...