NLP2 | with pythainlp

Truank Kanisorn Saeiaw
Nov 2 · 2 min read
Photo by Frame Harirak on Unsplash

Load data

ดาต้าที่ใช้ในวันนี้นะครับเป็นข้อความภาษาไทย

และมาทำนายว่าข้อความนั้นๆเป็น

Neutral(เป็นกลาง) Negative(เชิงลบ) หรือ Positive(เชิงบวก)

ตัวอย่าง ประโยคที่เป็นกลาง

เชิงลบ

เชิงบวก

หาความยาวของประโยค

โดยประโยคที่ยาวที่สุดมีความยาวถึง 749 มาดูกันว่าเป็นประโยคอะไร

เป็นคำโฆษณานั่นเองครับ

Word2Vec

หรือ Word to vector เป็นการแปลงข้อความให้กลายเป็นตัวเลขครับ

สร้างผลเฉลย

ทำเป็น OneHot

นิยาม และ Compile Model

Train

ลอง Plot ออกมาดูครับ

จะเห็นได้ว่า ค่า Validation loss มีความผันผวนค่อนข้างมาก เนื่องจาก Model มีความ Overfitting มาก และค่า Training loss ไม่เพิ่มตาม ค่า Validation loss อีกด้วยครับ

และผลลัพธ์ที่ได้ออกมา

ขอบคุณครับ

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade