การสร้างฟีเจอร์จากข้อความ

การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python

James Chapman

Curriculum Manager, DataCamp

การดึงข้อมูล

  • Regular expressions: โค้ดสำหรับระบุรูปแบบข้อความ
import re

my_string = "temperature:75.6 F"
temp = re.search("\d+\.\d+", my_string)
print(float(temp.group(0)))
75.6
  • \d+
  • \.
  • \d+
การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python

การแปลงข้อความเป็นเวกเตอร์

TF/IDF: แปลงคำเป็นเวกเตอร์โดยอิงจากความสำคัญ

  • TF = Term Frequency
  • IDF = Inverse Document Frequency
การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python

การแปลงข้อความเป็นเวกเตอร์

from sklearn.feature_extraction.text import TfidfVectorizer
print(documents.head())
0    Building on successful events last summer and ...
1               Build a website for an Afghan business
2    Please join us and the students from Mott Hall...
3    The Oxfam Action Corps is a group of dedicated...
4    Stop 'N' Swap reduces NYC's waste by finding n...
tfidf_vec = TfidfVectorizer()
text_tfidf = tfidf_vec.fit_transform(documents)
การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python

การจำแนกประเภทข้อความ

 

$$P(A|B) = \frac{P(B|A)P(A)}{P(B)}$$

การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python

มาฝึกกันเถอะ!

การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python

Preparing Video For Download...