数值变量

Python 中的机器学习特征工程

Robert O'Callaghan

Director of Data Science, Ordergroove

数值特征类型

  • 年龄
  • 价格
  • 计数
  • 地理空间数据
Python 中的机器学习特征工程

规模重要吗?

Python 中的机器学习特征工程

数值变量二值化

df['Binary_Violation'] = 0

df.loc[df['Number_of_Violations'] > 0, 'Binary_Violation'] = 1
Python 中的机器学习特征工程

数值变量二值化

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]
)
Python 中的机器学习特征工程

数值变量分箱

Python 中的机器学习特征工程

Passons à la pratique !

Python 中的机器学习特征工程

Preparing Video For Download...