ทำไมต้องสร้าง Feature?

Feature Engineering สำหรับ Machine Learning ใน Python

Robert O'Callaghan

Director of Data Science, Ordergroove

Feature Engineering

Feature Engineering สำหรับ Machine Learning ใน Python

ประเภทของข้อมูล

  • ต่อเนื่อง (Continuous): จำนวนเต็มหรือทศนิยม
  • หมวดหมู่ (Categorical): ค่าจากกลุ่มที่จำกัด เช่น เพศ ประเทศ
  • อันดับ (Ordinal): ค่าที่เรียงลำดับ โดยไม่ระบุระยะห่าง
  • บูลีน (Boolean): ค่า True/False
  • วันเวลา (Datetime): วันที่และเวลา
Feature Engineering สำหรับ Machine Learning ใน Python

โครงสร้างคอร์ส

  • บทที่ 1: การสร้างและดึง Feature

  • บทที่ 2: การจัดการข้อมูลที่ไม่เป็นระเบียบ

  • บทที่ 3: การ Normalize Feature

  • บทที่ 4: การทำงานกับ Feature ประเภทข้อความ

Feature Engineering สำหรับ Machine Learning ใน Python

Pandas

import pandas as pd  
df = pd.read_csv(path_to_csv_file)
print(df.head())
Feature Engineering สำหรับ Machine Learning ใน 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 สำหรับ Machine Learning ใน Python

ชื่อคอลัมน์

print(df.columns)
Index(['SurveyDate', 'FormalEducation',
       'ConvertedSalary', 'Hobby', 'Country',
       'StackOverflowJobsRecommend', 'VersionControl', 
       'Age', 'Years Experience', 'Gender', 
       'RawSalary'], dtype='object')
Feature Engineering สำหรับ Machine Learning ใน Python

ประเภทของคอลัมน์

print(df.dtypes)
SurveyDate                            object
FormalEducation                       object
ConvertedSalary                      float64
...
Years Experience                       int64
Gender                                object
RawSalary                             object
dtype: object
Feature Engineering สำหรับ Machine Learning ใน Python

การเลือกประเภทข้อมูลที่ต้องการ

only_ints = df.select_dtypes(include=['int'])
print(only_ints.columns)
Index(['Age', 'Years Experience'], dtype='object')
Feature Engineering สำหรับ Machine Learning ใน Python

มาเริ่มกันเลย!

Feature Engineering สำหรับ Machine Learning ใน Python

Preparing Video For Download...