Khai phá tập mục thường xuyên có yếu tố thời gian

82 16 0
Khai phá tập mục thường xuyên có yếu tố thời gian

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Khai phá tập mục thường xuyên có yếu tố thời gian Khai phá tập mục thường xuyên có yếu tố thời gian Khai phá tập mục thường xuyên có yếu tố thời gian luận văn tốt nghiệp,luận văn thạc sĩ, luận văn cao học, luận văn đại học, luận án tiến sĩ, đồ án tốt nghiệp luận văn tốt nghiệp,luận văn thạc sĩ, luận văn cao học, luận văn đại học, luận án tiến sĩ, đồ án tốt nghiệp

ĐẠI HỌC THÁI NGUYÊN TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG Phạm Văn Long KHAI PHÁ TẬP MỤC THƯỜNG XUYÊN CÓ YẾU TỐ THỜI GIAN LUẬN VĂN THẠC SĨ KHOA HỌC MÁY TÍNH Thái Ngun-2011 Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn ĐẠI HỌC THÁI NGUYÊN TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG Phạm Văn Long KHAI PHÁ TẬP MỤC THƯỜNG XUYÊN CÓ YẾU TỐ THỜI GIAN Chuyên ngành: Khoa học máy tính Mã số: 60 48 01 LUẬN VĂN THẠC SĨ KHOA HỌC MÁY TÍNH NGƢỜI HƢỚNG DẪN KHOA HỌC TS Nguyễn Huy Đức Thái Nguyên-2011 Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn LỜI CẢM ƠN Xin chân thành cảm ơn Thầy giáo TS Nguyễn Huy Đức tận tình dạy hƣớng dẫn tơi suốt thời gian học tập làm luận văn Tôi xin bày tỏ lời biết ơn chân thành đến quý Thầy giáo, cô giáo Viện Công nghệ Thông tận tình giảng dạy, trang bị cho tơi kiến thức quý báu suốt trình học tập Khoa Xin cảm ơn tất anh chị em học viên Cao học khóa 8, cám ơn cán công chức, giảng viên – Trƣờng đại học Công nghệ Thông tin truyền thông - Đại học Thái Nguyên tạo điều kiện giúp đỡ suốt trình học tập làm luận văn Cuối xin cảm ơn gia đình, bạn bè, đồng nghiệp giúp đỡ suốt thời gian học tập hoàn thành luận văn Thái Nguyên, tháng năm 2011 Tác giả Phạm Văn Long Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn Lời cam đoan Tôi xin cam đoan đề tài khoa học “Khai phá tập mục thường xuyên có yếu tố thời gian” cơng trình nghiên cứu thân tơi Các số liệu kết nghiên cứu nêu luận văn trung thực, đƣợc tác giả cho phép sử dụng tài liệu tham khảo nhƣ trình bày luận văn Tơi xin chịu trách nhiệm luận văn Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn MỤC LỤC Lời cam đoan Lời cảm ơn Mục lục i DANH MỤC CÁC KÝ HIỆU VÀ CÁC CHỮ VIẾT TẮT iii DANH MỤC CÁC BẢNG BIỂU iv DANH MỤC CÁC HÌNH VẼ, ĐỒ THỊ v MỞ ĐẦU Chương TỔNG QUAN VỀ KHAI PHÁ DỮ LIỆU 1.1 Khái niệm khám phá tri thức khai phá liệu 1.2 Kiến trúc hệ thống khai phá liệu 10 1.3 Các giai đoạn trình khai phá liệu 11 1.4 Một số kỹ thuật khai phá liệu 13 1.5 Các sở liệu phục vụ cho khai phá liệu 17 1.6 Các phương pháp khai phá liệu 19 1.7 Các ứng dụng khai phá liệu 21 1.8 Khai phá tập mục thường xuyên 22 1.8.1 Cơ sở liệu giao tác 22 1.8.2 Tập mục liệu thường xuyên 24 1.8.3 Các cách tiếp cận khai phá tập mục thường xuyên 25 1.8.4 Một số thuật toán điển hình tìm tập mục thường xuyên 26 Kết luận chương 39 Chương 2: KHAI PHÁ TẬP MỤC THƯỜNG XUYÊN CÓ YẾU TỐ THỜI GIAN 40 2.1 Mở đầu 40 2.2 Khai phá tập mục thường xuyên dòng liệu giao tác 41 2.2.1 Mơ hình xử lý liệu 41 2.2.2 Quản lý nhớ 44 2.3 Một số thuật toán khai phá tập mục thường xuyên dòng liệu 45 2.4 Thuật toán Clostream 47 2.4.1 Tập mục thường xuyên đóng 47 2.4.2 Cấu trúc liệu sử dụng thuật toán 48 2.4.3 Các bước thực thuật toán CloStream 50 2.4.4 Ví dụ minh họa thuật tốn Clostream 53 2.4.4 Nhận xét thuật toán CloStream 57 Kết luận chương 58 Chương 3: CÀI ĐẶT THỰC NGHIỆM 59 3.1 Tổ chức liệu thực nghiệm 59 3.2 Xây dựng chương trình 61 3.3 Kết thực nghiệm 63 3.4 Nhận xét 65 Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn KẾT LUẬN 65 Những kết nghiên cứu đạt được: 65 Hướng phát triển đề tài 66 TÀI LIỆU THAM KHẢO 67 PHỤ LỤC 69 Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn DANH MỤC CÁC KÝ HIỆU VÀ CÁC CHỮ VIẾT TẮT Ký hiệu Diễn giải Ck Tập k-tập mục ứng viên BFS Breadth First Search CSDL Cơ sở liệu DB Cơ sở liệu giao tác DFS Depth First Search FP –growth Frequent -Pattern Growth FP -tree Frequent pattern tree IT-tree Itemset-Tidset tree I Tập mục liệu k-itemset Tập mục gồm k mục KPDL Khai phá liệu Minsupp Ngưỡng hỗ trợ tối thiểu Lk Tập k-tập mục thường xuyên Supp Độ hỗ trợ (support) Tid Định danh giao tác Tid-List Danh sách định danh giao tác T Giao tác (transaction) Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn DANH MỤC CÁC BẢNG BIỂU Bảng 1.1: Biểu diễn ngang sở liệu giao tác 22 Bảng 1.2: Biểu diễn dọc sở liệu giao tác 23 Bảng 1.3: Ma trận giao tác sở liệu bảng 1.1 23 Bảng 1.4: Cơ sở liệu giao tác minh họa thực thuật toán Apriori 30 Bảng 1.5: CSDL giao tác minh hoạ cho thuật toán FP- growth 33 Bảng 2.1: Phân loại thuật tốn theo mơ hình liệu kiểu thuật tốn 46 Bảng 2.2: Cơ sở liệu giao tác 48 Bảng 2.3: Bảng đóng CT sau thêm vào giao tác bảng 2.2 49 Bảng 2.4: Bảng định danh CL sau thêm giao tác bảng 2.2 50 Bảng 2.5: Trạng thái bảng băm Temp sau thêm giao tác t6 55 Bảng 2.6: Bảng đóng CT sau thêm giao tác t6 56 Bảng 2.7: Bảng định danh CL sau thêm giao tác t6 56 Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn DANH MỤC CÁC HÌNH VẼ, ĐỒ THỊ Hình 1.1: Quá trình phát tri thức Hình 1.2: Kiến trúc hệ khai phá liệu điển hình 10 Hình 1.3 Quá trình khai phá liệu 12 Hình 1.4: Cây định 14 Hình 1.5: Mẫu kết nhiệm vụ phân cụm liệu 15 Hình 1.6: Mẫu kết nhiệm vụ hồi quy 16 Hình 1.7: Phân loại các thuật toán khai phá tập mục thường xuyên 26 Hình 1.8: Cây FP-tree xây dựng dần thêm giao tác t1, t2, t3 34 Hình 1.9: Cây FP-tree CSDL DB bảng 1.5 34 Hình 1.10: FP-tree phụ thuộc m 37 Hình 1.11 : Các FP-tree phụ thuộc am, cm cam 38 Hình 2.1: Mơ hình lấy mốc thời gian 42 Hình 2.2: Mơ hình lấy mốc thời gian có trọng số 42 Hình 2.3: Mơ hình trượt cửa sổ 43 Hình 3.1: Khối giao tác thứ tệp INPUT1.TXT 60 Hình 3.2: Khối giao tác thứ tệp INPUT2.TXT 61 Hình 3.3: Giao diện chương trình sau khởi động chương trình 62 Hình 3.4: Kết khai phá với minsup = 10% tệp INPUT1.TXT 63 Hình 3.5: Kết khai phá sau thêm khối giao tác thứ 64 Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn MỞ ĐẦU Với bùng nổ phát triển công nghệ thông tin mang lại nhiều hiệu khoa học hoạt động thực tế, khai phá liệu lĩnh vực mang lại hiệu thiết thực cho người Khai phá liệu giúp người sử dụng thu tri thức hữu ích từ sở liệu kho liệu khổng lồ khác Cơ sở liệu đơn vị, tổ chức kinh doanh, quản lý khoa học chứa đựng nhiều thông tin tiềm ẩn, phong phú đa dạng, địi hỏi phải có phương pháp nhanh, phù hợp, xác, hiệu để lấy thơng tin bổ ích Những “tri thức” chiết xuất từ nguồn sở liệu nguồn thông tin hỗ trợ cho lãnh đạo việc lên kế hoạch hoạt động việc định sản xuất kinh doanh Tiến hành công việc thực q trình phát tri thức sở liệu (Knowledge Discovery in Database) mà kỹ thuật khai phá liệu (Data Mining) cho phép phát tri thức tiềm ẩn Để lấy thơng tin mang tính tri thức khối liệu khổng lồ, cần thiết phải phát triển kỹ thuật có khả tích hợp liệu từ hệ thống giao dịch khác nhau, chuyển chúng thành tập hợp sở liệu ổn định có chất lượng Các kỹ thuật gọi kỹ thuật tạo kho liệu môi trường liệu nhận áp dụng kỹ thuật tạo kho liệu nói gọi kho liệu (Data Warehouse) [16, 11] Một nội dung khai phá liệu phổ biến phát luật kết hợp Phương pháp nhằm tìm tập thuộc tính thường xuất đồng thời sở liệu rút luật ảnh hưởng tập thuộc tính dẫn đến xuất (hoặc tập) thuộc tính khác Bên cạnh đó, nhu cầu khai phá xử lý liệu cần thiết kích thước lưu trữ liệu ngày nhiều nên Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 64 Tại thời điểm sau đó, CSDL bổ xung thêm khối giao tác biểu diễn tệp INPUT2.TXT, chương trình cho bổ xung khối giao tác vào nhận kết khai phá hình 3.5 Các tập mục thường xun đóng tìm kết khai phá tập giao tác tính từ mốc thời gian ban đầu Thuật toán thực nghiệm tiếp tập liệu lớn lấy địa chỉ: http://fimi.ua.ac.be/data/, kết cho thấy thuật toán thực hiệu Hình 3.5: Kết khai phá sau thêm khối giao tác thứ Kết thực nghiệm cho thấy: lần đầu đưa vào giao tác tệp INPUT1.TXT, lần đưa thêm vào giao tác tệp INPUT2.TXT kết khai thác giao tác chứa tệp INPUT1.TXT tệp INPUT2.TXT Điều với mô hình liệu mà thuật tốn sử dụng mơ hình lấy điểm mốc bắt đầu, tập mục thường xun đóng tìm khai phá giao tác tính từ thời điểm đầu Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 65 3.4 Nhận xét Kết thực chương trình thực nghiệm cho thấy thuật tốn CloStream tìm tập mục thường xun đóng dòng liệu nhanh hiệu Kết khai thác với mơ tả thuật tốn mơ hình liệu mà thuật tốn sử dụng Nếu muốn khai thác khối liệu xuất hiện, ta cần đặt lại điểm mốc cách đưa khối giao tác vào lần đầu KẾT LUẬN Những kết nghiên cứu đạt được: Với cách tiếp cận khảo cứu kết nghiên cứu công bố lĩnh vực khai phá liệu, luận văn tổng hợp nét khai phá liệu nói chung, khai phá tập mục thường xuyên nói riêng với sâu vào vấn đề khai phá tập mục thường xuyên dòng giao tác Sau điểm mà luận văn tập trung giải - Luận văn trình bày tổng quan khai phá liệu Trình bày chi tiết vấn đề khai phá tập mục thường xuyên: khái niệm bản, cách tiếp cận để khai phá thuật tốn điển hình: thuật tốn Apriori thuật toán FP-Growth - Nhu cầu thực tiễn đặt vấn đề cần khai phá tập mục thường xuyên sở liệu gia tăng, sở liệu động, dòng liệu Luận văn sâu vào vấn đề khai phá tập mục thường xuyên dòng liệu giao tác Do đặc điểm dòng liệu giao tác nên khai phá đặt số thách thức mới, địi hỏi phải có phương pháp kỹ thuật phù hợp Luận văn trình bày phân tích rõ mơ hình xử lý liệu dòng liệu giao tác là: lấy điểm mốc, lấy điểm mốc với gán trọng số mơ hình trượt cửa sổ Luận văn tóm lược thuật tốn, Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 66 phân loại thuật toán khai phá theo mơ hình xử lý liệu kiểu thuật tốn khai thác xác hay xấp xỉ - Luận văn trình bày chi tiết thuật tốn CloStream thuật toán trội khai phá tập mục thường xun đóng dịng giao tác Các sở tốn học liên quan khái niệm tốn tử đóng, tập mục thường xun đóng trình bày rõ ví dụ minh họa Các cấu trúc liệu sử dụng thuật toán bước thực thuật tốn trình bày chi tiết Luận văn phân tích ưu điểm mặt hạn chế thuật toán - Cài đặt thực nghiệm thành cơng thuật tốn CloStream, kết thực nghiệm khẳng định tính hiệu trội thuật tốn Chương trình thực nghiệm phát triển thành ứng dụng khai thác tập mục thường xuyên dòng giao tác thực tế Hướng phát triển đề tài Nghiên cứu thuật toán khai phá tập mục thường xuyên dòng liệu hướng nghiên cứu nhiều nhà nghiên cứu quan tâm tính ứng dụng vào nhiều lĩnh vực Đề tài luận văn tiếp tục nghiên cứu tiếp số vấn đề sau - Khai phá luật kết hợp dựa tập mục thường xun đóng tìm - Phát triển kỹ thuật khai thác xấp xỉ để phù hợp với mơi trường dịng liệu có tốc độ cao - Khai phá dòng liệu giao tác mà giao tác có giá trị liệu số - Khai phá tập mục thường xuyên có kèm theo điều kiện ràng buộc để phù hợp với mục đích sử dụng  Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 67 TÀI LIỆU THAM KHẢO Tiếng Việt: [1] Vũ Đức Thi, Nguyễn Huy Đức (2008), “Khai phá hiệu tập mục lợi ích cao sở liệu lớn”, Tạp chí Tin học Điều khiển học, 24(4), tr 307-320 [2] Nguyễn Huy Đức (2009), “Khai phá tập mục cổ phần cao lợi ích cao sở liệu”, Luận án Tiến sĩ Tốn học, Viện Cơng nghệ Thơng tin – Viện KH CN Việt Nam [3] Nguyễn Hữu Trọng (2008), “Phát triển số thuật toán khai phá luật kết hợp sở liệu gia tăng”, Luận án Tiến sĩ Tốn học, Viện Cơng nghệ Thông tin – Viện KH CN Việt Nam [4] Hồ Thuần, Hồ Cẩm Hà (2005), “Các hệ sở liệu: Lý thuyết tập”, tập 2, NXB Giáo dục, [5] Hoàng Kiếm, Đỗ Phúc (2001), “Phát triển thuật tốn tìm tập phổ biến sở liệu”, Hội thảo Quốc gia lần thứ IV: Một số vấn đề chọn lọc Công Nghệ Thông Tin, Hải Phòng Tiếng Anh: [6] R Agrawal, T Imielinski, A.N Swami (1993), “Mining association rules between sets of items in large databases”, in: Proc the ACM SIGMOD Conference on Management of Data, pp 207–216 [7] James Cheng · Yiping Ke · Wilfred Ng, “A survey on algorithms for mining frequent itemsets over data streams”, Springer-Verlag London Limited 2007 [8] Chang JH, Lee WS (2004) “A sliding window method for finding recently frequent item sets over online data streams” J INF Sci Eng 20(4):753–762 [9] Chang JH, Lee WS (2003) “estWin: adaptively monitoring the recent change of frequent item sets over online data streams” In: Proceedings of the 2003 ACM CIKM international conference on information and knowledge management, New Orleans, Louisiana, USA, pp 536–539 [10] Chi Y, Wang H, Yu P, Muntz R (2004), “Moment: maintaining closed frequent itemsets over a stream sliding window” In: Proceedings of the 4th IEEE international conference on data mining, Brighton, UK Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 68 [11] Gurmeet Singh Manku, Rajeev Motwani (2002) “Approximate Frequency Counts over Data Streams”; Int'l Conf on Very Large Databases; p.346-357 [12] Han J., Pei J., and Yin Y (2000), “Mining frequent patterns without candidate generation”, In ACM SIGMOD Intl Conference on Management of Data, pp 1-12 [13] M.M Gaber, A Zaslavsky and S Krishnaswamy (2005), “Mining data streams: a review”, ACM SIGMOD Record 34 (2), pp 18–26 [14] Jiang, N., Gruenwald, L (2006), “CFI-Stream: Mining Closed Frequent Itemsets in Data Streams” In: Proceedings of 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, Philadelphia, PA, USA, pp 592–597 [15] Nan Jiang and Le Gruenwald, the University of Oklahoma, School of Computer Science, Norman, OK 73019, USA (2006) “Research Issues in Data Stream Association Rule Mining”; SIGMOD Record, Vol 35, No 1, p 14 - 19 [16] Pasquier N, Bastide Y, Taouil R, Lakhal L (1999), “Discovering frequent closed item sets for association rules” In: Beeri C, Buneman P (eds) Proceedings of the 7th international conference on database theory, Jerusalem, Israel, January 1999, pp 398–416 [17] Show-Jane Yen, Yue-Shi Lee, Cheng-Wei Wu, and Chin-Lin Lin (2009), “An Efficient Algorithm for Maintaining Frequent Closed Itemsets over Data Stream” © Springer-Verlag Berlin Heidelberg 2009 [18] A.Tiwari, R.K Gupta and D.P Agrawal (2010) " A Survey on Frequent Pattern Mining: Current Status and Challenging Issues" Information Technology Journal 9(7), 1278-1293 Asian Network for Scientific Infomation Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 69 PHỤ LỤC Tệp NewJFrame.java /* * NewJFrame.java * * Created on September 23, 2011, 1:16 AM */ package javaapplication1; import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; import apriori.ItemApriori; import apriori.ItemsetApriori; import clostream.AlgoCloSteam; import java.io.*; import java.util.logging.Level; import java.util.logging.Logger; import java.lang.String; import javax.swing.table.DefaultTableModel; //import persistence.antlr.collections.impl.Vector; import java.util.Vector; import java.text.*; /** * * @author Admin */ public class NewJFrame extends javax.swing.JFrame { /** Creates new form NewJFrame */ public NewJFrame() { initComponents(); } private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); fileChooser = new javax.swing.JFileChooser(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jLabel3 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jSeparator1 = new javax.swing.JSeparator(); jLabel8 = new javax.swing.JLabel(); Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 70 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Agorithm CloStream"); setBounds(new java.awt.Rectangle(0, 0, 1000, 600)); setResizable(false); jPanel1.setFont(new java.awt.Font("Tahoma", 0, 12)); jLabel1.setFont(new java.awt.Font("Arial", 0, 13)); jLabel1.setText("Độ hỗ trợ tối thiểu"); jTextField1.setFont(new java.awt.Font("Arial", 0, 13)); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); jLabel2.setFont(new java.awt.Font("Arial", 0, 13)); jLabel2.setText("Tệp liệu"); jTextField2.setFont(new java.awt.Font("Arial", 0, 13)); jLabel5.setFont(new java.awt.Font("Arial", 0, 13)); jLabel5.setText("%"); jButton2.setFont(new java.awt.Font("Arial", 1, 13)); jButton2.setText("Chạy chương trình"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jLabel4.setFont(new java.awt.Font("Arial", 3, 13)); jLabel4.setText("Chọn tệp liệu:"); fileChooser.setControlButtonsAreShown(false); fileChooser.setDialogTitle("Open dialog"); fileChooser.setFont(new java.awt.Font("Times New Roman", 0, 12)); fileChooser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { fileChooserActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) addGroup(jPanel1Layout.createSequentialGroup() addGap(38, 38, 38) Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 71 addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) addComponent(jLabel1) addComponent(jLabel2)) addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) addGroup(jPanel1Layout.createSequentialGroup() addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE) addGroup(jPanel1Layout.createSequentialGroup() addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) addComponent(jLabel5))) addGap(126, 126, 126)) addGroup(jPanel1Layout.createSequentialGroup() addComponent(jButton2) addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) addComponent(jLabel4) addGroup(jPanel1Layout.createSequentialGroup() addGap(14, 14, 14) addComponent(fileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 490, javax.swing.GroupLayout.PREFERRED_SIZE))) addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) addGroup(jPanel1Layout.createSequentialGroup() addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) addGroup(jPanel1Layout.createSequentialGroup() addComponent(jLabel4) addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) addComponent(fileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)) addGroup(jPanel1Layout.createSequentialGroup() addGap(34, 34, 34) Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 72 addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) addComponent(jLabel2)) addGap(18, 18, 18) addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) addComponent(jLabel1) addComponent(jLabel5) addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) addGap(42, 42, 42) addComponent(jButton2))) addContainerGap(17, Short.MAX_VALUE)) ); jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 51, 51))); jScrollPane1.setAutoscrolls(true); jScrollPane1.setFont(new java.awt.Font("Tahoma", 0, 12)); jTable1.setFont(new java.awt.Font("Arial", 0, 14)); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null}, {null, null}, {null, null} }, new String [] { "Tập mục thường xuyên đóng", "Độ hỗ trợ" } )); jTable1.getTableHeader().setReorderingAllowed(false); jScrollPane1.setViewportView(jTable1); jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); jLabel3.setText("KẾT QUẢ:"); jLabel6.setFont(new java.awt.Font("Arial", 0, 13)); jLabel6.setText("Thời gian thực hiện:"); jLabel7.setFont(new java.awt.Font("Arial", 3, 14)); jLabel7.setForeground(new java.awt.Color(102, 0, 0)); jLabel7.setText("Khai phá tập mục thường xuyên đóng dịng liệu theo thuật tốn CloStream"); jLabel8.setFont(new java.awt.Font("Arial", 3, 13)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 73 getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) addGroup(layout.createSequentialGroup() addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) addGroup(layout.createSequentialGroup() addGap(129, 129, 129) addComponent(jLabel6) addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) addComponent(jLabel8)) addGroup(layout.createSequentialGroup() addGap(35, 35, 35) addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) addGroup(layout.createSequentialGroup() addGap(50, 50, 50) addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 899, javax.swing.GroupLayout.PREFERRED_SIZE) addComponent(jLabel7))) addGroup(layout.createSequentialGroup() addGap(56, 56, 56) addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) addComponent(jLabel3) addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 892, javax.swing.GroupLayout.PREFERRED_SIZE)))) addGap(57, 57, 57)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) addComponent(jLabel7) addGap(11, 11, 11) addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) addGap(5, 5, 5) addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 74 addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) addGap(5, 5, 5) addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) addComponent(jLabel6) addComponent(jLabel8)) addGap(11, 11, 11) addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE) addGap(104, 104, 104)) ); pack(); }// //GEN-END:initComponents public static AlgoCloSteam cloStream = new AlgoCloSteam(); public static long demsodong = 0; public static void chaychuongtrinh(String file) { try { FileReader reader = new FileReader(file); BufferedReader br = new BufferedReader(reader); String s=""; while((s = br.readLine()) != null) { demsodong++; ItemsetApriori transaction = new ItemsetApriori(); int vt_dau = -1, vt_cuoi=0; int so = 0; String tam = ""; while(1==1) { vt_cuoi = s.indexOf(' ', vt_cuoi); if (vt_cuoi = sogiaotac) && (itemset.toString().length() >0)) { DecimalFormat dec = new DecimalFormat("##.##"); double b = (double) itemset.getAbsoluteSupport(); writer.write(itemset.toString()+"("+dec.format(b*100/demsodong)+")"+" %"); writer.write("\r\n"); rowData = new Vector(); rowData.add (itemset.toString()); rowData.add (String.valueOf(dec.format(b*100/demsodong))+" %"); model.addRow(rowData) ; } } writer.close(); long endTime = System.currentTimeMillis(); jLabel8.setText(String.valueOf(endTime-startTime)+" ms"); } catch (IOException ex) { Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 76 Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex); } finally { try { writer.close(); } catch (IOException ex) { Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex); } } } private void fileChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileChooserActionPerformed File file = fileChooser.getSelectedFile(); jTextField2.setText(file.getPath()); private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame().setVisible(true); } }); } // Variables declaration - not modify//GEN-BEGIN:variables private javax.swing.JFileChooser fileChooser; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JTable jTable1; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; // End of variables declaration//GEN-END:variables } Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 77 Tệp AlgoCloSteam.java package clostream; import import import import import import java.util.ArrayList; java.util.HashMap; java.util.HashSet; java.util.List; java.util.Map; java.util.Set; import apriori.ItemApriori; import apriori.ItemsetApriori; /** * CloStream algorithm, S.J Yen (2009) */ public class AlgoCloSteam { List tableClosed = new ArrayList(); Map cidListMap = new HashMap(); public AlgoCloSteam() { ItemsetApriori emptySet = new ItemsetApriori(); emptySet.setTransactioncount(0); tableClosed.add(emptySet); } public void processNewTransaction(ItemsetApriori transaction){ Map tableTemp = new HashMap(); tableTemp.put(transaction, 0); Set cidset = new HashSet(); for(ItemApriori item : transaction.getItems()){ List cidlist = cidListMap.get(item); if(cidlist != null){ cidset.addAll(cidlist); } } for(Integer cid : cidset){ ItemsetApriori cti = tableClosed.get(cid); ItemsetApriori intersectionS = transaction.intersection(cti); boolean found = false; for(Map.Entry entry : tableTemp.entrySet()){ if(entry.getKey().isEqualTo(intersectionS)){ found = true; ItemsetApriori ctt = tableClosed.get(entry.getValue()); Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn 78 ctt.getAbsoluteSupport()){ if(cti.getAbsoluteSupport() > // &&&&&&&&& entry.setValue(cid); } break; } } if(found == false){ tableTemp.put(intersectionS, cid); } } for(Map.Entry xc : tableTemp.entrySet()){ ItemsetApriori x = xc.getKey(); Integer c = xc.getValue(); ItemsetApriori ctc = tableClosed.get(c); if(x.isEqualTo(ctc)){ ctc.increaseTransactionCount(); }else{ tableClosed.add(x); x.setTransactioncount(ctc.getAbsoluteSupport()+1); for(ItemApriori item : transaction.getItems()){ List cidlist = cidListMap.get(item); if(cidlist == null){ cidlist = new ArrayList(); cidListMap.put(item, cidlist); } cidlist.add(tableClosed.size()-1); } } } } public List abc() { return tableClosed; } public List getFrequentClosedItemsets() { if(tableClosed.get(0).size() ==0){ tableClosed.remove(0); } return tableClosed; } } Số hóa Trung tâm Học liệu – ĐHTN http://www.lrc-tnu.edu.vn ... tập tập mục thường xuyên phải tập mục thường xuyên Vì tập mục ứng viên gồm k mục sinh cách kết nối tập mục thường xuyên có (k-1) mục loại bỏ tập mục ứng viên có chứa tập thường xuyên Giả sử mục. .. Chương 2: KHAI PHÁ TẬP MỤC THƯỜNG XUYÊN CÓ YẾU TỐ THỜI GIAN 2.1 Mở đầu Khai phá tập mục thường xuyên lĩnh vực nhiều nhiệm vụ khai phá liệu Chương đề cập đến vấn đề khai phá tập mục thường xuyên sở... khai phá tập mục thường xuyên Bài toán khai phá tập mục thường xuyên chia thành hai tốn nhỏ: tìm tập mục ứng viên tìm tập mục thường xuyên Tập mục ứng viên tập mục mà ta hy vọng tập mục thường

Ngày đăng: 22/02/2021, 14:19

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan