為什麼要產生特徵?

Feature Engineering for Machine Learning in Python

Robert O'Callaghan

Director of Data Science, Ordergroove

特徵工程

Feature Engineering for Machine Learning in Python

資料型態種類

  • 連續:整數(或自然數)或浮點數(小數)
  • 類別:從有限集合中擇一,例如性別、出生國
  • 序位:有排序,彼此距離未定義
  • 布林:True/False 值
  • 日期時間:日期與時間
Feature Engineering for Machine Learning in Python

課程架構

  • 第 1 章:特徵建立與擷取

  • 第 2 章:雜亂資料工程

  • 第 3 章:特徵正規化

  • 第 4 章:文字特徵處理

Feature Engineering for Machine Learning in Python

Pandas

import pandas as pd  
df = pd.read_csv(path_to_csv_file)
print(df.head())
Feature Engineering for Machine Learning in Python

資料集

              SurveyDate  \
0    2018-02-28 20:20:00     
1    2018-06-28 13:26:00     
2    2018-06-06 03:37:00     
3    2018-05-09 01:06:00     
4    2018-04-12 22:41:00    

                              FormalEducation
0    Bachelor's degree (BA. BS. B.Eng.. etc.)
1    Bachelor's degree (BA. BS. B.Eng.. etc.)
2    Bachelor's degree (BA. BS. B.Eng.. etc.)
3    Some college/university study  ...
4    Bachelor's degree (BA. BS. B.Eng.. etc.)
Feature Engineering for Machine Learning in Python

欄位名稱

print(df.columns)
Index(['SurveyDate', 'FormalEducation',
       'ConvertedSalary', 'Hobby', 'Country',
       'StackOverflowJobsRecommend', 'VersionControl', 
       'Age', 'Years Experience', 'Gender', 
       'RawSalary'], dtype='object')
Feature Engineering for Machine Learning in Python

欄位型別

print(df.dtypes)
SurveyDate                            object
FormalEducation                       object
ConvertedSalary                      float64
...
Years Experience                       int64
Gender                                object
RawSalary                             object
dtype: object
Feature Engineering for Machine Learning in Python

選取特定資料型別

only_ints = df.select_dtypes(include=['int'])
print(only_ints.columns)
Index(['Age', 'Years Experience'], dtype='object')
Feature Engineering for Machine Learning in Python

開始上手吧!

Feature Engineering for Machine Learning in Python

Preparing Video For Download...