なぜ特徴量を作るのか?

Python で学ぶ Machine Learning のための特徴量エンジニアリング

Robert O'Callaghan

Director of Data Science, Ordergroove

特徴量エンジニアリング

Python で学ぶ Machine Learning のための特徴量エンジニアリング

データの種類

  • 連続値: 整数または浮動小数点
  • カテゴリ: 限られた値のいずれか。例: 性別、出身国
  • 順序尺度: 順位づけのみで距離は不明な値
  • ブール: True/False
  • 日時: 日付と時刻
Python で学ぶ Machine Learning のための特徴量エンジニアリング

コース構成

  • 第1章: 特徴量の作成と抽出

  • 第2章: 乱れたデータの処理

  • 第3章: 特徴量の正規化

  • 第4章: テキスト特徴量の扱い

Python で学ぶ Machine Learning のための特徴量エンジニアリング

Pandas

import pandas as pd  
df = pd.read_csv(path_to_csv_file)
print(df.head())
Python で学ぶ Machine Learning のための特徴量エンジニアリング

データセット

              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.)
Python で学ぶ Machine Learning のための特徴量エンジニアリング

列名

print(df.columns)
Index(['SurveyDate', 'FormalEducation',
       'ConvertedSalary', 'Hobby', 'Country',
       'StackOverflowJobsRecommend', 'VersionControl', 
       'Age', 'Years Experience', 'Gender', 
       'RawSalary'], dtype='object')
Python で学ぶ Machine Learning のための特徴量エンジニアリング

列の型

print(df.dtypes)
SurveyDate                            object
FormalEducation                       object
ConvertedSalary                      float64
...
Years Experience                       int64
Gender                                object
RawSalary                             object
dtype: object
Python で学ぶ Machine Learning のための特徴量エンジニアリング

特定のデータ型を選択

only_ints = df.select_dtypes(include=['int'])
print(only_ints.columns)
Index(['Age', 'Years Experience'], dtype='object')
Python で学ぶ Machine Learning のための特徴量エンジニアリング

始めましょう!

Python で学ぶ Machine Learning のための特徴量エンジニアリング

Preparing Video For Download...