นอกเหนือจากข้อมูลตัวเลข Cardinal ค่าต่อเนื่อง (Continuous) เราจะพบ Feature ที่เป็นข้อมูลค่าไม่ต่อเนื่อง (Discrete) ในรูปแบบตัวเลขแบบ Ordinal, Nominal หรือข้อความ คือ มีค่าที่เป็นไปได้จำกัด ระบุว่าอยู่หมวดหมู่ไหน เช่น วันในสัปดาห์ 1 จันทร์, 2 อังคาร, 3 พุธ, … คือ 1 ใน 7 ค่าเท่านั้น

เราจะไม่สามารถทำ Rescale, Normalize แบบใน ep 2 ได้ แล้วเราจะเตรียมข้อมูลชนิดนี้อย่างไรดี ถึงจะป้อนให้ Machine Learning ใช้เทรนได้

Hubble Space Telescope-Image of Supernova 1994D (SN1994D) in galaxy NGC 4526 (SN 1994D is the bright spot on the lower left). Credit https://commons.wikimedia.org/wiki/File:SN1994D.jpg
Hubble Space Telescope-Image of Supernova 1994D (SN1994D) in galaxy NGC 4526 (SN 1994D is the bright spot on the lower left). Credit https://commons.wikimedia.org/wiki/File:SN1994D.jpg

Nominal Number ข้อมูลไม่มีลำดับ

Nominal Number ความหมายของข้อมูลไม่มีลำดับเช่น 45 สีแดง, 85 สีเขียว, 52 สีน้ำเงิน, 23 สีเหลือง

เราสามารถใช้ One-Hot Encoding แปลงค่าแต่ละค่า เป็น 1 Dummy Feature ได้

A graphical "matchstick" representation of the ordinal ω². Each stick corresponds to an ordinal of the form ω·m+n where m and n are natural numbers. Credit https://en.wikipedia.org/wiki/Ordinal_number#/media/File:Ordinal_ww.svg
A graphical “matchstick” representation of the ordinal ω². Each stick corresponds to an ordinal of the form ω·m+n where m and n are natural numbers. Credit https://en.wikipedia.org/wiki/Ordinal_number#/media/File:Ordinal_ww.svg

Ordinal Number ข้อมูลมีลำดับ

Ordinal Number ข้อมูลมีลำดับ อยู่ในความหมายของข้อมูล เช่น 100 ปริญญาตรี < 200 ปริญญาโท < 300 ปริญญาเอก

เราจะใช้การ Map 100 ปริญญาตรี = 0, 200 ปริญญาโท = 1, 300 ปริญญาเอก = 2

Tensorboard แสดง Projector ข้อมูล Embedding ลดมิติด้วย T-SNE กรองเฉพาะ Star
Tensorboard แสดง Projector ข้อมูล Embedding ลดมิติด้วย T-SNE กรองเฉพาะ Star

Embedding

เราสามารถนำ Embedding มาใช้กับข้อมูล Category ได้ ทำให้โมเดล Machine Learning จับ Pattern ความหมายที่แฝงอยู่ในแต่ละ Category ได้ดีมากขึ้น ตัวอย่าง เช่น วันจันทร์ อังคาร พุธ พฤหัส ศุกร์ แทนที่จะมองเป็นมิติเดียว อาจะแตกต่างกันพอ ๆ กัน แต่เราสามารถมองเป็นหลายมิติ วันเสาร์ อาทิตย์ อาจใกล้เคียงกันมากกว่า และจับกลุ่มอยู่ห่างคนละ Latent Space กับกลุ่ม 5 วันแรก การใช้ Map เป็นมิติเดียว เป็นเลขเรียงกัน 0-6 หรือ One-Hot Encoding 6 Dummy Feature อาจทำให้สูญเสียความหมายนี้ไป

ใน ep ก่อน ๆ เราได้สอนเรื่อง Embedding ของ User และ Item ใน Collaborative Filtering และการนำ Embedding มาทำ Visualization เพื่อตีความ ให้เข้าใจข้อมูลได้มากขึ้น

เรามาเริ่มกันเลยดีกว่า

Open In Colab

แชร์ให้เพื่อน:

Surapong Kanoktipsatharporn on FacebookSurapong Kanoktipsatharporn on LinkedinSurapong Kanoktipsatharporn on Rss
Surapong Kanoktipsatharporn
Solutions Architect at Bua Labs
The ultimate test of your knowledge is your capacity to convey it to another.

Published by Surapong Kanoktipsatharporn

The ultimate test of your knowledge is your capacity to convey it to another.