數值變數

Feature Engineering for Machine Learning in Python

Robert O'Callaghan

Director of Data Science, Ordergroove

數值特徵的類型

  • 年齡
  • 價格
  • 計數
  • 地理空間資料
Feature Engineering for Machine Learning in Python

大小重要嗎?

Feature Engineering for Machine Learning in Python

將數值變數二值化

df['Binary_Violation'] = 0

df.loc[df['Number_of_Violations'] > 0, 'Binary_Violation'] = 1
Feature Engineering for Machine Learning in Python

將數值變數二值化

Feature Engineering for Machine Learning in Python

將數值變數分箱

import numpy as np
df['Binned_Group'] = pd.cut(
    df['Number_of_Violations'], 
    bins=[-np.inf, 0, 2, np.inf],
    labels=[1, 2, 3]
)
Feature Engineering for Machine Learning in Python

將數值變數分箱

Feature Engineering for Machine Learning in Python

一起來練習吧!

Feature Engineering for Machine Learning in Python

Preparing Video For Download...