SlideShare a Scribd company logo
1 of 62
การวิเคราะห์ข้อความ (text)
ด้วย RapidMiner Studio 7
Eakasit Pacharawongsakda, Ph.D.
RapidMiner Ambassador and Certified RapidMiner Analyst
http://dataminingtrend.com http://facebook.com/datacube.th
Structured & Unstructured data
• ข้อมูลแบ่งเป็นแบบมีโครงสร้าง (structure) และไม่มีโครงสร้าง
(unstructure)
• ข้อมูลแบบมีโครงสร้าง เช่น ข้อมูลที่เก็บในรูปแบบตาราง
• ข้อมูลแบบไม่มีโครงสร้าง เช่น ข้อมูลที่เป็นข้อความ ข้อมูลที่เป็นรูปภาพ
2
ID outlook humidity windy play
1 sunny high FALSE no
2 sunny high TRUE no
3 overcast normal FALSE yes
binominalnumeric nominal
http://dataminingtrend.com http://facebook.com/datacube.th
Structured & Unstructured data
• ข้อมูลที่ไม่มีโครงสร้างที่เก็บอยู่ในรูปแบบข้อความ รูปภาพ เสียงมี
จำนวนมากถึง 80% ของข้อมูลทั้งหมด
3
source: http://www.couchbase.com/why-nosql/nosql-database
http://dataminingtrend.com http://facebook.com/datacube.th
Why text is important?
• ข้อมูลที่เป็นประเภทข้อความมีอยู่เป็นจำนวนมาก
• ข้อความใน Social Network ต่างๆ เช่น Facebook, Twitter, LinkedIN
• ข้อความในเอกสารต่างๆ เช่น email, SMS, รายงานต่างๆ
• ข้อความในข่าวต่างๆ เช่น หนังสือพิมพ์, Google News
4source: bangkokpost.com
http://dataminingtrend.com http://facebook.com/datacube.th
Why text is important?
• การประยุกต์ใช้ข้อมูลประเภทข้อความ
• หาข่าวที่ใกล้เคียง
5
source:https://news.google.com
http://dataminingtrend.com http://facebook.com/datacube.th
Why text is important?
• การประยุกต์ใช้ข้อมูลประเภทข้อความ
• วิเคราะห์ทัศนคติในแง่ต่างๆ จากสังคมออนไลน์
6source:http://sentiment140.com และ http://www.techguide.com.au
http://dataminingtrend.com http://facebook.com/datacube.th
Text representation
• ในการวิเคราะห์ข้อมูลข้อความต้องทำการแปลงข้อมูลให้อยู่

ในรูปแบบที่มีโครงสร้าง
7
Laying on the sand sun hitting me, this feels good :)
Smells so good I have two :)
i watched 3 movies today, reminded me of my child hood! Finding Nemo 

was always my favourite, but that was when i was MUCH younger! :)
I think NYC would be amazing, I really wanna go there :)
he never care,he never look at me..:(
i am so tired!! and my feet hurt :(
positive
negative
http://dataminingtrend.com http://facebook.com/datacube.th
Text representation: Bag of Words
• จำนวนความถี่ของคำที่เกิดขึ้นในข้อความ
8
ID Tweet Sentiment
1
Laying on the sand sun hitting
me, this feels good. positive
2 Smells so good I have two. positive
3
i watched 3 movies today,
reminded me of my child hood!
Finding Nemo was always my
favourite, but that was when i
was MUCH younger!
positive
4
I think NYC would be amazing,
I really wanna go there.
positive
5
he never care,he never look at
me.
negative
6
i am so tired!! and my feet
hurt.
negative
Term Count
Finding 1
http://dataminingtrend.com http://facebook.com/datacube.th
Text representation: Bag of Words
• จำนวนความถี่ของคำที่เกิดขึ้นในข้อความ
9
ID Tweet Sentiment
1
Laying on the sand sun hitting
me, this feels good. positive
2 Smells so good I have two. positive
3
i watched 3 movies today,
reminded me of my child hood!
Finding Nemo was always my
favourite, but that was when i
was MUCH younger!
positive
4
I think NYC would be amazing,
I really wanna go there.
positive
5
he never care,he never look at
me.
negative
6
i am so tired!! and my feet
hurt.
negative
Term Count
Finding 1
I 3
http://dataminingtrend.com http://facebook.com/datacube.th
Text representation: Bag of Words
• จำนวนความถี่ของคำที่เกิดขึ้นในข้อความ
10
ID Tweet Sentiment
1
Laying on the sand sun hitting
me, this feels good. positive
2 Smells so good I have two. positive
3
i watched 3 movies today,
reminded me of my child hood!
Finding Nemo was always my
favourite, but that was when i
was MUCH younger!
positive
4
I think NYC would be amazing,
I really wanna go there.
positive
5
he never care,he never look at
me.
negative
6
i am so tired!! and my feet
hurt.
negative
Term Count
Finding 1
I 3
Laying 1
MUCH 1
NYC 1
Nemo 1
Smells 1
always 1
am 1
amazing 1
and 1
at 1
be 1
but 1
care 1
Term Count
child 1
favourite 1
feels 1
feet 1
go 1
good 2
have 1
he 2
hitting 1
hood 1
hurt 1
i 3
look 1
me 1
… 1
bag of words
http://dataminingtrend.com http://facebook.com/datacube.th
Text representation: Stemming
• แปลงคำให้เป็นรากศัพท์ (root) เช่น finding แปลงเป็น find
11
Term Count
child 1
favourite 3
feels 1
feet 1
go 1
good 2
have 1
he 2
hitting 1
hood 1
hurt 1
i 3
look 1
me 1
… 1
Term Count
child 1
favourit 1
feel 1
feet 1
go 1
good 2
have 1
he 2
hit 1
hood 1
hurt 1
i 3
look 1
me 1
… 1
Term Count
Finding 1
I 3
Laying 1
MUCH 1
NYC 1
Nemo 1
Smells 1
always 1
am 1
amazing 1
and 1
at 1
be 1
but 1
care 1
Term Count
find 1
i 6
lai 1
much 1
nyc 1
nemo 1
smell 1
alwai 1
am 1
amaz 1
and 1
at 1
be 1
but 1
care 1
bag of words bag of words
http://dataminingtrend.com http://facebook.com/datacube.th
Text representation: Remove stopwords
• ตัดคำที่เป็น stop word ทิ้ง
12
Term Count
find 1
i 6
lai 1
much 1
nyc 1
nemo 1
smell 1
alwai 1
am 1
amaz 1
and 1
at 1
be 1
but 1
care 1
Term Count
child 1
favourit 1
feel 1
feet 1
go 1
good 2
have 1
he 2
hit 1
hood 1
hurt 1
look 1
me 1
… 1
Term Count
find 1
i 6
lai 1
nyc 1
nemo 1
smell 1
alwai 1
amaz 1
child 1
favorit 1
feel 1
feet 1
go 1
good 2
hit 1
Term Count
hood 1
hurt 1
look 1
care 1
movi 1
reali 1
remind 1
sand 1
sun 1
thi 1
think 1
tire 1
todai 1
wa 3
watch 1
remove stopwords
http://dataminingtrend.com http://facebook.com/datacube.th
Convert text to structured data
• Binary occurrence ถ้ามีคำที่เกิดขึ้นในแต่ละเอกสารจะให้ค่าเป็น 1 

ถ้าไม่เกิดขึ้นจะเป็น 0
13
ID find I lai nyc nemo smell alwai … Sentiment
1 0 0 1 0 0 0 0 … positive
2 0 1 0 0 0 1 0 … positive
3 1 1 0 0 1 0 1 … positive
4 0 1 0 1 0 0 0 … positive
5 0 0 0 0 0 0 0 … negative
6 0 1 0 0 0 0 0 … negative
attribute label
ID Tweet Sentiment
1
Laying on the sand sun hitting
me, this feels good. positive
2 Smells so good I have two. positive
3
i watched 3 movies today,
reminded me of my child hood!
Finding Nemo was always my
favourite, but that was when i
was MUCH younger!
positive
4
I think NYC would be amazing,
I really wanna go there.
positive
5
he never care,he never look at
me.
negative
6
i am so tired!! and my feet
hurt.
negative
training data แสดงคำที่เกิดขึ้นในเอกสารต่างๆ
http://dataminingtrend.com http://facebook.com/datacube.th
Convert text to structured data
• Term Frequency คือจำนวนครั้งที่คำนั้นเกิดขึ้นในเอกสารทั้งหมด
• TF = จำนวนคำที่พิจารณาในเอกสาร/จำนวนคำในเอกสาร
14
ID find I lai nyc nemo … Sentiment
1 0 0 0.17 0 0 … positive
2 0 0.17 0 0 0 … positive
3 0.17 0.33 0 0 0.17 … positive
4 0 0.33 0 0.17 0 … positive
5 0 0 0 0 0 … negative
6 0 0.17 0 0 0 … negative
attribute label
ID Tweet Sentiment
1
Laying on the sand sun hitting
me, this feels good. positive
2 Smells so good I have two. positive
3
i watched 3 movies today,
reminded me of my child hood!
Finding Nemo was always my
favourite, but that was when i
was MUCH younger!
positive
4
I think NYC would be amazing,
I really wanna go there.
positive
5
he never care,he never look at
me.
negative
6
i am so tired!! and my feet
hurt.
negative
training data แสดงคำที่เกิดขึ้นในเอกสารต่างๆ
http://dataminingtrend.com http://facebook.com/datacube.th
Convert text to structured data
• TF-IDF คือจำนวนครั้งของคำที่เกิดขึ้นคูณกับจำนวนคำที่เกิดเฉพาะ
เอกสารในคลาส
15
ID find I lai nyc nemo … Sentiment
1 0 0 0.40 0 0 … positive
2 0 0.19 0 0 0 … positive
3 0.22 0.10 0 0 0.22 … positive
4 0 0.20 0 0.17 0 … positive
5 0 0 0 0 0 … negative
6 0 0.13 0 0 0 … negative
attribute label
ID Tweet Sentiment
1
Laying on the sand sun hitting
me, this feels good. positive
2 Smells so good I have two. positive
3
i watched 3 movies today,
reminded me of my child hood!
Finding Nemo was always my
favourite, but that was when i
was MUCH younger!
positive
4
I think NYC would be amazing,
I really wanna go there.
positive
5
he never care,he never look at
me.
negative
6
i am so tired!! and my feet
hurt.
negative
training data แสดงคำที่เกิดขึ้นในเอกสารต่างๆ
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
16
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
17
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
18
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
19
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
20
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
21
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
22
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
23
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
24
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
25
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
26
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
27
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
28
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
29
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
N-Gram sequences
• จำนวนคำที่พิจารณาต่อกัน N ตัว
• unigram พิจารณาการเกิดขึ้นของแต่ละคำ
• bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good
• tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good
30
Smells so good I have two.
unigram bi-gram tri-gram
smells smells so smells so good
so so good so good I
good good I good I have
I I have I have two
have have two
two
http://dataminingtrend.com http://facebook.com/datacube.th
Install text mining plugin to RM 7
• ติดตั้ง text processing plugin ลงใน RapidMiner Studio 7
• เลือกเมนู Extensions > Marketplace (Updates and Extensions)…
31
http://dataminingtrend.com http://facebook.com/datacube.th
Install text mining plugin to RM 7
• ค้นหา plugin ที่ชื่อว่า text processing
32
1
3
2
4
http://dataminingtrend.com http://facebook.com/datacube.th
Install text mining plugin to RM 7
• เลือก I accept terms of all license agreements.
33
5
6
http://dataminingtrend.com http://facebook.com/datacube.th
Install text mining plugin to RM 7
• RapidMiner Studio 7 จะทำการดาวน์โหลด plugin และติดตั้งให้
34
http://dataminingtrend.com http://facebook.com/datacube.th
Install text mining plugin to RM 7
• หลังจากติดตั้งเสร็จแล้วจะให้ทำการ restart RapidMiner Studio 7
35
7
สัญลักษณ์ของ text
mining plugin
http://dataminingtrend.com http://facebook.com/datacube.th
Install text mining plugin to RM 7
• มีโอเปอเรเตอร์เพิ่มขึ้นมาในส่วนของ Extension folder
36
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• ตัวอย่างข้อมูลจาก Data Science Thailand meetup #1
• ข้อมูลจาก Twitter แบ่งเป็น 2 ประเภท (class)
• Tweet ที่เกี่ยวข้องกับร้านกาแฟ Amazon
• Tweet อื่นๆ ที่ไม่ได้หมายถึงร้านกาแฟ Amazon อาจจะเป็นเว็บไซต์ amazon.com
37
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• ภาพรวมของ Process ที่สร้างขึ้น
38
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• โอเปอเรเตอร์ที่เกี่ยวข้อง
39
โอเปอเรเตอร์ คำอธิบาย
Read CSV
ใช้สำหรับอ่านไฟล์ประเภท CSV มาใช้งาน ในตัวอย่าง Process นี้
อ่านไฟล์ training data มาใช้งาน
Read Excel
ใช้สำหรับอ่านไฟล์ประเภท Excel มาใช้งาน ในตัวอย่าง Process
นี้อ่านไฟล์ testing data มาใช้งาน
Naive Bayes
ใช้สำหรับสร้างโมเดล Naive Bayes เพื่อ classify ข้อมูลออกเป็น
Amazon หรือ Other
Apply Model
ใช้สำหรับนำโมเดล (classification model) ไปทำนาย (predict)
ข้อมูลใหม่
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• โอเปอเรเตอร์ที่เกี่ยวข้อง
40
โอเปอเรเตอร์ คำอธิบาย
Performance ใช้สำหรับวัดประสิทธิภาพของโมเดลที่สร้างขึ้นมา
Validation ใช้สำหรับแบ่งข้อมูลและทำการทดสอบแบบ cross-validation
Process Documents from
Data
ใช้สำหรับสำหรับจัดการข้อความ (text) ที่อ่านได้จากไฟล์
Tokenize ใช้สำหรับตัดคำออกเป็นคำศัพท์ต่างๆ
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• โอเปอเรเตอร์ที่เกี่ยวข้อง
41
โอเปอเรเตอร์ คำอธิบาย
Filter Tokens 

by Length
ใช้สำหรับกรองคำศัพท์ (token) ที่มีค่าน้อยกว่าหรือมากกว่าที่
กำหนด
Stem (Porter)
ใช้สำหรับแปลงคำศัพท์ให้อยู่ในรูปของรากศัพท์ภาษาอังกฤษ
(root)
Filter Stopwords

(English)
ใช้สำหรับตัดคำเชื่อมหรือคำที่ไม่จำเป็นทิ้ง
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• โหลดข้อมูล twitter.csv ด้วยโอเปอเรเตอร์ Read CSV
• เลือกโอเปอเรเตอร์ Read CSV และวางไว้ใน Process
42
3
1
2
4
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เลือกไฟล์ twitter.csv
43
5
6
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เปลี่ยน File Encoding เป็น UTF-8 และเลือก Comma “,”
44
7
8
9
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• คลิกที่ Next ได้เลยครับ
45
10
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เปลี่ยนแอตทริบิวต์ Class ให้เป็น label และ Tweet เป็น text
46
11
12
11
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เพิ่มโอเปอเรเตอร์ Process Document from Data เพื่อทำ preprocess ข้อมูล text
• เลือก vector creation เป็นแบบ TF-IDF
• เลือก prune method เป็น percentual เพื่อ prune คำระหว่าง 3% - 30%
47
15
14
12
13
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• double click ที่โอเปอเรเตอร์ Process Document from Data
• เพิ่มโอเปอเรเตอร์ Tokenize เพื่อตัดคำ และต่อ port doc เข้ากับ Tokenize
48
18
16
17
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เพิ่มโอเปอเรเตอร์ Filter Tokens (by Length) เพื่อลบคำที่สั้นหรือ

ยาวเกินไป
• ต่อ port จาก Tokenize ไปยัง Filter Tokens (by Length)
49
21
19
20
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เพิ่มโอเปอเรเตอร์ Stem (Porter) เพื่อทำ stemming (แปลงข้อมูล

ให้เป็น root)
• ต่อ port จาก Filter Tokens (by Length) ไปยัง Stem (Porter)
50
24
22
23
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เพิ่มโอเปอเรเตอร์ Filter Stopwords เพื่อลบคำที่เป็น stopword ทิ้ง
• ต่อ port จาก Stem (Porter) ไปยัง Filter Stopwords
51
27
25
26
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• ผลการทำงานจะตัดคำต่างๆ ออกมาได้ พร้อมทั้งความถี่ของคำต่างๆ
52
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• ผลการทำงานแสดงข้อมูลในรูปแบบตาราง โดยมีคำต่างๆ เป็น
แอตทริบิวต์
53
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• คลิกขวาในส่วน Main Process และเลือกเมนู Insert Building Block
และเลือกเมนู Nominal X-Validation
• ต่อพอร์ต mod และ ave ของโอเปอเรเตอร์ X-Validation ไปยัง res
54
28
29
30
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• double click ที่โอเปอเรเตอร์ X-Validation
• เปลี่ยนโอเปอเรเตอร์จาก Decision Tree เป็น Naive Bayes แทน
55
31
Training Testing
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• กดปุ่ม Run เพื่อดูผลการทดสอบประสิทธิภาพของโมเดล
56
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• โมเดล NaiveBayes ที่สร้างได้
57
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• หลังจากสร้างโมเดลและวัดประสิทธิภาพได้เรียบร้อยแล้ว ขั้นตอนถัดมาจะเป็นการนำโมเดล
ไปใช้งาน
• ใช้โอเปอเรเตอร์ Read Excel เพื่ออ่านไฟล์ทดสอบที่อยู่ในรูปแบบ Excel
58
34
32
33
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เปลี่ยนแอตทริบิวต์ prediction (Label) ให้เป็น label และ Tweet เป็น text
59
35
36
37
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• copy โอเปอเรเตอร์ Process Documents from Data มาต่อกับ Read Excel 

และต่อพอร์ต wor มาต่อกับโอเปอเรเตอร์ Process Documents from Data
60
38
39
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• เพิ่มโอเปอเรเตอร์ Apply Model เพื่อนำโมเดลไป predict ข้อมูลใหม่
61
30
40
41
42
http://dataminingtrend.com http://facebook.com/datacube.th
Example: Amazon coffee?
• กดปุ่ม Run เพื่อดูผลการ predict
62
ผลการ predict

More Related Content

What's hot

DBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptxDBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptxHong Ong
 
Case Study PDPA Workshop (September 15, 2023)
Case Study PDPA Workshop (September 15, 2023)Case Study PDPA Workshop (September 15, 2023)
Case Study PDPA Workshop (September 15, 2023)Nawanan Theera-Ampornpunt
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerAntonios Chatzipavlis
 
แนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไป
แนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไปแนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไป
แนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไปประพันธ์ เวารัมย์
 
แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...
แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...
แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...ประพันธ์ เวารัมย์
 
The Role of Data Governance in a Data Strategy
The Role of Data Governance in a Data StrategyThe Role of Data Governance in a Data Strategy
The Role of Data Governance in a Data StrategyDATAVERSITY
 
データ分析プラットフォームの歩き方
データ分析プラットフォームの歩き方データ分析プラットフォームの歩き方
データ分析プラットフォームの歩き方Tomoyuki Oota
 
แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)
แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)
แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)waoram
 
Sizing MongoDB Clusters
Sizing MongoDB Clusters Sizing MongoDB Clusters
Sizing MongoDB Clusters MongoDB
 
เสี่ยวเอ้อสอน Spark
เสี่ยวเอ้อสอน Sparkเสี่ยวเอ้อสอน Spark
เสี่ยวเอ้อสอน SparkBhuridech Sudsee
 
Big Data - Applications and Technologies Overview
Big Data - Applications and Technologies OverviewBig Data - Applications and Technologies Overview
Big Data - Applications and Technologies OverviewSivashankar Ganapathy
 

What's hot (20)

First Step to Big Data
First Step to Big DataFirst Step to Big Data
First Step to Big Data
 
Practical Data Mining: FP-Growth
Practical Data Mining: FP-GrowthPractical Data Mining: FP-Growth
Practical Data Mining: FP-Growth
 
03 data preprocessing
03 data preprocessing03 data preprocessing
03 data preprocessing
 
Data mining
Data   miningData   mining
Data mining
 
Introduction to Predictive Analytics with case studies
Introduction to Predictive Analytics with case studiesIntroduction to Predictive Analytics with case studies
Introduction to Predictive Analytics with case studies
 
GDPR for developers
GDPR for developersGDPR for developers
GDPR for developers
 
DBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptxDBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptx
 
Case Study PDPA Workshop (September 15, 2023)
Case Study PDPA Workshop (September 15, 2023)Case Study PDPA Workshop (September 15, 2023)
Case Study PDPA Workshop (September 15, 2023)
 
Building Decision Tree model with numerical attributes
Building Decision Tree model with numerical attributesBuilding Decision Tree model with numerical attributes
Building Decision Tree model with numerical attributes
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL Server
 
แนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไป
แนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไปแนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไป
แนวข้อสอบภาค ก. เล่มที่ 1 ความรู้ความสามารถทั่วไป
 
แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...
แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...
แนวข้อสอบเจ้าพนักงานธุรการ นักวิชาการคอมพิวเตอร์และทุกตำแหน่งอื่นๆที่ต้องมีคว...
 
The Role of Data Governance in a Data Strategy
The Role of Data Governance in a Data StrategyThe Role of Data Governance in a Data Strategy
The Role of Data Governance in a Data Strategy
 
データ分析プラットフォームの歩き方
データ分析プラットフォームの歩き方データ分析プラットフォームの歩き方
データ分析プラットフォームの歩き方
 
แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)
แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)
แนวข้อสอบเจ้าพนักงานธุรการ และนักจัดการงานทั่วไป (เล่มที่ 9)
 
Realtime with websockets
Realtime with websocketsRealtime with websockets
Realtime with websockets
 
Sizing MongoDB Clusters
Sizing MongoDB Clusters Sizing MongoDB Clusters
Sizing MongoDB Clusters
 
เสี่ยวเอ้อสอน Spark
เสี่ยวเอ้อสอน Sparkเสี่ยวเอ้อสอน Spark
เสี่ยวเอ้อสอน Spark
 
Big Data - Applications and Technologies Overview
Big Data - Applications and Technologies OverviewBig Data - Applications and Technologies Overview
Big Data - Applications and Technologies Overview
 
Data cube
Data cubeData cube
Data cube
 

Viewers also liked

Viewers also liked (10)

Search Twitter with RapidMiner Studio 6
Search Twitter with RapidMiner Studio 6Search Twitter with RapidMiner Studio 6
Search Twitter with RapidMiner Studio 6
 
Practical Data Mining with RapidMiner Studio 7 : A Basic and Intermediate
Practical Data Mining with RapidMiner Studio 7 : A Basic and IntermediatePractical Data Mining with RapidMiner Studio 7 : A Basic and Intermediate
Practical Data Mining with RapidMiner Studio 7 : A Basic and Intermediate
 
Evaluation metrics: Precision, Recall, F-Measure, ROC
Evaluation metrics: Precision, Recall, F-Measure, ROCEvaluation metrics: Precision, Recall, F-Measure, ROC
Evaluation metrics: Precision, Recall, F-Measure, ROC
 
What is word2vec?
What is word2vec?What is word2vec?
What is word2vec?
 
การติดตั้ง RapidMiner Studio 6.1
การติดตั้ง RapidMiner Studio 6.1การติดตั้ง RapidMiner Studio 6.1
การติดตั้ง RapidMiner Studio 6.1
 
Predictive analytic-for-retail-business
Predictive analytic-for-retail-businessPredictive analytic-for-retail-business
Predictive analytic-for-retail-business
 
Apply (Big) Data Analytics & Predictive Analytics to Business Application
Apply (Big) Data Analytics & Predictive Analytics to Business ApplicationApply (Big) Data Analytics & Predictive Analytics to Business Application
Apply (Big) Data Analytics & Predictive Analytics to Business Application
 
Install weka extension_rapidminer
Install weka extension_rapidminerInstall weka extension_rapidminer
Install weka extension_rapidminer
 
Data mining and_big_data_web
Data mining and_big_data_webData mining and_big_data_web
Data mining and_big_data_web
 
Introduction to Weka: Application approach
Introduction to Weka: Application approachIntroduction to Weka: Application approach
Introduction to Weka: Application approach
 

Introduction to Text Classification with RapidMiner Studio 7

  • 1. การวิเคราะห์ข้อความ (text) ด้วย RapidMiner Studio 7 Eakasit Pacharawongsakda, Ph.D. RapidMiner Ambassador and Certified RapidMiner Analyst
  • 2. http://dataminingtrend.com http://facebook.com/datacube.th Structured & Unstructured data • ข้อมูลแบ่งเป็นแบบมีโครงสร้าง (structure) และไม่มีโครงสร้าง (unstructure) • ข้อมูลแบบมีโครงสร้าง เช่น ข้อมูลที่เก็บในรูปแบบตาราง • ข้อมูลแบบไม่มีโครงสร้าง เช่น ข้อมูลที่เป็นข้อความ ข้อมูลที่เป็นรูปภาพ 2 ID outlook humidity windy play 1 sunny high FALSE no 2 sunny high TRUE no 3 overcast normal FALSE yes binominalnumeric nominal
  • 3. http://dataminingtrend.com http://facebook.com/datacube.th Structured & Unstructured data • ข้อมูลที่ไม่มีโครงสร้างที่เก็บอยู่ในรูปแบบข้อความ รูปภาพ เสียงมี จำนวนมากถึง 80% ของข้อมูลทั้งหมด 3 source: http://www.couchbase.com/why-nosql/nosql-database
  • 4. http://dataminingtrend.com http://facebook.com/datacube.th Why text is important? • ข้อมูลที่เป็นประเภทข้อความมีอยู่เป็นจำนวนมาก • ข้อความใน Social Network ต่างๆ เช่น Facebook, Twitter, LinkedIN • ข้อความในเอกสารต่างๆ เช่น email, SMS, รายงานต่างๆ • ข้อความในข่าวต่างๆ เช่น หนังสือพิมพ์, Google News 4source: bangkokpost.com
  • 5. http://dataminingtrend.com http://facebook.com/datacube.th Why text is important? • การประยุกต์ใช้ข้อมูลประเภทข้อความ • หาข่าวที่ใกล้เคียง 5 source:https://news.google.com
  • 6. http://dataminingtrend.com http://facebook.com/datacube.th Why text is important? • การประยุกต์ใช้ข้อมูลประเภทข้อความ • วิเคราะห์ทัศนคติในแง่ต่างๆ จากสังคมออนไลน์ 6source:http://sentiment140.com และ http://www.techguide.com.au
  • 7. http://dataminingtrend.com http://facebook.com/datacube.th Text representation • ในการวิเคราะห์ข้อมูลข้อความต้องทำการแปลงข้อมูลให้อยู่
 ในรูปแบบที่มีโครงสร้าง 7 Laying on the sand sun hitting me, this feels good :) Smells so good I have two :) i watched 3 movies today, reminded me of my child hood! Finding Nemo 
 was always my favourite, but that was when i was MUCH younger! :) I think NYC would be amazing, I really wanna go there :) he never care,he never look at me..:( i am so tired!! and my feet hurt :( positive negative
  • 8. http://dataminingtrend.com http://facebook.com/datacube.th Text representation: Bag of Words • จำนวนความถี่ของคำที่เกิดขึ้นในข้อความ 8 ID Tweet Sentiment 1 Laying on the sand sun hitting me, this feels good. positive 2 Smells so good I have two. positive 3 i watched 3 movies today, reminded me of my child hood! Finding Nemo was always my favourite, but that was when i was MUCH younger! positive 4 I think NYC would be amazing, I really wanna go there. positive 5 he never care,he never look at me. negative 6 i am so tired!! and my feet hurt. negative Term Count Finding 1
  • 9. http://dataminingtrend.com http://facebook.com/datacube.th Text representation: Bag of Words • จำนวนความถี่ของคำที่เกิดขึ้นในข้อความ 9 ID Tweet Sentiment 1 Laying on the sand sun hitting me, this feels good. positive 2 Smells so good I have two. positive 3 i watched 3 movies today, reminded me of my child hood! Finding Nemo was always my favourite, but that was when i was MUCH younger! positive 4 I think NYC would be amazing, I really wanna go there. positive 5 he never care,he never look at me. negative 6 i am so tired!! and my feet hurt. negative Term Count Finding 1 I 3
  • 10. http://dataminingtrend.com http://facebook.com/datacube.th Text representation: Bag of Words • จำนวนความถี่ของคำที่เกิดขึ้นในข้อความ 10 ID Tweet Sentiment 1 Laying on the sand sun hitting me, this feels good. positive 2 Smells so good I have two. positive 3 i watched 3 movies today, reminded me of my child hood! Finding Nemo was always my favourite, but that was when i was MUCH younger! positive 4 I think NYC would be amazing, I really wanna go there. positive 5 he never care,he never look at me. negative 6 i am so tired!! and my feet hurt. negative Term Count Finding 1 I 3 Laying 1 MUCH 1 NYC 1 Nemo 1 Smells 1 always 1 am 1 amazing 1 and 1 at 1 be 1 but 1 care 1 Term Count child 1 favourite 1 feels 1 feet 1 go 1 good 2 have 1 he 2 hitting 1 hood 1 hurt 1 i 3 look 1 me 1 … 1 bag of words
  • 11. http://dataminingtrend.com http://facebook.com/datacube.th Text representation: Stemming • แปลงคำให้เป็นรากศัพท์ (root) เช่น finding แปลงเป็น find 11 Term Count child 1 favourite 3 feels 1 feet 1 go 1 good 2 have 1 he 2 hitting 1 hood 1 hurt 1 i 3 look 1 me 1 … 1 Term Count child 1 favourit 1 feel 1 feet 1 go 1 good 2 have 1 he 2 hit 1 hood 1 hurt 1 i 3 look 1 me 1 … 1 Term Count Finding 1 I 3 Laying 1 MUCH 1 NYC 1 Nemo 1 Smells 1 always 1 am 1 amazing 1 and 1 at 1 be 1 but 1 care 1 Term Count find 1 i 6 lai 1 much 1 nyc 1 nemo 1 smell 1 alwai 1 am 1 amaz 1 and 1 at 1 be 1 but 1 care 1 bag of words bag of words
  • 12. http://dataminingtrend.com http://facebook.com/datacube.th Text representation: Remove stopwords • ตัดคำที่เป็น stop word ทิ้ง 12 Term Count find 1 i 6 lai 1 much 1 nyc 1 nemo 1 smell 1 alwai 1 am 1 amaz 1 and 1 at 1 be 1 but 1 care 1 Term Count child 1 favourit 1 feel 1 feet 1 go 1 good 2 have 1 he 2 hit 1 hood 1 hurt 1 look 1 me 1 … 1 Term Count find 1 i 6 lai 1 nyc 1 nemo 1 smell 1 alwai 1 amaz 1 child 1 favorit 1 feel 1 feet 1 go 1 good 2 hit 1 Term Count hood 1 hurt 1 look 1 care 1 movi 1 reali 1 remind 1 sand 1 sun 1 thi 1 think 1 tire 1 todai 1 wa 3 watch 1 remove stopwords
  • 13. http://dataminingtrend.com http://facebook.com/datacube.th Convert text to structured data • Binary occurrence ถ้ามีคำที่เกิดขึ้นในแต่ละเอกสารจะให้ค่าเป็น 1 
 ถ้าไม่เกิดขึ้นจะเป็น 0 13 ID find I lai nyc nemo smell alwai … Sentiment 1 0 0 1 0 0 0 0 … positive 2 0 1 0 0 0 1 0 … positive 3 1 1 0 0 1 0 1 … positive 4 0 1 0 1 0 0 0 … positive 5 0 0 0 0 0 0 0 … negative 6 0 1 0 0 0 0 0 … negative attribute label ID Tweet Sentiment 1 Laying on the sand sun hitting me, this feels good. positive 2 Smells so good I have two. positive 3 i watched 3 movies today, reminded me of my child hood! Finding Nemo was always my favourite, but that was when i was MUCH younger! positive 4 I think NYC would be amazing, I really wanna go there. positive 5 he never care,he never look at me. negative 6 i am so tired!! and my feet hurt. negative training data แสดงคำที่เกิดขึ้นในเอกสารต่างๆ
  • 14. http://dataminingtrend.com http://facebook.com/datacube.th Convert text to structured data • Term Frequency คือจำนวนครั้งที่คำนั้นเกิดขึ้นในเอกสารทั้งหมด • TF = จำนวนคำที่พิจารณาในเอกสาร/จำนวนคำในเอกสาร 14 ID find I lai nyc nemo … Sentiment 1 0 0 0.17 0 0 … positive 2 0 0.17 0 0 0 … positive 3 0.17 0.33 0 0 0.17 … positive 4 0 0.33 0 0.17 0 … positive 5 0 0 0 0 0 … negative 6 0 0.17 0 0 0 … negative attribute label ID Tweet Sentiment 1 Laying on the sand sun hitting me, this feels good. positive 2 Smells so good I have two. positive 3 i watched 3 movies today, reminded me of my child hood! Finding Nemo was always my favourite, but that was when i was MUCH younger! positive 4 I think NYC would be amazing, I really wanna go there. positive 5 he never care,he never look at me. negative 6 i am so tired!! and my feet hurt. negative training data แสดงคำที่เกิดขึ้นในเอกสารต่างๆ
  • 15. http://dataminingtrend.com http://facebook.com/datacube.th Convert text to structured data • TF-IDF คือจำนวนครั้งของคำที่เกิดขึ้นคูณกับจำนวนคำที่เกิดเฉพาะ เอกสารในคลาส 15 ID find I lai nyc nemo … Sentiment 1 0 0 0.40 0 0 … positive 2 0 0.19 0 0 0 … positive 3 0.22 0.10 0 0 0.22 … positive 4 0 0.20 0 0.17 0 … positive 5 0 0 0 0 0 … negative 6 0 0.13 0 0 0 … negative attribute label ID Tweet Sentiment 1 Laying on the sand sun hitting me, this feels good. positive 2 Smells so good I have two. positive 3 i watched 3 movies today, reminded me of my child hood! Finding Nemo was always my favourite, but that was when i was MUCH younger! positive 4 I think NYC would be amazing, I really wanna go there. positive 5 he never care,he never look at me. negative 6 i am so tired!! and my feet hurt. negative training data แสดงคำที่เกิดขึ้นในเอกสารต่างๆ
  • 16. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 16 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 17. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 17 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 18. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 18 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 19. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 19 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 20. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 20 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 21. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 21 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 22. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 22 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 23. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 23 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 24. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 24 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 25. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 25 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 26. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 26 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 27. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 27 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 28. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 28 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 29. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 29 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 30. http://dataminingtrend.com http://facebook.com/datacube.th N-Gram sequences • จำนวนคำที่พิจารณาต่อกัน N ตัว • unigram พิจารณาการเกิดขึ้นของแต่ละคำ • bi-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 2 คำ เช่น so good • tri-gram พิจารณาการเกิดขึ้นของคำที่ติดกัน 3 คำ เช่น smells so good 30 Smells so good I have two. unigram bi-gram tri-gram smells smells so smells so good so so good so good I good good I good I have I I have I have two have have two two
  • 31. http://dataminingtrend.com http://facebook.com/datacube.th Install text mining plugin to RM 7 • ติดตั้ง text processing plugin ลงใน RapidMiner Studio 7 • เลือกเมนู Extensions > Marketplace (Updates and Extensions)… 31
  • 32. http://dataminingtrend.com http://facebook.com/datacube.th Install text mining plugin to RM 7 • ค้นหา plugin ที่ชื่อว่า text processing 32 1 3 2 4
  • 33. http://dataminingtrend.com http://facebook.com/datacube.th Install text mining plugin to RM 7 • เลือก I accept terms of all license agreements. 33 5 6
  • 34. http://dataminingtrend.com http://facebook.com/datacube.th Install text mining plugin to RM 7 • RapidMiner Studio 7 จะทำการดาวน์โหลด plugin และติดตั้งให้ 34
  • 35. http://dataminingtrend.com http://facebook.com/datacube.th Install text mining plugin to RM 7 • หลังจากติดตั้งเสร็จแล้วจะให้ทำการ restart RapidMiner Studio 7 35 7 สัญลักษณ์ของ text mining plugin
  • 36. http://dataminingtrend.com http://facebook.com/datacube.th Install text mining plugin to RM 7 • มีโอเปอเรเตอร์เพิ่มขึ้นมาในส่วนของ Extension folder 36
  • 37. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • ตัวอย่างข้อมูลจาก Data Science Thailand meetup #1 • ข้อมูลจาก Twitter แบ่งเป็น 2 ประเภท (class) • Tweet ที่เกี่ยวข้องกับร้านกาแฟ Amazon • Tweet อื่นๆ ที่ไม่ได้หมายถึงร้านกาแฟ Amazon อาจจะเป็นเว็บไซต์ amazon.com 37
  • 38. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • ภาพรวมของ Process ที่สร้างขึ้น 38
  • 39. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • โอเปอเรเตอร์ที่เกี่ยวข้อง 39 โอเปอเรเตอร์ คำอธิบาย Read CSV ใช้สำหรับอ่านไฟล์ประเภท CSV มาใช้งาน ในตัวอย่าง Process นี้ อ่านไฟล์ training data มาใช้งาน Read Excel ใช้สำหรับอ่านไฟล์ประเภท Excel มาใช้งาน ในตัวอย่าง Process นี้อ่านไฟล์ testing data มาใช้งาน Naive Bayes ใช้สำหรับสร้างโมเดล Naive Bayes เพื่อ classify ข้อมูลออกเป็น Amazon หรือ Other Apply Model ใช้สำหรับนำโมเดล (classification model) ไปทำนาย (predict) ข้อมูลใหม่
  • 40. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • โอเปอเรเตอร์ที่เกี่ยวข้อง 40 โอเปอเรเตอร์ คำอธิบาย Performance ใช้สำหรับวัดประสิทธิภาพของโมเดลที่สร้างขึ้นมา Validation ใช้สำหรับแบ่งข้อมูลและทำการทดสอบแบบ cross-validation Process Documents from Data ใช้สำหรับสำหรับจัดการข้อความ (text) ที่อ่านได้จากไฟล์ Tokenize ใช้สำหรับตัดคำออกเป็นคำศัพท์ต่างๆ
  • 41. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • โอเปอเรเตอร์ที่เกี่ยวข้อง 41 โอเปอเรเตอร์ คำอธิบาย Filter Tokens 
 by Length ใช้สำหรับกรองคำศัพท์ (token) ที่มีค่าน้อยกว่าหรือมากกว่าที่ กำหนด Stem (Porter) ใช้สำหรับแปลงคำศัพท์ให้อยู่ในรูปของรากศัพท์ภาษาอังกฤษ (root) Filter Stopwords
 (English) ใช้สำหรับตัดคำเชื่อมหรือคำที่ไม่จำเป็นทิ้ง
  • 42. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • โหลดข้อมูล twitter.csv ด้วยโอเปอเรเตอร์ Read CSV • เลือกโอเปอเรเตอร์ Read CSV และวางไว้ใน Process 42 3 1 2 4
  • 43. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เลือกไฟล์ twitter.csv 43 5 6
  • 44. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เปลี่ยน File Encoding เป็น UTF-8 และเลือก Comma “,” 44 7 8 9
  • 45. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • คลิกที่ Next ได้เลยครับ 45 10
  • 46. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เปลี่ยนแอตทริบิวต์ Class ให้เป็น label และ Tweet เป็น text 46 11 12 11
  • 47. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เพิ่มโอเปอเรเตอร์ Process Document from Data เพื่อทำ preprocess ข้อมูล text • เลือก vector creation เป็นแบบ TF-IDF • เลือก prune method เป็น percentual เพื่อ prune คำระหว่าง 3% - 30% 47 15 14 12 13
  • 48. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • double click ที่โอเปอเรเตอร์ Process Document from Data • เพิ่มโอเปอเรเตอร์ Tokenize เพื่อตัดคำ และต่อ port doc เข้ากับ Tokenize 48 18 16 17
  • 49. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เพิ่มโอเปอเรเตอร์ Filter Tokens (by Length) เพื่อลบคำที่สั้นหรือ
 ยาวเกินไป • ต่อ port จาก Tokenize ไปยัง Filter Tokens (by Length) 49 21 19 20
  • 50. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เพิ่มโอเปอเรเตอร์ Stem (Porter) เพื่อทำ stemming (แปลงข้อมูล
 ให้เป็น root) • ต่อ port จาก Filter Tokens (by Length) ไปยัง Stem (Porter) 50 24 22 23
  • 51. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เพิ่มโอเปอเรเตอร์ Filter Stopwords เพื่อลบคำที่เป็น stopword ทิ้ง • ต่อ port จาก Stem (Porter) ไปยัง Filter Stopwords 51 27 25 26
  • 52. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • ผลการทำงานจะตัดคำต่างๆ ออกมาได้ พร้อมทั้งความถี่ของคำต่างๆ 52
  • 53. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • ผลการทำงานแสดงข้อมูลในรูปแบบตาราง โดยมีคำต่างๆ เป็น แอตทริบิวต์ 53
  • 54. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • คลิกขวาในส่วน Main Process และเลือกเมนู Insert Building Block และเลือกเมนู Nominal X-Validation • ต่อพอร์ต mod และ ave ของโอเปอเรเตอร์ X-Validation ไปยัง res 54 28 29 30
  • 55. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • double click ที่โอเปอเรเตอร์ X-Validation • เปลี่ยนโอเปอเรเตอร์จาก Decision Tree เป็น Naive Bayes แทน 55 31 Training Testing
  • 56. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • กดปุ่ม Run เพื่อดูผลการทดสอบประสิทธิภาพของโมเดล 56
  • 57. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • โมเดล NaiveBayes ที่สร้างได้ 57
  • 58. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • หลังจากสร้างโมเดลและวัดประสิทธิภาพได้เรียบร้อยแล้ว ขั้นตอนถัดมาจะเป็นการนำโมเดล ไปใช้งาน • ใช้โอเปอเรเตอร์ Read Excel เพื่ออ่านไฟล์ทดสอบที่อยู่ในรูปแบบ Excel 58 34 32 33
  • 59. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เปลี่ยนแอตทริบิวต์ prediction (Label) ให้เป็น label และ Tweet เป็น text 59 35 36 37
  • 60. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • copy โอเปอเรเตอร์ Process Documents from Data มาต่อกับ Read Excel 
 และต่อพอร์ต wor มาต่อกับโอเปอเรเตอร์ Process Documents from Data 60 38 39
  • 61. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • เพิ่มโอเปอเรเตอร์ Apply Model เพื่อนำโมเดลไป predict ข้อมูลใหม่ 61 30 40 41 42
  • 62. http://dataminingtrend.com http://facebook.com/datacube.th Example: Amazon coffee? • กดปุ่ม Run เพื่อดูผลการ predict 62 ผลการ predict