11 ธันวาคม 2558

Published ธันวาคม 11, 2558 by with 0 comment

ทำ Machine Learning ด้วย MonkeyLearn กับภาษาไพทอน

สวัสดีผู้อ่านทุกท่านครับ บทความนี้ผมจะขอแนะนำการทำ Machine Learning ด้วย MonkeyLearn กับภาษาไพทอนกันครับ


MonkeyLearn เป็นบริการสร้าง Machine Learning Models For Language Processing แบบออนไลน์ โดยมีรูปแบบการใช้งานที่ง่ายและสะดวกกว่าทำ Machine Learning ด้วยตนเอง (ตอนนี้ยังไม่รองรับภาษาไทย รองรับเฉพาะภาษาอังกฤษ) และรองรับการดึงข้อมูลมาประมวลจาก Social Media ต่าง ๆ ไม่ว่าจะเป็นทวิตเตอร์และอื่น ๆ รองรับการประมวลผลมากมาย ไม่ว่าจะเป็นการหา Keyword จากชุดข้อมูล , การวัดค่า Positive หรือ Negative ของข้อความได้ง่าย ๆ โดยจากตัวอย่างที่บรรจุเข้าไป เป็นต้น

สามารถใช้งานได้ฟรี โดยสามารถ QUERIES ได้ 100,000 ครั้งต่อเดือน และไม่มีการสนับสนุนโดยตรงจาก MonkeyLearn แต่ชุมชนเป็นผู้ให้การสนับสนุนแทน

ลองเข้าไปลองเล่นได้ที่ http://www.monkeylearn.com/

ทาง MonkeyLearn ได้ออก API สำหรับภาษาไพทอนออกมา โดยสามารถติดตั้งได้จาก
pip install monkeylearn

ตัวอย่างการใช้งาน

from monkeylearn import MonkeyLearn

# Use the API key from your account
ml = MonkeyLearn('<YOUR API KEY HERE>')

# Create a new classifier
res = ml.classifiers.create('Test Classifier')

# Get the id of the new module
module_id = res.result['classifier']['hashed_id']

# Get the id of the root node
res = ml.classifiers.detail(module_id)
root_id = res.result['sandbox_categories'][0]['id']

# Create two new categories on the root node
res = ml.classifiers.categories.create(module_id, 'Negative', root_id)
negative_id = res.result['category']['id']
res = ml.classifiers.categories.create(module_id, 'Positive', root_id)
positive_id = res.result['category']['id']

# Now let's upload some samples
samples = [('The movie was terrible, I hated it.', negative_id), ('I love this movie, I want to watch it again!', positive_id)]
res = ml.classifiers.upload_samples(module_id, samples)

# Now let's train the module!
res = ml.classifiers.train(module_id)

# Classify some texts
res = ml.classifiers.classify(module_id, ['I love the movie', 'I hate the movie'], sandbox=True)
print(res.result)


ผลลัพธ์

[[{'label': 'Positive', 'probability': 0.98}], [{'label': 'Negative', 'probabili
ty': 0.989}]]


รายละเอียดเพิ่มเติม https://github.com/monkeylearn/monkeylearn-python

ติดตามบทความต่อไปนะครับ
ขอบคุณครับ

0 ความคิดเห็น:

แสดงความคิดเห็น

แสดงความคิดเห็นได้ครับ :)