Enviar búsqueda
Cargar
Introduction to Weka: Application approach
•
49 recomendaciones
•
40,480 vistas
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Seguir
This presentation shows how to integrate Weka with your application.
Leer menos
Leer más
Tecnología
Denunciar
Compartir
Denunciar
Compartir
1 de 91
Recomendados
Introduction to Feature (Attribute) Selection with RapidMiner Studio 6
Introduction to Feature (Attribute) Selection with RapidMiner Studio 6
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
04 association
04 association
นนทวัฒน์ บุญบา
1 weka introducing
1 weka introducing
นนทวัฒน์ บุญบา
Practical Data Mining with RapidMiner Studio 7 : A Basic and Intermediate
Practical Data Mining with RapidMiner Studio 7 : A Basic and Intermediate
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
01 introduction to data mining
01 introduction to data mining
นนทวัฒน์ บุญบา
Data manipulation with RapidMiner Studio 7
Data manipulation with RapidMiner Studio 7
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Weka dataprepocessing
Weka dataprepocessing
นนทวัฒน์ บุญบา
Preprocessing with RapidMiner Studio 6
Preprocessing with RapidMiner Studio 6
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Más contenido relacionado
La actualidad más candente
Introduction to Data Mining and Big Data Analytics
Introduction to Data Mining and Big Data Analytics
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Practical Data Mining: FP-Growth
Practical Data Mining: FP-Growth
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Introduction to Data Mining and Big Data Analytics
Introduction to Data Mining and Big Data Analytics
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
การวิเคราะห์ข้อมูลใบเสร็จ7-eleven ด้วย Weka
การวิเคราะห์ข้อมูลใบเสร็จ7-eleven ด้วย Weka
Kannikanune
วิทยาการคำนวณ ม.5 - บทที่ 2 การเก็บรวบรวมและสำรวจข้อมูล
วิทยาการคำนวณ ม.5 - บทที่ 2 การเก็บรวบรวมและสำรวจข้อมูล
Coco Tan
Data mining
Data mining
Kridsada Alfred
05 classification 1 decision tree and rule based classification
05 classification 1 decision tree and rule based classification
นนทวัฒน์ บุญบา
Weka classification
Weka classification
นนทวัฒน์ บุญบา
Data mining and_big_data_web
Data mining and_big_data_web
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
คู่มือ practical data mining with rapid miner studio7
คู่มือ practical data mining with rapid miner studio7
Pitchayanida Khumwichai
เทคโนโลยีสมัยใหม่
เทคโนโลยีสมัยใหม่
Janchai Pokmoonphon
Advanced Predictive Modeling with R and RapidMiner Studio 7
Advanced Predictive Modeling with R and RapidMiner Studio 7
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Introduction to Data Analytics with RapidMiner Studio 6 (ภาษาไทย)
Introduction to Data Analytics with RapidMiner Studio 6 (ภาษาไทย)
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
วิทยาการคำนวณ ม.5 - บทที่ 3 การวิเคราะห์ข้อมูล
วิทยาการคำนวณ ม.5 - บทที่ 3 การวิเคราะห์ข้อมูล
Coco Tan
First Step to Big Data
First Step to Big Data
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Introduction to Text Classification with RapidMiner Studio 7
Introduction to Text Classification with RapidMiner Studio 7
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
06 classification 2 bayesian and instance based classification
06 classification 2 bayesian and instance based classification
นนทวัฒน์ บุญบา
วิทยาการคำนวณ ม.5 - บทที่ 4 การทำข้อมูลให้เป็นภาพ และการสื่อสารด้วยข้อมูล
วิทยาการคำนวณ ม.5 - บทที่ 4 การทำข้อมูลให้เป็นภาพ และการสื่อสารด้วยข้อมูล
Coco Tan
ความพึงพอใจและพฤติกรรมการมีส่วนร่วม Challenge ในแอปพลิเคชัน TikTok
ความพึงพอใจและพฤติกรรมการมีส่วนร่วม Challenge ในแอปพลิเคชัน TikTok
ssuser72c983
03 data preprocessing
03 data preprocessing
นนทวัฒน์ บุญบา
La actualidad más candente
(20)
Introduction to Data Mining and Big Data Analytics
Introduction to Data Mining and Big Data Analytics
Practical Data Mining: FP-Growth
Practical Data Mining: FP-Growth
Introduction to Data Mining and Big Data Analytics
Introduction to Data Mining and Big Data Analytics
การวิเคราะห์ข้อมูลใบเสร็จ7-eleven ด้วย Weka
การวิเคราะห์ข้อมูลใบเสร็จ7-eleven ด้วย Weka
วิทยาการคำนวณ ม.5 - บทที่ 2 การเก็บรวบรวมและสำรวจข้อมูล
วิทยาการคำนวณ ม.5 - บทที่ 2 การเก็บรวบรวมและสำรวจข้อมูล
Data mining
Data mining
05 classification 1 decision tree and rule based classification
05 classification 1 decision tree and rule based classification
Weka classification
Weka classification
Data mining and_big_data_web
Data mining and_big_data_web
คู่มือ practical data mining with rapid miner studio7
คู่มือ practical data mining with rapid miner studio7
เทคโนโลยีสมัยใหม่
เทคโนโลยีสมัยใหม่
Advanced Predictive Modeling with R and RapidMiner Studio 7
Advanced Predictive Modeling with R and RapidMiner Studio 7
Introduction to Data Analytics with RapidMiner Studio 6 (ภาษาไทย)
Introduction to Data Analytics with RapidMiner Studio 6 (ภาษาไทย)
วิทยาการคำนวณ ม.5 - บทที่ 3 การวิเคราะห์ข้อมูล
วิทยาการคำนวณ ม.5 - บทที่ 3 การวิเคราะห์ข้อมูล
First Step to Big Data
First Step to Big Data
Introduction to Text Classification with RapidMiner Studio 7
Introduction to Text Classification with RapidMiner Studio 7
06 classification 2 bayesian and instance based classification
06 classification 2 bayesian and instance based classification
วิทยาการคำนวณ ม.5 - บทที่ 4 การทำข้อมูลให้เป็นภาพ และการสื่อสารด้วยข้อมูล
วิทยาการคำนวณ ม.5 - บทที่ 4 การทำข้อมูลให้เป็นภาพ และการสื่อสารด้วยข้อมูล
ความพึงพอใจและพฤติกรรมการมีส่วนร่วม Challenge ในแอปพลิเคชัน TikTok
ความพึงพอใจและพฤติกรรมการมีส่วนร่วม Challenge ในแอปพลิเคชัน TikTok
03 data preprocessing
03 data preprocessing
Destacado
Search Twitter with RapidMiner Studio 6
Search Twitter with RapidMiner Studio 6
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Evaluation metrics: Precision, Recall, F-Measure, ROC
Evaluation metrics: Precision, Recall, F-Measure, ROC
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
07 classification 3 neural network
07 classification 3 neural network
นนทวัฒน์ บุญบา
การติดตั้ง RapidMiner Studio 6.1
การติดตั้ง RapidMiner Studio 6.1
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Predictive analytic-for-retail-business
Predictive analytic-for-retail-business
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Apply (Big) Data Analytics & Predictive Analytics to Business Application
Apply (Big) Data Analytics & Predictive Analytics to Business Application
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Install weka extension_rapidminer
Install weka extension_rapidminer
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Introduction to Predictive Analytics with case studies
Introduction to Predictive Analytics with case studies
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Building Decision Tree model with numerical attributes
Building Decision Tree model with numerical attributes
Big Data Engineering, Faculty of Engineering, Dhurakij Pundit University
Destacado
(9)
Search Twitter with RapidMiner Studio 6
Search Twitter with RapidMiner Studio 6
Evaluation metrics: Precision, Recall, F-Measure, ROC
Evaluation metrics: Precision, Recall, F-Measure, ROC
07 classification 3 neural network
07 classification 3 neural network
การติดตั้ง RapidMiner Studio 6.1
การติดตั้ง RapidMiner Studio 6.1
Predictive 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 Application
Install weka extension_rapidminer
Install weka extension_rapidminer
Introduction to Predictive Analytics with case studies
Introduction to Predictive Analytics with case studies
Building Decision Tree model with numerical attributes
Building Decision Tree model with numerical attributes
Introduction to Weka: Application approach
1.
(data)3 base|warehouse|mining Store. Analyze. Predict. Introduction
to Weka: Application approach โดย เอกสิทธิ์ พัชรวงศ์ศักดา5 5 หสม. ดาต้า คิวบ์5 http://facebook.com/datacube.th5 http://www.dataminingtrend.com5 1
2.
2 About Us (data)3 ! ชื่อ:
เอกสิทธิ์ พัชรวงศ์ศักดา5 ! การศึกษา5 ! ปริญญาตรี วิศวกรรมคอมพิวเตอร์ มหาวิทยาลัยเกษตรศาสตร์5 ! ปริญญาโท วิศวกรรมคอมพิวเตอร์ มหาวิทยาลัยเกษตรศาสตร์5 ! ศึกษาต่อระดับปริญญาเอก วิทยาการคอมพิวเตอร์ สถาบันเทคโนโลยีนานาชาติสิรินธร มหาวิทยาลัยธรรมศาสตร์ (คาดว่าจะสำเร็จการศึกษาในเร็ววันนี้ !)5 ! ประสบการณ์1 ! วิทยากรประจำหลักสูตร Basic Data Mining with Weka จัดโดย หสม. ดาต้า คิวบ์ 9 ! เขียนบทความเกี่ยวกับการใช้งานโปรแกรม Weka ลงในนิตยสาร OpenSource2Day9 http://facebook.com/datacube.th http://www.dataminingtrend.com
3.
3 About Us (cont’) (data)3 ! ประสบการณ์:9 ! วิทยากรรับเชิญเกี่ยวกับการใช้
Data Mining และ Weka 9 ! มหาวิทยาลัย: SPU, KU, KMUTNB, BU, NRRU9 มหาวิทยาลัยศรีปทุม5 มหาวิทยาลัยเกษตรศาสตร์5 มหาวิทยาลัยเทคโนโลยี5 พระจอมเกล่าพระนครเหนือ5 มหาวิทยาลัยบูรพา5 มหาวิทยาลัยราชภัฏ5 นครราชสีมา5 ! บริษัทเอกชน: TPA, DTAC, REPCO (SCG), SSUP Group, Mono Technology9 http://facebook.com/datacube.th http://www.dataminingtrend.com
4.
About Us (cont’) 4 (data)3 !
ผลงานที่เคยมีส่วนร่วม:1 ! ทำนายโอกาสความสำเร็จในการผลิตฝนหลวง (มหาวิทยาลัยเกษตรศาสตร์)5 ! ในการนำเครื่องบินขึ้นปฏิบัติการเสียค่าใช้จ่ายค่อนข้างสูง5 ! ใช้เทคนิคการจำแนกประเภทข้อมูล (classification) เพื่อคาดการณ์โอกาสสำเร็จในการขึ้น ปฏิบัติการ5 ! ทำนายอารมณ์จากภาพถ่ายบุคคล (มหาวิทยาลัยหอการค้าไทย)5 ! แนะนำรองเท้าที่เหมาะสมให้แก่เด็กอนุบาล (มหาวิทยาลัยศิลปากร)5 ! จัดกลุ่มผู้ใช้งานเครือข่ายสังคม (social network) ที่มีลักษณะคล้ายๆ กัน (มหาวิทยาลัย เกษตรศาสตร์)5 ! แนะนำคำถามที่เกี่ยวข้องหรือคำถามที่พบบ่อยๆ สำหรับ call center (บริษัท TOT จำกัด)5 http://facebook.com/datacube.th http://www.dataminingtrend.com
5.
Statement of Completion 5 (data)3
6.
Outline 6 (data)3 ! Introduction to Weka9 ! Explorer9 ! CLI
(Command Line Interface)9 ! Integrating Weka with PHP9 ! Integrating Weka with Visual C# .Net9 ! Integrating Weka with Java9 ! Example applications9 http://www.facebook.com/datacube.th 8/28/12
7.
Introduction to Weka 7 (data)3 ! Weka1 ! Waikato
Environment for Knowledge Analysis5 ! เป็นซอฟต์แวร์ open source สำหรับการวิเคราะห์ข้อมูลด้วยเทคนิค Data Mining5 ! สามารถดาวน์โหลดมาใช้ได้ ฟรี !!!1 ! พัฒนาด้วยภาษา Java และสามารถทำงานได้บน5 ! Windows5 ! Linux5 ! MAC OS5 ! ดาวน์โหลด Weka ได้จาก 5 ! http://www.cs.waikato.ac.nz/ml/weka/5 http://www.facebook.com/datacube.th 8/28/12
8.
Running the Weka 8 (data)3 ! สำหรับ
Windows5 ! สำหรับ Linux และ Mac OS X5 ! java -jar weka.jar5 http://www.facebook.com/datacube.th 8/28/12
9.
Starting the Weka http://www.facebook.com/datacube.th 9 (data)3 8/28/12
10.
Weka Explorer 10 (data)3 ! ใช้งาน Weka
โดยการคลิกผ่านทางหน้าจอ Interface5 http://www.facebook.com/datacube.th 8/28/12
11.
Weka Experimenter 11 (data)3 ! ใช้เพื่อหาทำการทดลองกับหลายๆ เทคนิค5 5 http://www.facebook.com/datacube.th 8/28/12
12.
Weka Knowledge Flow 12 (data)3 ! นำส่วนการทำงานต่างๆ
มาเชื่อมต่อกันเป็น Flow5 5 http://www.facebook.com/datacube.th 8/28/12
13.
Weka Simple CLI 13 (data)3 ! เรียกใช้งาน
Weka ผ่านทาง command line5 http://www.facebook.com/datacube.th 8/28/12
14.
8/28/12 Weka Explorer http://www.facebook.com/datacube.th 14
15.
Weka Explorer 15 (data)3 Tab สำหรับเรียกใช้งานฟังก์ชัน ต่างๆ
ของ data mining5 Workspace: เป็นส่วนสำคัญของ Weka Explorer จะใช้ในการปรับ เปลี่ยน พารามิเตอร์ต่างๆ และ แสดงผลการทำงาน5 จะเต้นเมื่อกำลังทำงานอยู่5 Status: บอกว่า Wekaกำลังทำงานอะไรอยู่5 http://www.facebook.com/datacube.th Log: เก็บรายละเอียดของการทำงานต่างๆ5 8/28/12
16.
16 Weka Explorer (2) 5 ! Preprocess1 !
เลือกไฟล์ Input จากที่ต่างๆ5 ! ดูรายละเอียดของข้อมูล5 ! แก้ไขข้อมูลที่ไม่มีค่า5 ! แปลงข้อมูล5 ! Classify1 ! จำแนกประเภทข้อมูล (classification)5 ! ทำนาย (prediction) ค่าของข้อมูลใหม่โดยอาศัยข้อมูลเก่า5 http://www.facebook.com/datacube.th (data)3 ! Cluster1 ! แบ่งกลุ่มข้อมูลตามความคล้ายคลึง (similarity)5 ! Associate1 ! หารูปแบบข้อมูลที่เกิดร่วมกันบ่อยๆ5 ! Select attributes1 ! คัดเลือกแอตทริบิวต์ที่สำคัญ5 ! Visualize1 ! แสดงผลของข้อมูลในรูปแบบต่างๆ 8/28/12
17.
17 Data (data)3 หมายเลขสมาชิก2 ชื่อสมาชิก2 เพศ2
อายุ2 รายได้2 19 สมชาย9 ชาย9 209 12,0009 29 สมหญิง9 หญิง9 189 39 สมสมร9 หญิง9 359 35,0009 49 สมจริง9 เด็ก9 59 สมศรี9 หญิง9 3009 20,0009 169 7,0009 4,0009 ! อินสแตนซ์ (Instance)5 ! ข้อมูลที่อยู่ในแนวแถว (row) หรือ เรคอร์ด (record)5 ! เป็นการอธิบายตัวข้อมูลแต่ละตัว โดยจะ ประกอบด้วยหลายๆ แอตทริบิวต์5 ! เช่น รายละเอียดของสมาชิกแต่ละคน1 ! แอตทริบิวต์ (Attribute)5 ! เป็นข้อมูลที่อยู่ในแนวคอลัมน์ (column) หรือ ฟิลด์ (field)5 ! เป็นการอธิบายลักษณะของข้อมูลในแง่มุม ต่างๆ 5 ! เช่น ชื่อสมาชิก, อายุ, เพศ5 http://www.facebook.com/datacube.th 8/28/12
18.
ARFF Format 18 (data)3 ! ARFF File
(Attribute-Relation File Format)9 ! ไฟล์รูปแบบที่ Weka กำหนดขึ้นเอง9 ! แบ่งเป็น 2 ส่วนหลัก9 ! ส่วน Header: ส่วนแสดงรายละเอียดต่างๆ เปรียบได้กับโครงสร้างฐานข้อมูล (database schema)9 ! ชื่อของชุดข้อมูล (relation)9 ! ชื่อของแต่ละแอตทริบิวต์ (attribute)9 ! ประเภทของข้อมูลในแต่ละแอตทริบิวต์ (data type)9 ! ส่วน Data: ส่วนของข้อมูล เปรียบเทียบได้กับข้อมูลที่อยู่ในตารางฐานข้อมูล9 ! ข้อมูลในแอตทริบิวต์ต่างๆ ที่ต้องการใช้ในการวิเคราะห์5 http://www.facebook.com/datacube.th 8/28/12
19.
19 ARFF Format (2) @relation
customers @attribute Customer_ID (data)3 ! Tag พิเศษที่มีในส่วน header ของ9 ไฟล์ ARFF9 real ! @relation <relation-name> 2 ! ใช้ในการบอกชื่อเรียกชุดข้อมูล9 … ! @attribute <attribute-name> <data type>2 @data ! Tag พิเศษที่มีในส่วน data ของไฟล์ ARFF9 ! @data2 @attribute Sex {0,1,2} 1,Somchai,1,20,12000 2,Somying,0,18,7000 3,Somsmall,0,35,35000 4,Somjing,2,16,4000 5,Somsri,0,300,20000 http://www.facebook.com/datacube.th ! ใช้บอกชื่อ แอตทริบิวต์ 9 ! ประเภทของข้อมูลในแอตทริบิวต์นั้นๆ9 ! บรรทัดถัดไปจากนี้จะเป็นส่วนของข้อมูล 9 ! ใช้เครื่องหมาย comma (,) แบ่งแต่ละแอตทริบิวต์9 ! % แทน คอมเมนต์ (comment) หรือคำ อธิบาย5 8/28/12
20.
Load data to
Weka Explorer ! คลิก (data)3 หน้าต่าง Weka GUI Chooser5 ! กดปุ่ม 20 ในแท็บ Preprocess5 ! เลือกไฟล์ ARFF ที่ต้องการโหลดเข้าไปใน Weka5 ! แท็บ Preprocess จะเปลี่ยนไปโดยจะแสดงค่าต่างๆ ดังนี้5 ! Current Relation: เป็นการบอกรายละเอียดของไฟล์ที่ได้ทำการโหลดเข้ามาใช้งาน5 ! Attributes: ส่วนที่ช่วยจัดการเรื่องแอตทริบิวต์ต่างๆ5 ! Selected Attribute: แสดงรายละเอียดของแอตทริบิวต์ที่ได้ทำการเลือกอยู่5 ! Visualization: เป็นการแสดงกราฟรายละเอียดของแต่ละแอตทริบิวต์5 ! Filter: ใช้สำหรับเลือกเทคนิคในการทำ Preprocessing5 http://www.facebook.com/datacube.th 8/28/12
21.
Classify data 21 (data)3 ! คลิกที่แท็บ Classify
5 ! คลิกที่ปุ่ม ] เลือกเทคนิค classification ที่ต้องการใช้งาน5 ! เลือก Weka > classifiers > tress > J485 ! เลือก Test Options เป็นแบบที่ต้องการทดสอบ5 ! เลือก Cross-validation และ Folds เป็น 105 ! กดปุ่ม เพื่อเริ่มการทำงาน5 ! ผลการทำ classification จะแสดงในส่วน Classifier Output5 ! Classification model5 ! ผลการทดสอบโมเดล5 http://www.facebook.com/datacube.th 8/28/12
22.
Clustering data 22 (data)3 ! คลิกที่แท็บ Cluster5 ! คลิกที่ปุ่ม ]
เลือกเทคนิค clustering ที่ต้องการใช้งาน5 ! เลือก Weka > clusters > SimpleKMeans5 ! กดปุ่ม เพื่อเริ่มการทำงาน5 ! ผลการทำ clustering จะแสดงในส่วน Clusterer Output5 ! Center of cluster5 ! จำนวนข้อมูลที่อยู่ในแต่ละคลัสเตอร์5 http://www.facebook.com/datacube.th 8/28/12
23.
Finding association rules 23 (data)3 ! คลิกที่แท็บ
Associate5 ! คลิกที่ปุ่ม ] เลือกเทคนิคการหา association rules ที่ต้องการใช้งาน5 ! เลือก Weka > associations> Apriori5 ! กดปุ่ม เพื่อเริ่มการทำงาน5 ! ผลการหา association rules จะแสดงในส่วน Associator Output5 ! กฏความสัมพันธ์ พร้อมค่า Support และ Confidence5 http://www.facebook.com/datacube.th 8/28/12
24.
8/28/12 Weka Command Line http://www.facebook.com/datacube.th 24
25.
Using Weka CLI 25 (data)3 ! การเรียกใช้งาน
Weka ด้วยการพิมพ์คำสั่งผ่านทาง DOS9 ! พิมพ์ cmd ในช่อง Search programs and files จะปรากฏหน้า DOS (หน้าจอดำๆ)9 http://www.facebook.com/datacube.th 8/28/12
26.
26 Using Weka CLI
(2) (data)3 ! พิมพ์ cd “C:Program FilesWeka-3-6” ในหน้า DOS (cmd)9 ! สร้าง decision tree model ด้วย Weka ผ่านทาง command line9 java -cp weka.jar weka.classifiers.trees.J48 -t dataweather.arff9 9 1 2 3 1 ใช้ในการระบุว่าไฟล์ไลบรารี weka.jar อยู่ในโฟลเดอร์ไหน เช่น “C:Program FilesWeka-3-6”9 2 ใช้ในการบอกว่าจะสร้างโมเดลด้วยวิธี decision tree จากตัวอย่างหมายความว่าเทคนิค J489 อยู่ภายใต้ classifier แบบ tree 9 3 option –t เป็นการบอกว่าจะใช้ไฟล์ไหนเป็นไฟล์ input หรือใช้เป็น training data 5 http://www.facebook.com/datacube.th 8/28/12
27.
Using Weka CLI
(3) http://www.facebook.com/datacube.th 27 (data)3 8/28/12
28.
28 Using Weka CLI
(4) (data)3 ! Option สำหรับการใช้งาน command line5 ! Generic options เป็นการระบุ option ที่สามารถใช้ได้กับทุกๆ วิธีของ data mining 5 Option2 Function2 -t <training file> สำหรับระบุตำแหน่งของไฟล์ที่จะใช้เป็น training file9 -T <testing file> สำหรับระบุตำแหน่งของไฟล์ที่จะใช้เป็น testing file9 -c <class index> สำหรับระบุว่าจะใช้แอตทริบิวต์ไหนเป็น คลาาคำตอบ9 (ปกติจะเป็นแอตทริบิวต์ตัวสุดท้าย)9 -x <number of folds> สำหรับระบุว่าจะใช้การทดสอบแบบ cross-validation กี่ fold9 -d <output file> สำหรับระบุตำแหน่งของไฟล์ที่ใช้เก็บไฟล์โมเดลที่สร้างได้9 -l <input file> สำหรับระบุตำแหน่งของไฟล์ที่ใช้โหลดไฟล์โมเดลเข้ามาใช้9 -p <attribute range> สำหรับการแสดงคลาสทำนายที่ได้9 http://www.facebook.com/datacube.th 8/28/12
29.
Classification Example 29 (data)3 ! สร้างโมเดล (model
training phase)5 java -cp weka.jar weka.classifiers.trees.J48 -t dataweather.arff 9 -d dataweather.model9 ! สร้าง decision tree model เก็บไว้ในไฟล์ชื่อว่า weather.model ภายในโฟลเดอร์ data5 ! ทำนายข้อมูลใหม่ (classification phase)5 X java -cp weka.jar weka.classifiers.trees.J48 -T dataweather.arff 9 -l dataweather.model –p 09 ! -T เป็นการระบุว่าใช้ไฟล์ dataweather.arff เป็น testing data9 ! -l เป็นการระบุว่าใช้ไฟล์ dataweather.model เป็นโมเดลเพื่อใช้ในการทำนาย9 ! -p เป็นกำหนดให้แสดงคลาสที่ทำนายได้ออกมาทางหน้าจอ5 http://www.facebook.com/datacube.th 8/28/12
30.
Clustering Example 30 (data)3 ! พิมพ์ cd
“C:Program FilesWeka-3-6” ในหน้า DOS (cmd)9 ! แบ่งกลุ่มข้อมูลด้วย Weka ผ่านทาง command line9 java -cp weka.jar weka.clusterers.SimpleKMeans -N 2 -t dataweather.arff5 http://www.facebook.com/datacube.th 8/28/12
31.
31 Clustering Example (2) (data)3 ! Output
การแบ่งกลุ่มออกเป็น 2 คลัสเตอร์9 5 จุดศูนย์กลางของ แต่ละคลัสเตอร์1 http://www.facebook.com/datacube.th 8/28/12
32.
Association Rules Example 32 (data)3 ! เทคนิคที่นิยมใช้ในการหากฏความสัมพันธ์
(Association rules) คือ Apriori5 ! ไม่สามารถหากฏความสัมพันธ์กับข้อมูลที่เป็นประเภท “ตัวเลข” ได่้5 ! การหากฏความสัมพันธ์โดยใช้ Weka ผ่านทาง command line5 java -cp weka.jar weka.associations.Apriori -C 0.9 –M 0.5 -t dataexample1.arff5 5 ! option “-M” ใช้สำหรับกำหนดค่า minimum support5 ! option “-C” ใข้สำหรับกำหนดค่า minimum confidence5 ! เพิ่ม option “-I” เพื่อแสดง frequent itemsets5 http://www.facebook.com/datacube.th 8/28/12
33.
Association Rules Example (2) 33 (data)3 ! Output5 กฏความสัมพันธ์ ที่พบ1 http://www.facebook.com/datacube.th 8/28/12
34.
Handle large dataset 34 (data)3 ! Weka
พัฒนาขึ้นด้วยภาษาจาวา (Java) 5 ! จะทำงานบน Virtual Machine (VM) ที่ จาวา สำรองหน่วยความจำไว้ให้5 ! อาจจะมีปัญหาเมื่อทำงานกับข้อมูลที่มีขนาดใหญ่ ซึ่งอาจจะพบ error ว่า5 “Not enough memory. Please load a smaller dataset or use a larger heap size.”5 ! วิธีแก้ปัญหา ทำได้โดยการเพิ่มขนาดของ heap size ของ VM5 java –Xmx1024m –jar weka.jar5 ! Option “-Xmx” เป็นการระบุขนาดของ heap size 5 ! 1024m คือ การระบุว่าจะใช้ heap size เป็นจำนวน 1GB (1024 MB)5 ! การกำหนด heap size ที่เหมาะสมจะต้องขึ้นกับขนาดของ RAM ภายในเครื่อง5 http://www.facebook.com/datacube.th 8/28/12
35.
Convert CSV to
ARFF 35 (data)3 ! ในกรณีที่มีไฟล์ประเภท CSV (Comma Separated Values) อยู่สามารถแปลงให้ เป็นไฟล์ประเภท ARFF ได้โดย5 java -cp weka.jar weka.core.converters.CSVLoader dataweather.csv > 5 dataweather.arff5 http://www.facebook.com/datacube.th 8/28/12
36.
8/28/12 Integrate Weka &
PHP http://www.facebook.com/datacube.th 36
37.
37 Integrate Weka &
PHP (data)3 ! Overview Framework5 Web browser Web application (PHP) Data mining (Weka) Web Server (Apache, IIS) 5 ! องค์ประกอบ5 ! Web server เช่น Apache หรือ IIS5 ! PHP Interpreter สำหรับรันโปรแกรมที่เขียนด้วยภาษา PHP5 ! ไลบรารีของ Weka สำหรับใช้ในการวิเคราะห์ข้อมูลด้วยเทคนิค data mining5 http://www.facebook.com/datacube.th 8/28/12
38.
Integrate Weka &
PHP (2) 38 (data)3 ! สร้างโฟลเดอร์ weka ไว้ภายใต้โฟลเดอร์ C:AppServwww หรือ C:inetpub wwwroot หรือ /var/www9 ! วางไฟล์ไลบรารี weka.jar ไว้ที่โฟลเดอร์ Weka ที่สร้างขึ้นใหม่9 ! ภายใต้โฟลเดอร์ weka สร้างโฟลเดอร์ data และ model สำหรับเก็บไฟล์ตัวอย่าง และไฟล์ classification model ต่าๆ ที่สร้างขึ้น9 ! ดาวน์โหลดไฟล์ข้อมูลต่างๆ จากเว็บไซต์ http://www.open-miner.com/ เพื่อใส่ใน โฟลเดอร์ weka/data9 http://www.facebook.com/datacube.th 8/28/12
39.
Integrate Weka &
PHP (3) 39 (data)3 ! ใช้คำสั่งเหมือนที่ใช้เรียก Weka ผ่านทาง Command Line (line 2-3)5 ! ใช้คำสั่ง exec() เพื่อทำการรันคำสั่งในตัวแปร $cmd (line 2-3)5 ! เก็บผลลัพธ์ไว้ในตัวแปร $output (line 5)5 ! ทำการวน loop เพื่อแสดงผลลัพธ์ผ่านทางหน้า web browser (line 7-10)5 1: <?php 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: ?> $cmd = “java –cp weka.jar weka.clusterers.SimpleKMeans -N 2 –t dataweather.arff”; exec($cmd, $output); for ($i = 0; $i < sizeof($output); $i++) { trim($output[$i]); echo $output[$i].”<br>”; } http://www.facebook.com/datacube.th 8/28/12
40.
Integrate Weka &
PHP (4) 40 (data)3 ! Example5 Input form http://www.facebook.com/datacube.th Clustering output 8/28/12
41.
Classify data 41 (data)3 ! สร้างโมเดล (model
training phase)1 ! ใช้ไฟล์ dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค J48 (decision tree) เพื่อสร้าง classification model (weka.classifiers.trees.J48)5 ! สร้างโมเดลชื่อ weather.model เก็บไว้ในโฟลเดอร์ model (option “-d”)5 1: <?php 2: 3: 4: 5: 5: 6: 7: 8: 9: 10: 11: ?> $cmd = “java -cp weka.jar weka.classifiers.trees.J48 -t dataweather.arff –d modelweather.model”; exec($cmd, $output); for ($i = 0; $i < sizeof($output); $i++) { trim($output[$i]); echo $output[$i].”<br>”; } http://www.facebook.com/datacube.th 8/28/12
42.
42 Classify data (2) (data)3 ! output5 โมเดล decision
tree1 http://www.facebook.com/datacube.th 8/28/12
43.
Classify data (3) 43 (data)3 ! ทำนายข้อมูลใหม่
(Classification)1 ! ใช้ไฟล์ dataweather_test.arff เป็นไฟล์ testing data (option “-T”) 5 ! ใช้โมเดลชื่อ weather.model ที่สร้างขึ้นเพื่อทำนายข้อมูล testing data (option “-l”)1 1: <?php 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: ?> $cmd = “java -cp weka.jar weka.classifiers.trees.J48 -T dataweather_test.arff -l dataweather.model –p 0”; exec($cmd, $output); for ($i = 0; $i < sizeof($output); $i++) { trim($output[$i]); echo $output[$i].”<br>”; } http://www.facebook.com/datacube.th 8/28/12
44.
Classify data (4) 44 (data)3 ! Output5 ! inst#
: หมายเลข instance5 ! actual : คลาสคำตอบในไฟล์ training data5 ! predicted : คลาสที่โมเดลทำนายได้5 ! prediction : ค่าความน่าจะเป็นของ คลาสคำตอบที่โมเดลทำนายได้5 http://www.facebook.com/datacube.th ผลการทำนาย1 8/28/12
45.
Cluster data 45 (data)3 ! คลัสเตอริ่งที่แสดงเฉพาะข้อมูล centroid
ของแต่ละคัลสเตอร์5 ! ใช้ไฟล์ dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค SimpleKMeans เพื่อทำการแบ่งกลุ่มข้อมูล (weka.clusterers.SimpleKMeans)5 ! สามารถกำหนดจำนวนคลัสเตอร์ได้จาก option “-N”5 1: <?php 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: ?> $cmd = “java –cp weka.jar weka.clusterers.SimpleKMeans -N 2 –t dataweather.arff”; exec($cmd, $output); for ($i = 0; $i < sizeof($output); $i++) { trim($output[$i]); echo $output[$i].”<br>”; } http://www.facebook.com/datacube.th 8/28/12
46.
46 Cluster data (2) (data)3 ! Output5 จุดศูนย์กลางของ แต่ละคลัสเตอร์1 http://www.facebook.com/datacube.th 8/28/12
47.
Cluster data (3) 47 (data)3 ! คลัสเตอริ่งเพื่อระบุหมายเลขคลัสเตอร์ให้กับข้อมูล5 ! ใช้ไฟล์
dataweather.arff เป็นไฟล์ input data (option “-i”) สำหรับเทคนิค AddCluster5 ! ใช้เทคนิค weka.filters.unsupervised.attribute.AddCluster เพื่อเพิ่มหมายเลขคลัสเตอร์ให้กับ ข้อมูลแต่ละ instance5 ! ใช้เทคนิค SimpleKMeans เพื่อทำการแบ่งกลุ่มข้อมูล (weka.clusterers.SimpleKMeans)5 ! สามารถกำหนดจำนวนคลัสเตอร์ได้จาก option “-N”5 1: <?php ! ผลลัพธ์อยู่ในไฟล์ cluster_result.arff (option “-o”)5 2: 3: 4: 5: 6: 7: 5: ?> $cmd = “java -cp weka.jar weka.filters.unsupervised.attribute.AddCluster -W "weka.clusterers.SimpleKMeans -N 2" -i dataweather.arff –o datacluster_results.arff”; exec($cmd, $output); http://www.facebook.com/datacube.th 8/28/12
48.
Clustering data (4) 48 (data)3 ! Output5 ! มีแอตทริบิวต์
cluster 5 เพิ่มขึ้นมา5 ! สามารถแบ่งแยกข้อมูล5 ออกตามแต่ละคลัสเตอร์5 http://www.facebook.com/datacube.th ข้อมูลพร้อม หมายเลขคลัสเตอร์1 8/28/12
49.
Finding Association Rules 49 (data)3 ! หากฏความสัมพันธ์ด้วยเทคนิค
Apriori5 ! ใช้ไฟล์ dataexample1.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค Apriori เพื่อทำการแบ่งกลุ่มข้อมูล (weka.associations.Apriori)5 ! สามารถกำหนดค่า min_sup และ min_conf ด้วย option “-M” และ “-C”5 1: <?php 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: ?> $cmd = “java -cp weka.jar weka.associations.Apriori -C 0.9 –M 0.5 -t dataexample1.arff”; exec($cmd, $output); for ($i = 0; $i < sizeof($output); $i++) { trim($output[$i]); echo $output[$i].”<br>”; } http://www.facebook.com/datacube.th 8/28/12
50.
Finding Association Rules
[2] 50 (data)3 ! Output5 กฏความสัมพันธ์ที่พบ1 http://www.facebook.com/datacube.th 8/28/12
51.
Asynchronous mode 51 (data)3 ! การใช้ฟังก์ชัน
exec() ของ PHP จะเป็นการทำงานแบบ synchronous 5 ! ต้องรอ Weka ทำงานให้เสร็จก่อนจึงจะแสดงผลออกมาที่ web browser5 ! อาจจะมีปัญหาถ้าใช้โปรแกรม Weka ทำการวิเคราะห์ข้อมูลที่มีขนาดใหญ่ๆ เนื่องจากต้องรอผลการรันและอาจจะทำให้ session expire หรือ timeout ไปก่อน5 ! วิธีการหนึ่งที่สามารถแก้ไขได้คือการเรียก Weka แบบ asynchronous mode 5 ! สั่งให้ Weka ทำงานแบบ background 5 ! ไม่ต้องรอให้ Weka ทำงานเสร็จ 5 ! เมื่อ weka ทำงานเสร็จแล้วให้บันทึกผลลงในไฟล์ หรือ ฐานข้อมูล5 ! Windows 5 ! ใช้คำสั่ง “start cmd /c” เพื่อสั่งให้ทำงานใน window ใหม่5 ! Linux/Mac OS X5 ! เพิ่ม option ‘&’ ต่อท้ายเพื่อให้ทำงานแบบ background5 http://www.facebook.com/datacube.th 5 8/28/12
52.
Asynchronous mode (2) 52 (data)3 ! Windows5 9 9 1:
<?php 2: $cmd = “start cmd /c java -cp weka.jar 3: weka.classifiers.trees.J48 -t dataweather.arff 4: -d modelweather.model ^> classification_output.txt”; 5: 6: exec($cmd, $output); 5: 11: ?> 9 ! ใช้คำสั่ง “start cmd /c” เพื่อสั่งให้ทำงานในหน้าต่างอื่นแทน9 ! สร้างไฟล์โมเดลเก็บไว้ในโฟลเดอร์ weather.model9 ! เก็บผลลัพธ์การทำงานไว่ในไฟล์ classification_output.txt5 http://www.facebook.com/datacube.th 8/28/12
53.
Asynchronous mode (3) 53 (data)3 ! Linux/Mac
OS X5 1: <?php 2: $cmd = “java -cp weka.jar weka.classifiers.trees.J48 3: -t dataweather.arff -d modelweather.model 4: > classification_output.txt &”; 5: 6: exec($cmd, $output); 5: 11: ?> 9 ! ใช้คำสั่ง “&” ต่อท้ายคำสั่งทำให้ทำงานในแบบ background9 ! สร้างไฟล์โมเดลเก็บไว้ในโฟลเดอร์ weather.model9 ! เก็บผลลัพธ์การทำงานไว่ในไฟล์ classification_output.txt5 5 http://www.facebook.com/datacube.th 8/28/12
54.
8/28/12 Integrate Weka &
C# http://www.facebook.com/datacube.th 54
55.
55 Integrate Weka &
C# (data)3 ! Overview Framework5 Standalone application (C# .Net) Data mining (Weka) .NET Framework 5 ! องค์ประกอบ5 ! Microsoft .Net Framework สำหรับใช้รันภาษา C#5 ! ไลบรารีของ Weka สำหรับใช้ในการวิเคราะห์ข้อมูลด้วยเทคนิค data mining5 http://facebook.com/datacube.th http://www.dataminingtrend.com
56.
56 Integrate Weka &
C# (2) (data)3 ! ใช้ method run_cmd เพื่อรับคำสั่งในการทำงานผ่านทาง command line5 1: private string run_cmd(String cmd) 2: { 3: StreamWriter sw; // Handles strings sent to CMD.exe 4: StreamReader sr; // Reads text back from CMD.exe 5: StreamReader err; // Returns all errors from CMD.exe 6: Process dir = new Process(); // Will run CMD.EXE for you 7: String output; 8: 9: 10: 11: 12: 13: dir.StartInfo.FileName = "CMD.EXE"; dir.StartInfo.UseShellExecute = false; dir.StartInfo.CreateNoWindow = true; dir.StartInfo.RedirectStandardInput = true; dir.StartInfo.RedirectStandardError = true; dir.StartInfo.RedirectStandardOutput = true; // Continue to next slide http://facebook.com/datacube.th http://www.dataminingtrend.com
57.
57 Integrate Weka &
C# (3) (data)3 ! ใช้ method run_cmd เพื่อรับคำสั่งในการทำงานผ่านทาง command line5 // Continue from previous slide 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: dir.Start(); // Runs CMD.exe sw = dir.StandardInput; sr = dir.StandardOutput; err = dir.StandardError; sw.AutoFlush = true; sw.WriteLine(cmd); // Sends strings to CMD.EXE output = sr.ReadToEnd().ToString(); sw.Close(); sr.Close(); err.Close(); return output; } http://facebook.com/datacube.th http://www.dataminingtrend.com
58.
58 Integrate Weka &
C# (4) (data)3 ! ตัวอย่างการเรียกใช้ methon run_cmd เพื่อทำการ clustering5 ! ต้องระบุ path ของโปรแกรม weka (line 4)5 1: public Form1() 2: { 3: InitializeComponent(); 4: String weka_path = "C:Program FilesWeka-3-6"; 5: String cmd = "java -cp "" + weka_path + "weka.jar" 6: weka.clusterers.SimpleKMeans -N 2 -t "" + 7: weka_path + "dataweather.arff""; 8: String output = run_weka(cmd); 9: MessageBox.Show(output); 10: } http://facebook.com/datacube.th http://www.dataminingtrend.com
59.
59 Integrate Weka &
C# (5) (data)3 ! Output5 ผลการทำคลัสเตอริ่ง1 http://facebook.com/datacube.th http://www.dataminingtrend.com
60.
Classify data 60 (data)3 ! สร้างโมเดล (model
training phase)1 ! ใช้ไฟล์ dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค J48 (decision tree) เพื่อสร้าง classification model (weka.classifiers.trees.J48)5 ! สร้างโมเดลชื่อ weather.model เก็บไว้ในโฟลเดอร์ model (option “-d”)5 1: public create_model() 2: { 3: 4: String weka_path = "C:Program FilesWeka-3-6"; 5: String cmd = "java -cp "" + weka_path + "weka.jar" 6: weka.classifiers.trees.J48 -t "" + 7: weka_path + "dataweather.arff” + 8: " -d "" + weka_path + "modelweather.model""; 9: String output = run_weka(cmd); 10: MessageBox.Show(output); 11: } http://facebook.com/datacube.th http://www.dataminingtrend.com
61.
61 Classify data (2) (data)3 ! output5 โมเดล decision
tree1 http://facebook.com/datacube.th http://www.dataminingtrend.com
62.
62 Classify data (3) (data)3 ! ทำนายข้อมูลใหม่
(Classification)1 ! ใช้ไฟล์ dataweather_test.arff เป็นไฟล์ testing data (option “-T”) 5 ! ใช้โมเดลชื่อ weather.model ที่สร้างขึ้นเพื่อทำนายข้อมูล testing data (option “-l”)1 1: public test_model() 2: { 3: 4: String weka_path = "C:Program FilesWeka-3-6"; 5: String cmd = "java -cp "" + weka_path + "weka.jar" 6: weka.classifiers.trees.J48 -T "" + 7: weka_path + "dataweather_test.arff” + 8: " -l "" + weka_path + "modelweather.model” –p 0"; 9: String output = run_weka(cmd); 10: MessageBox.Show(output); 11: } http://facebook.com/datacube.th http://www.dataminingtrend.com
63.
Classify data (4) 63 (data)3 ! Output5 ! inst#
: หมายเลข instance5 ! actual : คลาสคำตอบในไฟล์ training data5 ! predicted : คลาสที่โมเดลทำนายได้5 ! prediction : ค่าความน่าจะเป็นของคลาส5 คำตอบที่โมเดลทำนายได้5 http://facebook.com/datacube.th ผลการทำนาย1 http://www.dataminingtrend.com
64.
64 Cluster data (data)3 ! คลัสเตอริ่งที่แสดงเฉพาะข้อมูล centroid
ของแต่ละคัลสเตอร์5 ! ใช้ไฟล์ dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค SimpleKMeans เพื่อทำการแบ่งกลุ่มข้อมูล (weka.clusterers.SimpleKMeans)5 ! สามารถกำหนดจำนวนคลัสเตอร์ได้จาก option “-N”5 1: public run_clustering() 2: { 3: 4: String weka_path = "C:Program FilesWeka-3-6"; 5: String cmd = "java -cp "" + weka_path + "weka.jar" 6: weka.clusterers.SimpleKMeans -N 2 -t "" + 7: weka_path + "dataweather.arff""; 8: String output = run_weka(cmd); 9: MessageBox.Show(output); 10: } http://facebook.com/datacube.th http://www.dataminingtrend.com
65.
65 Cluster data (2) (data)3 ! Output5 จุดศูนย์กลางของ แต่ละคลัสเตอร์1 http://facebook.com/datacube.th http://www.dataminingtrend.com
66.
66 Cluster data (3) (data)3 ! คลัสเตอริ่งเพื่อระบุหมายเลขคลัสเตอร์ให้กับข้อมูล5 ! ใช้ไฟล์
dataweather.arff เป็นไฟล์ input data (option “-i”) สำหรับเทคนิค AddCluster5 ! ใช้เทคนิค weka.filters.unsupervised.attribute.AddCluster เพื่อเพิ่มหมายเลขคลัสเตอร์ให้กับ ข้อมูลแต่ละ instance5 ! ใช้เทคนิค SimpleKMeans เพื่อทำการแบ่งกลุ่มข้อมูล (weka.clusterers.SimpleKMeans)5 1: ! ผลลัพธ์อrun_clustering_detail() public ยู่ในไฟล์ cluster_result.arff (option “-o”)5 2: { 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: } String weka_path = "C:Program FilesWeka-3-6"; String cmd = "java -cp "" + weka_path + "weka.jar" weka.filters.unsupervised.attribute.AddCluster -W "weka.clusterers.SimpleKMeans -N 2" -i "" + weka_path + "dataweather.arff" –o "" + weka_path + "datacluster_output.arff""; String output = run_weka(cmd); MessageBox.Show(output); http://facebook.com/datacube.th http://www.dataminingtrend.com
67.
Clustering data (4) 67 (data)3 ! Output5 ! มีแอตทริบิวต์
cluster 5 เพิ่มขึ้นมา5 ! สามารถแบ่งแยกข้อมูล5 ออกตามแต่ละคลัสเตอร์5 http://facebook.com/datacube.th ข้อมูลพร้อม หมายเลขคลัสเตอร์1 http://www.dataminingtrend.com
68.
68 Finding Association Rules (data)3 ! หากฏความสัมพันธ์ด้วยเทคนิค
Apriori5 ! ใช้ไฟล์ dataexample1.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค Apriori เพื่อทำการแบ่งกลุ่มข้อมูล (weka.associations.Apriori)5 ! สามารถกำหนดค่า min_sup และ min_conf ด้วย option “-M” และ “-C”5 1: public run_association_rules() 2: { 3: 4: String weka_path = "C:Program FilesWeka-3-6"; 5: String cmd = "java -cp "" + weka_path + "weka.jar" 6: weka.associations.Apriori -C 0.9 -M 0.5 7: -t ”” + weka_path + "dataexample1.arff""; 8: String output = run_weka(cmd); 9: MessageBox.Show(output); 10: } http://facebook.com/datacube.th http://www.dataminingtrend.com
69.
Finding Association Rules
(2) 69 (data)3 ! Output5 กฏความสัมพันธ์ที่พบ1 http://facebook.com/datacube.th http://www.dataminingtrend.com
70.
8/28/12 Integrate Weka &
Java http://www.facebook.com/datacube.th 70
71.
71 Integrate Weka &
Java (data)3 ! Overview Framework5 Standalone application (Java) Data mining (Weka) Java Virtual Machine (JVM) 5 ! องค์ประกอบ5 ! Java Virtual Machine (JVM) ใช้สำหรับรันโปรแกรมภาษาจาวา5 ! ไลบรารีของ Weka สำหรับใช้ในการวิเคราะห์ข้อมูลด้วยเทคนิค data mining5 http://facebook.com/datacube.th http://www.dataminingtrend.com
72.
72 Integrate Weka &
Java (2) (data)3 ! import แพ็คเก็จ (package) ของ Weka เข้ามาใช้งาน เช่น5 ! !import weka.classifiers.trees.j48 สำหรับใช้งาน decision tree (J48)5 ! import weka.classifiers.bayes.NaiveBayes สำหรับใช้งาน NaïveBayes5 ! package ดูได้จาก5 5 ! คลิกขวาที่5 http://facebook.com/datacube.th http://www.dataminingtrend.com
73.
Integrate Weka &
Java (3) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 73 (data)3 import weka.classifiers.trees.*; import weka.classifiers.trees.j48.*; option ที่ใช้ใน import java.util.*; import weka.core.*; CLI1 Include package เพื่อใช้ import weka.classifiers.*; ในการทำ classification1 class testClassifier { public static void main(String[] argv) { String argument = "-t dataweather.arff –d modelweather.model"; argv = argument.split(" "); try { System.out.println(Evaluation.evaluateModel(new J48(), argv)); } catch (Exception e) { System.err.println(e.getMessage()); } } } http://facebook.com/datacube.th http://www.dataminingtrend.com
74.
74 Integrate Weka &
Java (4) (data)3 ! ขั้นตอนการ compile โปรแกรม5 5 javac -classpath “C:Program FilesWeka-3-6weka.jar” testClassifier.java ! ขั้นตอนการ run โปรแกรม5 java -classpath testClassifier http://facebook.com/datacube.th “C:Program FilesWeka-3-6weka.jar;.” http://www.dataminingtrend.com
75.
Integrate Weka &
Java (5) 75 (data)3 ! Output5 http://facebook.com/datacube.th http://www.dataminingtrend.com
76.
Classify data 76 (data)3 ! สร้างโมเดล (model
training phase)1 ! ใช้ไฟล์ dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค J48 (decision tree) เพื่อสร้าง classification model (weka.classifiers.trees.J48)5 ! สร้างโมเดลชื่อ weather.model เก็บไว้ในโฟลเดอร์ model (option “-d”)5 1: public static void main(String[] argv) 2: { 3: testClassifier tc = new testClassifier(); 4: tc.buildClassifier("dataweather.arff",”dataweather.model”); 5: 6: } http://facebook.com/datacube.th http://www.dataminingtrend.com
77.
77 Classify data (2) (data)3 7:
public void buildClassifier(String training_file, String model_file) 8: { 9: String[] argv = null; 10: String argument = "-t " + training_file + " -d "+ model_file; 11: String result = ""; 12: String[] stat = null; 13: argv = argument.split(" "); 14: try { 15: result = Evaluation.evaluateModel(new J48(), argv); 16: 17: stat = result.split("n"); 18: for (int i = 0; i < stat.length; i++) { 19: System.out.println("" + i + " " + stat[i]); 20: } 21: } catch (Exception e) { 22: System.err.println(e.getMessage()); 23: } 24: } http://facebook.com/datacube.th http://www.dataminingtrend.com
78.
Classify data (3) 78 (data)3 ! output5 โมเดล decision
tree1 http://facebook.com/datacube.th http://www.dataminingtrend.com
79.
79 Classify data (4) (data)3 ! ทำนายข้อมูลใหม่
(Classification)1 ! ใช้ไฟล์ dataweather_test.arff เป็นไฟล์ testing data (option “-T”) 5 ! ใช้โมเดลชื่อ weather.model ที่สร้างขึ้นเพื่อทำนายข้อมูล testing data (option “-l”)1 1: public static void main(String[] argv) 2: { 3: testClassifier tc = new testClassifier(); 4: tc.predict(”modelweather.model","dataweather_test.arff"); 5: 6: } http://facebook.com/datacube.th http://www.dataminingtrend.com
80.
Classify data (5) 80 (data)3 7:
public void predict(String model_file, String testing_file) { 8: String[] argv = null; 9: String argument = " -l "+ model_file + " -T "+ testing_file + " -p 0"; 10: String result; 11: argv = argument.split(" "); 12: try { 13: result = Evaluation.evaluateModel(new J48(), argv); 14: System.out.println(result); 15: } catch (Exception e) { 16: System.err.println(e.getMessage()); 17: } 18: } http://facebook.com/datacube.th http://www.dataminingtrend.com
81.
Classify data (6) ! Output5 81 (data)3 ผลการทำนาย1 ! inst#
: หมายเลข instance5 ! actual : คลาสคำตอบในไฟล์ 5 training data5 ! predicted : คลาสที่โมเดลทำนายได้5 ! prediction : ค่าความน่าจะเป็นของ5 คลาสคำตอบที่โมเดลทำนายได้5 http://facebook.com/datacube.th http://www.dataminingtrend.com
82.
Cluster data 82 (data)3 ! คลัสเตอริ่งที่แสดงเฉพาะข้อมูล centroid
ของแต่ละคัลสเตอร์5 ! ใช้ไฟล์ dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค SimpleKMeans เพื่อทำการแบ่งกลุ่มข้อมูล (weka.clusterers.SimpleKMeans)5 ! สามารถกำหนดจำนวนคลัสเตอร์ได้จาก option “-N”5 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: import java.io.*; import java.util.*; import weka.core.*; import weka.clusterers.*; import weka.clusterers.SimpleKMeans; import weka.clusterers.ClusterEvaluation; import weka.clusterers.Clusterer; class testClusterer public static void main(String[] argv) { testClusterer tc = new testClusterer(); tc.cluster("dataweather.arff",2); } http://facebook.com/datacube.th http://www.dataminingtrend.com
83.
Cluster data (2) 83 (data)3 14:
public void cluster(String training_file, int k) { 15: String[] options = null; 16: String argument = "-N "+ k +" -t " + training_file; 17: String result = ""; 18: String[] stat = null; 19: options = argument.split(" "); 20: String trainFileString; 21: StringBuffer text = new StringBuffer(); 22: Reader reader; 23: try { 24: SimpleKMeans clusterer = new SimpleKMeans(); 25: clusterer.setOptions(options); 26: trainFileString = Utils.getOption('t', options); 27: reader = new BufferedReader(new FileReader(trainFileString)); 28: clusterer.buildClusterer(new Instances(reader)); 29: System.out.println(clusterer); 30: } catch (Exception e) { 31: System.err.println(e.getMessage()); 32: } 33: } http://facebook.com/datacube.th http://www.dataminingtrend.com
84.
84 Cluster data (3) (data)3 ! Output5 จุดศูนย์กลางของ แต่ละคลัสเตอร์1 http://facebook.com/datacube.th http://www.dataminingtrend.com
85.
Cluster data (4) 85 (data)3 ! คลัสเตอริ่งเพื่อระบุหมายเลขคลัสเตอร์ให้กับข้อมูล5 ! ใช้ไฟล์
dataweather.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค SimpleKMeans เพื่อทำการแบ่งกลุ่มข้อมูล (weka.clusterers.SimpleKMeans)5 ! สามารถกำหนดจำนวนคลัสเตอร์ได้จาก option “-N”5 ! ต้องใช้ option “-O” เพื่อ preserve order of instances5 5 1: int[] assignments = clusterer.getAssignments(); 2: int i=0; 3: for(int clusterNum : assignments) { 4: System.out.printf("Instance %d -> Cluster %dn", i, clusterNum); 5: i++; 6: } http://facebook.com/datacube.th http://www.dataminingtrend.com
86.
Clustering data (5) 86 (data)3 14:
public void cluster(String training_file, int k) { 15: String[] options = null; 16: String argument = "-N "+ k +” -O -t " + training_file; 17: String result = ""; 18: String[] stat = null; 19: options = argument.split(" "); 20: String trainFileString; 21: StringBuffer text = new StringBuffer(); 22: Reader reader; 23: try { 24: SimpleKMeans clusterer = new SimpleKMeans(); 25: clusterer.setOptions(options); 26: trainFileString = Utils.getOption('t', options); 27: reader = new BufferedReader(new FileReader(trainFileString)); 28: clusterer.buildClusterer(new Instances(reader)); 29: System.out.println(clusterer); 30: int[] assignments = clusterer.getAssignments(); 31: int i=0; 32: for(int clusterNum : assignments) { 33: System.out.printf("Instance %d -> Cluster %dn", i, clusterNum); 34: i++; 35: } 36: } catch (Exception e) { 37: System.err.println(e.getMessage()); 38: } http://www.dataminingtrend.com http://facebook.com/datacube.th http://www.open-miner.com 8/28/12 39: }
87.
87 Clustering data (6) (data)3 ! Output5 ! มีแอตทริบิวต์
cluster 5 เพิ่มขึ้นมา5 ! สามารถแบ่งแยกข้อมูล5 ออกตามแต่ละคลัสเตอร์5 ข้อมูลพร้อม หมายเลขคลัสเตอร์1 http://facebook.com/datacube.th http://www.dataminingtrend.com
88.
88 Finding Association Rules (data)3 ! หากฏความสัมพันธ์ด้วยเทคนิค
Apriori5 ! ใช้ไฟล์ dataexample1.arff เป็นไฟล์ training data (option “-t”) 5 ! ใช้เทคนิค Apriori เพื่อทำการแบ่งกลุ่มข้อมูล (weka.associations.Apriori)5 ! สามารถกำหนดค่า min_sup และ min_conf ด้วย option “-M” และ “-C”5 1: 2: 3: 4: 5: 6: 7: import java.io.*;import java.util.*; import weka.core.*; import weka.associations.*; public static void main(String[] options) { testAssociation ta = new testAssociation(); ta.findAssociationRules("dataexample1.arff"); } http://facebook.com/datacube.th http://www.dataminingtrend.com
89.
Finding Association Rules
(2) 89 (data)3 8: public void findAssociationRules(String training_file) 9: { 10: String[] options = null; 11: String argument = "-t " + training_file; 12: options = argument.split(" "); 13: String trainFileString; 14: StringBuffer text = new StringBuffer(); 15: Apriori apriori = new Apriori(); 16: Reader reader; 17: try { 18: trainFileString = Utils.getOption('t', options); 19: if (trainFileString.length() == 0) throw new Exception( 20: "No training file given!"); 21: apriori.setOptions(options); 22: reader = new BufferedReader(new 23: FileReader(trainFileString)); 24: apriori.buildAssociations(new Instances(reader)); 25: System.out.println(apriori); 26: } catch(Exception e) { 27: e.printStackTrace(); 28: System.out.println("n"+e.getMessage()); 29: } 30: } http://facebook.com/datacube.th http://www.dataminingtrend.com
90.
Finding Association Rules
(3) 90 (data)3 ! Output5 กฏความสัมพันธ์ที่พบ1 http://facebook.com/datacube.th http://www.dataminingtrend.com
91.
91 For more information (data)3 ! หลักสูตรการพัฒนา
Web Application ด้วย PHP และ Weka รุ่นที่ 2 5 จะจัดขึ้นในช่วงเดือนเมษายน 2557 5 ! หสม. Data Cube5 ! http://facebook.com/datacube.th5 ! http://www.dataminingtrend.com5 ! sit.ake@gmail.com5 http://facebook.com/datacube.th http://www.dataminingtrend.com