Nghiên cứu thuật toán khai phá tập phổ biến eclat và các biến thể

77 44 0
Nghiên cứu thuật toán khai phá tập phổ biến eclat và các biến thể

Đ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

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC NHA TRANG NGUYỄN THỊ HƯƠNG LÝ NGHIÊN CỨU THUẬT TOÁN KHAI PHÁ TẬP PHỔ BIẾN ECLAT VÀ CÁC BIẾN THỂ LUẬN VĂN THẠC SĨ KHÁNH HÒA - 2019 LỜI CAM ĐOAN Tôi xin cam đoan kết đề tài: “Nghiên cứu thuật toán khai phá tập phổ biến Eclat biến thể” cơng trình nghiên cứu cá nhân chưa công bố cơng trình khoa học khác thời điểm Nha Trang, ngày 18 tháng 10 năm 2019 Tác giả luận văn Nguyễn Thị Hương Lý iii LỜI CẢM ƠN Trước hết, muốn gửi lời cảm ơn đến quý phòng ban trường Đại học Nha Trang, thầy giáo tham gia giảng dạy khóa cao học Khoa Công nghệ Thông tin trường Đại học Nha Trang Đặc biệt, xin gửi lời cảm ơn sâu sắc đến thầy TS Nguyễn Đức Thuần - người dành nhiều thời gian định hướng, hướng dẫn tư vấn giúp tơi hồn thành luận văn Tiếp đến, xin cảm ơn gia đình, bạn bè đồng nghiệp ln ủng hộ, động viên để tơi nghiên cứu, thực nghiệm hồn thành luận văn Trong trình làm luận văn, thân tơi cố gắng tập trung tìm hiểu, nghiên cứu thêm nhiều tài liệu liên quan, nhiên luận văn cịn thiếu sót định Tơi mong nhận góp ý Thầy Cô giáo bạn bè, đồng nghiệp luận văn kết nghiên cứu Tôi xin chân thành cảm ơn! Nha Trang, ngày 18 tháng 10 năm 2019 Tác giả luận văn Nguyễn Thị Hương Lý iv MỤC LỤC Lời cam đoan iii Lời cảm ơn iv Mục lục v Danh mục chữ viết tắt vii Danh mục bảng viii Danh mục hình ix Danh mục biểu đồ x Trích yếu luận văn xi Mở đầu .1 Chương KHAI PHÁ DỮ LIỆU VÀ KHAI PHÁ TẬP PHỔ BIẾN 1.1 Khai phá liệu 1.1.1 Khái niệm Khai phá liệu 1.1.2 Kiến trúc điển hình hệ thống khai phá liệu 1.1.3 Một số kỹ thuật khai phá liệu 1.2 Ứng dụng khai phá liệu .6 1.3 Một số khó khăn khai phá liệu .6 1.4 Khai phá Luật kết hợp 1.4.1 Giới thiệu khái niệm 1.4.2 Các phương pháp khai phá tập phổ biến luật kết hợp 10 1.5 Dàn tập mục liệu 11 1.6 Thuật toán vét cạn khai phá tập phổ biến 12 1.7 Thuật toán Apriori .13 1.8 Thuật toán FP-Growth .16 1.8.1 Thuật toán sinh FP-Tree từ CSDL giao tác 16 1.8.2 Thuật toán FP-Growth 19 Kết luận chương 20 Chương THUẬT TOÁN ECLAT VÀ CÁC BIẾN THỂ 21 2.1 Giới thiệu 21 2.2 Biều diễn liệu theo chiều ngang theo chiều dọc 21 2.3 Thuật toán Eclat 23 2.3.1 Sinh tập ứng viên 23 2.3.2 Tính tốn độ hỗ trợ 26 2.3.2 Mã giả thuật toán Eclat 27 v 2.4 Thuật toán dEclat 28 2.5 Thuật toán PostDiffset .31 2.6 Thuật toán BI-Eclat .32 Kết luận chương 35 Chương KẾT QUẢ VÀ HƯỚNG PHÁT TRIỂN .36 3.1 Cài đặt chương trình thực nghiệm 36 3.2 Thực nghiệm đánh giá 37 3.2.1 CSDL Chess 37 3.2.2 CSDL Connect 39 3.2.3 CSDL Mushrom 40 3.2.4 CSDL Accidents 42 3.2.5 CSDL T40I10D100K 44 3.2.6 CSDL Pumb 45 3.2.7 CSDL T10I4D100K 47 3.2.8 CSDL PUMSB_STAR 49 3.2.9 CSDL Retail 50 3.2.10 CSDL Kosarak 52 Kết luận chương 53 Tài liệu tham khảo 56 Phụ lục vi DANH MỤC CHỮ VIẾT TẮT KDD : Knowledge Discovery in Database (Phát tri thức từ sở liệu) CSDL : Cơ sở liệu Item : Mục liệu 𝕀 : Itemset (Tập mục liệu) k-itemtset : tập gồm k mục liệu T : Transaction (Giao tác) 𝔻 : Transaction Database (Cơ sở liệu giao tác) Supp : support (Độ hỗ trợ) R_supp : Relative support (Độ hỗ trợ tương đối) 𝔽 : Frequent itemset (Tập mục phổ biến) Min_supp : support (Độ hỗ trợ tối thiểu người dùng tự định nghĩa) Conf : Confidient (Độ tin cậy) Min_conf : Min confidient (Ngưỡng tin cậy tối thiểu) BFS : Breadth – first search (Tìm kiếm theo chiều rộng) DFS : Depth – first search (Tìm kiếm theo chiều sâu) FP-Tree : Frequent Pattern Tree (Cấu trúc FP-tree) FP-Growth : Frequent Pattern Growth (Thuật toán phát triển mẫu phổ biến) Tid : Transaction Identifer (Mã giao tác) Tid set : Transaction Indentifer set (Tập mã giao tác) FIM : Frequent Itemset Mining (Khai phá tập phổ biến) vii DANH MỤC BẢNG Bảng 1.1 Ví dụ sở liệu giao tác Bảng 3.1 Thông tin CSDL thực nghiệm 36 viii DANH MỤC HÌNH Hình 1.1 Q trình phát tri thức khai phá liệu Hình 1.2 Kiến trúc điển hình hệ thống khai phá liệu Hình 1.3 Minh họa dàn 12 Hình 2.1 Ví dụ biểu diễn theo chiều ngang (trái) chiều dọc (phải) 22 Hình 2.2 Cây tìm kiếm item sở {a,b,c,d,e} .26 Hình 2.3 Minh họa khai tác tập thường xun với thuật tốn Eclat 28 Hình 2.4 Minh họa tính diffset .29 Hình 2.5 Minh họa thuật toán dEclat 31 Hình 3.1 Giao diện chương trình 36 Hình 3.2 Thống kê kết lần thực nghiệm CSDL Chess 37 Hình 3.3 Thống kê kết lần thực nghiệm CSDL Connect 39 Hình 3.4.Thống kê kết lần thực nghiệm CSDL Mushrom 41 Hình 3.5 Thống kê kết lần thực nghiệm CSDL Accidents 43 Hình 3.6 Thống kê kết lần thực nghiệm CSDL T40I10D100K .44 Hình 3.7 Thống kê kết lần thực nghiệm CSDL Pumb .46 Hình 3.8 Thống kê kết lần thực nghiệm CSDL T10I4D100K 48 Hình 3.9 Thống kê kết lần thực nghiệm CSDL Pumsb_star 49 Hình 3.10 Thống kê kết lần thực nghiệm CSDL Retail 51 Hình 3.11 Thống kê kết lần thực nghiệm CSDL Kosarak .52 ix DANH MỤC BIỂU ĐỒ Biểu đồ 3.1 So sánh thời gian thực thuật toán CDSL Chess 38 Biểu đồ 3.2 So sánh nhớ sử dụng thuật toán CDSL Chess 38 Biểu đồ 3.3 So sánh thời gian thực thuật toán CDSL Connect 40 Biểu đồ 3.4 So sánh nhớ sử dụng thuật toán CDSL Connect .40 Biểu đồ 3.5 So sánh thời gian thực thuật toán CDSL Mushrom 41 Biểu đồ 3.6 So sánh nhớ sử dụng thuật toán CDSL Mushrom 42 Biểu đồ 3.7 So sánh thời gian thực thuật toán CDSL Accidents 42 Biểu đồ 3.8 So sánh nhớ sử dụng thuật toán CDSL Accidents 43 Biểu đồ 3.9 So sánh thời gian thực thuật toán CDSL T40I10D100K .45 Biểu đồ 3.10 So sánh nhớ sử dụng thuật toán CDSL T40I10D100K 45 Biểu đồ 3.11 So sánh thời gian thực thuật toán CDSL Pumsb .46 Biểu đồ 3.12 So sánh nhớ sử dụng thuật toán CDSL Pumb .47 Biểu đồ 3.13 So sánh thời gian thực thuật toán CDSL T10I4D100K .47 Biểu đồ 3.14 So sánh nhớ sử dụng thuật toán CDSL T10I4D100K 48 Biểu đồ 3.15 So sánh thời gian thực thuật toán CDSL Pumsb_star 50 Biểu đồ 3.16 So sánh nhớ sử dụng thuật toán CDSL Pumsb_star 50 Biểu đồ 3.17 So sánh thời gian thực thuật toán CDSL Retail 51 Biểu đồ 3.18 So sánh nhớ sử dụng thuật toán CDSL Retail .52 Biểu đồ 3.19 So sánh thời gian thực thuật toán CDSL Kosarak 53 Biểu đồ 3.20 So sánh nhớ sử dụng thuật toán CDSL Kosarak 53 x TRÍCH YẾU LUẬN VĂN Trong khai phá liệu, phát luật kết hợp kỹ thuật nhằm tìm tri thức tiềm ẩn kho liệu lớn Khai phá tập phổ biến toán quan trọng khai phá luật kết hợp Có nhiều thuật tốn khai phá tập phổ biến đời, thuật tốn có ưu nhược điểm khác Luận văn này, chúng tơi trình bày kết nghiên cứu đánh giá thuật toán khai phá tập phổ biến Eclat biến thể Luận văn sử dụng phương pháp phân tích tổng hợp nhằm phân tích, tổng hợp báo liên quan đến lĩnh vực nghiên cứu, cài đặt, thử nghiệm đán giá hiệu thuật toán Để đánh giá hiệu thuật toán Eclat biến thể sử dụng 10 sở liệu giao tác với đặc tính khác (số lượng giao tác, số lượng mục liệu quan tâm, thưa, dày) lấy trang http://fimi.uantwerpen.be/data [23] Những gồm: Chess, connect, mushroom, accidents, T40I10D100K, pumsb, T10I4D100K, pumsb_star, retail kosarak Với bộ, tùy theo đặc tính mà chúng tơi chọn thử nghiệm độ hỗ trợ khác Các thử nghiệm thực CSDL có mức độ thưa dần Các CSDL có đặc điểm khác Kết thực nghiệm cho thấy Eclat BI-Eclat hoạt động tốt với sở liệu thưa, dEclat postDiffset hoạt động tốt với sở liệu dày Từ khóa: BI-Eclat; Eclat; dEclat; Khai phá tập phổ biến; postDiffset xi Kết hình 3.11 thể biểu đồ 3.19 (trang bên) cho thấy Eclat BI-Eclat có thời gian hoạt động tốt Về mức độ sử dụng nhớ, biểu đồ 3.20 cho thấy thuật tốn khơng khác nhiều mức độ sử dụng Tuy tổng thể Eclat BI-Eclat ứng viên tốt cho loại sở liệu thưa, nhiều mục liệu quan tâm nhiều giao tác (CSDL Kosarak) 4700 4600 4500 Eclat dEclat postDiffset BI-Eclat TIME (MS) 4400 4300 4200 4100 4000 3900 3800 MINSUP (%) Biểu đồ 3.19 So sánh thời gian thực thuật toán CDSL Kosarak 320,00 310,00 MEM(MB) 300,00 290,00 Eclat 280,00 dEclat postDiffset 270,00 BI-Eclat 260,00 250,00 60 50 40 30 20 MINSUP(%) Biểu đồ 3.20 So sánh nhớ sử dụng thuật toán CDSL Kosarak KẾT LUẬN CHƯƠNG Chương trình bày chi tiết thử nghiệm liệu có đặc tính khác Để đánh giá hiệu thuật toán Eclat biến thể sử dụng 10 sở liệu giao tác với đặc tính khác (số lượng giao tác, số lượng mục 53 liệu quan tâm, thưa, dày) Những gồm: Chess, connect, mushroom, accidents, T40I10D100K, pumsb, T10I4D100K, pumsb_star, retail kosarak Với bộ, tùy theo đặc tính mà tơi chọn thử nghiệm độ hỗ trợ khác Các thử nghiệm thực CSDL có mức độ thưa dần Với liệu dày chess connect, kết cho thấy BI-Eclat thời gian thực khai phá tập mục phổ biến, đặc biệt ngưỡng độ hỗ trợ giảm dần, mức độ sử dụng nhớ tăng đáng kể ngưỡng độ hỗ trợ nhỏ BI-Eclat tốn chi phí thời gian nhớ cho việc xếp tidset, CSDL loại khơng tận dụng ưu (khi ngưỡng độ hỗ trợ nhỏ dần) để tỉa bớt ứng viên không tiềm việc giảm bớt số lần duyệt k-itemset Có thể nói rằng, CSDL này, dEclat postDiffset tốt quan tâm đến thời gian thực hiện, quan tâm đến mức độ sử dụng nhớ dEclat cho hiệu tốt Đối với liệu mushrom, biểu đồ 3.5 cho thấy khơng có khác nhiều thuật toán thời gian thực hiện, postDiffset tốt Như hình 3.5, biểu đồ 3.7 3.8 ta thấy với CSDL accidents, Eclat dEclat tốt hiệu sử dụng nhớ, cịn thời gian thực hiền dEclat nhanh Với CSDL T40I10D100K, kết thống kê hình 3.6, biểu đồ 3.9 cho thấy với CSDL thưa dần (tỉ lệ độ dài trung bình giao tác số mục liệu ~4.1%), thuật toán dEclat hiệu BI-Eclat postDiffset tương đương mức tốt Eclat ngưỡng độ hỗ nhỏ dần Trên biểu đồ 3.9 cho thấy số lượng giao tác lớn, dEclat thuật toán sử dùng nhiều nhớ Biểu đồ 3.11 cho thấy, với CSDL pumsb dEclat postDiffset hoạt động tốt tương đương thời gian thực Eclat mức trung bình, BI-Eclat mức hiệu Về mức độ sử dụng nhớ, kết biểu đồ 3.12 cho thấy ưu dEclaat so với thuật tốn cịn lại Sang loại liệu thưa T10I4D100K, kết thực nghiệm quan sát biểu đồ 3.13, 3.14 cho thấy, dEclat hiệu thời gian thực giải thuật mức độ sử dụng nhớ Ba thuật tốn cịn lại thời gian thực tương đồng nhau, Eclat sử dụng nhớ Đối với CSDL retail, biểu đồ 3.17 thể thuật toán dEclat hoạt động hiệu BI-Eclat Eclat hoạt động tốt ổn định CSDL Kosarak thưa tất CSDL mà thử nghiệm Tỉ lệ độ dài 54 trung bình giao dịch số mục liệu bé (~0.01%) Số lượng giao dịch 99002, số mục liệu lớn (41270) Kết hình 3.11 thể biểu đồ 3.19 cho thấy Eclat BI-Eclat có thời gian hoạt động tốt Về mức độ sử dụng nhở, biểu đồ 3.20 cho thấy thuật tốn khơng khác nhiều mức độ sử dụng Tuy tổng thể Eclat BI-Eclat ứng viên tốt cho loại CSDL thưa, nhiều mục liệu quan tâm nhiều giao tác Các kết thử nghiệm cho thấy dEclat PostDiffset hoạt động tốt CSDL dày, Eclat BI-Eclat hoạt động tốt CSDL thưa thể rõ CSDL thưa Hướng phát triển đề tài: - Thử nghiệm nhiều liệu, so sánh với thuật toán khai phá tập phổ biến khác - Tìm hiểu khai thác nhược điểm thuật toán nhằm đề xuất thuật toán cải tiến nhằm nâng cao hiệu - So sánh, kết hợp để tìm tập phổ biến có ràng buộc, hay tập phổ biến đóng mà nhóm nước quan tâm 55 TÀI LIỆU THAM KHẢO T Mitchell, "Machine Learning and Data Mining",Communications of the ACM, vol 42, no 11, pp 33-36, 1999 G P.-S P a R U U M Fayyad, "Advances in Knowledge Discovery and Data Minining", AAAI Press, 1996 Đ Phúc, "Giáo trình khai thác liệu", Đại học Quốc gia TP Hồ Chí Minh, 2006 H M a P S D Hand, "Principles of Data Mining", London: The MIT Press, 2001 M K a J P Jiawei Han, "Data Mining: Concepts and Techniques", 3rd ed., Morgan Kaufmann Publishers, 2011 J H a M Kamber, "Data Mining: Concepts and Techniques", Morgan Kaufmann Publishers, 2006 Agrawal R, Mannila H, Srikant R, Toivonen H, and A Inkeri, "Fast Discovery of Association Rules", Advances in Knowledge Discovery and Data Mining, pp 307328, 1996 Agrawal R, Imielinski T, Swam A, "Mining Association Rules between Sets of Items in Large Databases", in Proc of ACM SIGMOD Conference Management of Data, Washington DC, US, 1993 Agrawal A, Shafer J, "Parallel mining of association rules", In IEEE transaction in Knowledge and Data Engineering, vol 8, no 6, pp 962-969, 1996 10 N H Trọng, "Phát triển số thuật toán kết hợp sở liệu gia tăng", Luận án Tiến sĩ, Viện Công nghệ thông tin, Hà Nội, 2008 11 N Đ Thuần, "Nhập môn phát tri thức khai phá liệu", NXB Thông tin Truyền thông, 2013 12 Agrawal, R; Srikant, R;, "Fast Algorithms for Minings Association Rules", in Proc of the Very Large Database International Conference, Santiago, 1994 13 Han J, Pei J, Yin J, anh Mao R, "Mining Frequent Paterns without Candidate Generation: A Frequent-Patern Tree Approach", Datamining and Knowledge Discovery, vol 8, pp 53-87, 2004 14 Zaki M.J, Parthasarathy S, Orihara M and Li W, "New Algorithms for Fast DIscovery of Association Rules", in Proc of KDD 1997, 1997 56 15 Mythili M.S, Mohamed Shanavas A.R, "Performance Evaluation of Apriori and FP-Growth Algorithms", International Journal of Computer Applications , vol 79, no 10, 2013 16 Kanwal Garg Dr, Deepak Kumar, "Comparing the Performance of Frequent Pattern Mining Algorithms", International Journal of Computer Applications , vol 69, no 25, 2013 17 Zaki MJ, & Gouda K, "Fast vertical mining using diffsets", Proceedings of The Ninth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp 326-335, 2003 18 T Tuan, "A Vertical Representation for Parallel dEclat Algorithm in Frequent Itemset Mining", Ritsumeikan University, 2012 19 Xiaomei Yu, Hong Wang, "Improvement of Eclat Algorithm Based on Support in Frequent Itemset Mining", JOURNAL OF COMPUTERS, vol IX, no 9, 2014 20 S Rohit, "Association Rule Mining Algorithms: Survey", International Research Journal of Engineering and Technology, vol III, no 10, 2016 21 Sotiris Kotsiantis and Dimitris, "Association Rules Mining: A Recent Overview", GESTS International Transactions On Computer Science and Engineering, vol 32, no 1, pp 71-82, 2006 22 Bakar W.A.W.A, Jalil M.A, Man M, Abdullah Z, Mohd F, "Postdiffset: an Eclatlike algorithm for frequent itemset mining", International Journal of Engineering & Technology,, 2018 23 http://fimi.uantwerpen.be/data/, 2012 57 PHỤ LỤC Phụ lục Nội dung Số trang Một số hàm phục vụ thuật tốn Thuật tốn Eclat Thuật toán dEclat Thuật toán postDiffset Thuật toán BI-Eclat 58 Một số hàm phục vụ thuật tốn STT Ý nghĩa Tên hàm saveFile_1_Frequency Ghi file mục 1_itemset để xem performIntersection Tính tốn tidset tập mục liệu IJ processEquivalenceClass Hàm xử lý lớp tương đương saveFile Hàm lưu file để xem Hàm tính độ hỗ trợ itemset X sư calculateSupport dụng tidset X size=1 Ngược lại sử dụng diffset để tính độ hỗ trợ Sinh 2-itemset từ việc tính phép giao performIntersectionFirstTime performIntersaction2Itemset performSubtraction 1-itemset cách sử dụng diffset Thuc hien phep giao itemset Tính tốn diffset theo tidset d(XY)=T(X)T(Y) 59 Code thuật toán Eclat class Eclat { public Eclat(int _minSup, TransactionDB dbTrans, String outFile) { minSup = _minSup; database = dbTrans; writer=new StreamWriter(outFile); } public FreqItemSets run() { // CChuyển DB sang chiều dọc với //1 tính tidSet mục liệu cấp 1: Level Dictionary vertDB = new Dictionary(); for (int i = 0; i < database.getTranSize(); i++) // Với giao tác { List transaction = database.getTransactions()[i]; // thứ i for (int j = 0; j < transaction.Count; j++) { // mục giao tác UInt16 item=transaction[j]; // get the current tidset of that item HashSet tidset; bool ok= vertDB.TryGetValue(item, out tidset); // if (!ok) { tidset = new HashSet(); vertDB.Add(item, tidset); } tidset.Add(Convert.ToUInt16( i)); } } // tinh muc thuong xuyen cap 1, luu ket qua file out.txt // (1) danh sach muc thuong xuyen cap List frequent_1_Items = new List(); foreach (KeyValuePair entry in vertDB) { //lay tidset cua item HashSet tidset = entry.Value; UInt16 item = entry.Key; // tinh toan ho tro cua tap du lieu muc dl int sup_1_Items = tidset.Count(); if (sup_1_Items >= minSup) { frequent_1_Items.Add(item); // ghi file để xem saveFile_1_Frequency(item, tidset, sup_1_Items); } } // Tạo lớp tương đương 2-itemset cách hợp item đơn //duyet lan luot phân tử 1-itemset thường xuyên for (int i = 0; i < frequent_1_Items.Count(); i++) { UInt16 itemI = frequent_1_Items[i]; HashSet tidsetI ; bool ok = vertDB.TryGetValue(itemI, out tidsetI); int supI = tidsetI.Count(); 60 // equalClassItems lưu trữ ký tự cuối lớp tương đương có prefix itemI, tidset có prefix itemI List equalClassItems = new List(); List equalClassTidsets= new List(); //duyet itemI đứng sau itemI for (int j = i + 1; j < frequent_1_Items.Count(); j++) { UInt16 itemJ = frequent_1_Items[j]; HashSet tidsetJ; bool ok1 = vertDB.TryGetValue(itemJ, out tidsetJ); int supJ = tidsetJ.Count(); //tinh toán phép giao tidsetI tidsetJ để tidset itemset IJ HashSet tidsetIJ = performIntersection(tidsetI, supI, tidsetJ, supJ); int supIJ = tidsetIJ.Count(); if (supIJ >= minSup) { equalClassItems.Add(itemJ); equalClassTidsets.Add(tidsetIJ); } }// -vong lap j writer.Close(); return null; } 61 Thuật toán dEclat class dEclat { public dEclat(int _minSup, TransactionDB tranDB, String outFile) { minSup =_minSup; database = tranDB; writer = new StreamWriter(outFile); itemsetFrequencyFound = 0; } // -public void run() { var watch = System.Diagnostics.Stopwatch.StartNew(); var procStart = System.Diagnostics.Process.GetCurrentProcess(); var mbUsedStart = procStart.PrivateMemorySize64; //chuyển CSDL ngan bg sang dọc for (int i = 0; i < database.getTranSize(); i++) // Với giao tác { List transaction = database.getTransactions()[i]; // thứ i for (int j = 0; j < transaction.Count; j++) { //voi item j giao tac i UInt32 item = transaction[j]; HashSet tidset; bool ok = vertDB.TryGetValue(item, out tidset); if (!ok) { tidset = new HashSet(); vertDB.Add(item, tidset); } tidset.Add(Convert.ToUInt32(i)); } }// end for i //tinh muc thuong xuyen cho cac 1-itemset, luu ket qua file out List frequent_1_itemset = new List(); foreach (KeyValuePair entry in vertDB) { //lay item tidset item UInt32 item = entry.Key; HashSet tidset = entry.Value; //tinh độ hỗ trợ item int sup_1_Item = tidset.Count(); if (sup_1_Item >= minSup) { frequent_1_itemset.Add(item); saveFile_1Item(item, tidset, sup_1_Item); } } // Tạo 2-itemset cách hợp item đơn //duyet item 1-itemset for (int i = 0; i < frequent_1_itemset.Count; i++) { UInt32 itemI = frequent_1_itemset[i]; HashSet tidsetI; bool okI = vertDB.TryGetValue(itemI, out tidsetI); int supI = tidsetI.Count(); //equavilenceClass lưu trữ kí tự cuối lớp tương đương có prefix itemI //equavilenceClassTidset luu trữ tidset List equivalenceClass=new List(); List equivalenceClassDiffset=new List(); //duyet item đứng sau itemI for(int j=i+1;j=minSup){ equivalenceClass.Add(itemJ); equivalenceClassDiffset.Add(diffsetIJ); } }// end for j // sinh 3-itemset if (equivalenceClass.Count()>0) { itemsetPrefix[0] = itemI; processEquivalenceClass(itemsetPrefix, 1, supI, equivalenceClass, equivalenceClassDiffset); } } watch.Stop(); totalTimeSpend = watch.ElapsedMilliseconds; writer.Close(); var procEnd = System.Diagnostics.Process.GetCurrentProcess(); var mbUsedEnd = procEnd.PrivateMemorySize64; totalmbUsed = ((mbUsedEnd - mbUsedStart)*1.0/ 1024) / 1024; GC.Collect(); }// end run 63 Giải thuật postDiffset class postDEclat { public postDEclat(int _minSup, TransactionDB tranDB, String outFile) { minSup =_minSup; database = tranDB; writer = new StreamWriter(outFile); itemsetFrequencyFound = 0; } // -public void run() { // tinh muc thuong xuyen cap 1, luu ket qua file out.txt // (1) danh sach muc thuong xuyen cap List frequent_1_Items = new List(); foreach (KeyValuePair entry in vertDB) { //lay tidset cua item HashSet tidset = entry.Value; UInt32 item = entry.Key; // tinh toan ho tro cua tap du lieu muc dl int sup_1_Items = tidset.Count; if (sup_1_Items >= minSup) { frequent_1_Items.Add(item); // ghi file để xem saveFile_1_Frequency(item, tidset, sup_1_Items); } } #region TidSet (Eclat) // Tạo lớp tương đương 2-itemset cách hợp item đơn //duyet lan luot phân tử 1-itemset thường xuyên List frequent_2_Items = new List(); frequent_2_Items.Add(new FQ2Itemset(prefix,equalClass,equalClassTidset)); } // -for i writer.Close(); #endregion Eclat #region dEclat // Tạo 3-itemset for (int i = 0; i < frequent_2_Items.Count-1; i++) // với lớp nhóm theo Prefix { for (int k = 0; k < frequent_2_Items[i].getEqualClass().Count; k++) { // Lấy 2-itemset; xem prefix List itemI = new List(); itemI.Add(frequent_2_Items[i].getPrefix()); itemI.Add(frequent_2_Items[i].getEqualClass()[k]); HashSet tidsetI = frequent_2_Items[i].getEqualClassTidset()[k]; int supI = tidsetI.Count; // // Xây dựng 3-itemset với prefix ItemI List equivalenceClass = new List(); 64 List equivalenceClassDiffset = new List(); // dựa vào lớp tương đương trước for (int j = k+1; j < frequent_2_Items[i].getEqualClass().Count; j++) { UInt32 itemJ = frequent_2_Items[i].getEqualClass()[j]; // xem sufix HashSet tidsetJ = frequent_2_Items[i].getEqualClassTidset()[j]; int supJ = tidsetJ.Count; HashSet diffsetIJ = performSubtraction(tidsetI, supI, tidsetJ, supJ); int suppIJ = calculateSupport(2, supI, diffsetIJ); if (suppIJ >= minSup) { equivalenceClass.Add(itemJ); equivalenceClassDiffset.Add(diffsetIJ); } } if (equivalenceClass.Count() > 0) { itemsetPrefix[0] = itemI[0]; itemsetPrefix[1] = itemI[1]; processEquivalenceClass(itemsetPrefix, 2, supI, equivalenceClass, equivalenceClassDiffset); } } } #endregion dEclat watch.Stop(); totalTimeSpend = watch.ElapsedMilliseconds; writer.Close(); var procEnd = System.Diagnostics.Process.GetCurrentProcess(); var mbUsedEnd = procEnd.PrivateMemorySize64; totalmbUsed = ((mbUsedEnd - mbUsedStart) * 1.0 / 1024) / 1024; GC.Collect(); } 65 Giải thuật BI-Eclat class biEclat { public biEclat(int _minSup, TransactionDB dbTrans, String outFile) { minSup = _minSup; database = dbTrans; writer=new StreamWriter(outFile); // Khởi tạo đếm số tập mục thường xuyên phát itemsetFound = 0; } public void run() { // CChuyển DB sang chiều dọc với //1 tính tidSet mục liệu cấp 1: Level for (int i = 0; i < database.getTranSize(); i++) // Với giao tác { List transaction = database.getTransactions()[i]; // thứ i for (int j = 0; j < transaction.Count; j++) //với mục giao tác { // mục giao tác UInt32 item = transaction[j]; // get the current tidset of that item HashSet tidset; bool ok = vertDB.TryGetValue(item, out tidset); // if (!ok) { tidset = new HashSet(); vertDB.Add(item, tidset); } tidset.Add(Convert.ToUInt32(i)); } } // tinh muc thuong xuyen cap 1, luu ket qua file out.txt // (1) danh sach muc thuong xuyen cap List frequent_1_Items = new List(); List frequent_1_ItemsTidset = new List(); foreach (KeyValuePair entry in vertDB) { //lay tidset cua item HashSet tidset = entry.Value; UInt32 item = entry.Key; // tinh toan ho tro cua tap du lieu muc dl int sup_1_Items = tidset.Count; if (sup_1_Items >= minSup) { frequent_1_Items.Add(item); frequent_1_ItemsTidset.Add(tidset); // ghi file để xem saveFile_1_Frequency(item, tidset, sup_1_Items); } } //sắp xếp giảm dẫn theo tidset size for (int i = 0; i < frequent_1_Items.Count - 1; i++) for (int j = i + 1; j < frequent_1_Items.Count; j++) 66 { if (frequent_1_ItemsTidset[i].Count < frequent_1_ItemsTidset[j].Count) { HashSet tamTidset = frequent_1_ItemsTidset[i]; frequent_1_ItemsTidset[i] = frequent_1_ItemsTidset[j]; frequent_1_ItemsTidset[j] = tamTidset; UInt32 tamItem = frequent_1_Items[i]; frequent_1_Items[i] = frequent_1_Items[j]; frequent_1_Items[j] = tamItem; } } // Tạo lớp tương đương 2-itemset cách hợp item đơn //duyet lan luot phân tử 1-itemset thường xuyên for (int i = 0; i < frequent_1_Items.Count; i++) { UInt32 itemI = frequent_1_Items[i]; HashSet tidsetI = frequent_1_ItemsTidset[i]; int supI = tidsetI.Count; // equalClassItems lưu trữ ký tự cuối lớp tương đương có prefix itemI, tidset có prefix itemI List equalClassItems = new List(); List equalClassTidsets = new List(); //duyet itemI đứng sau itemI for (int j = i + 1; j < frequent_1_Items.Count; j++) { UInt32 itemJ = frequent_1_Items[j]; HashSet tidsetJ= frequent_1_ItemsTidset[j]; int supJ = tidsetJ.Count; //tinh toán phép giao tidsetI tidsetJ để tidset itemset IJ HashSet tidsetIJ = performIntersection(tidsetI, supI, tidsetJ, supJ); int supIJ = tidsetIJ.Count; if (supIJ >= minSup) { equalClassItems.Add(itemJ); equalClassTidsets.Add(tidsetIJ); } }// -vong lap j // sinh 3-itemsets if (equalClassItems.Count > 0) { itemsetPrefix[0] = itemI; processEquivalenceClass(itemsetPrefix, 1, supI, equalClassItems, equalClassTidsets); } } // -for i watch.Stop(); totalTimeSpend = watch.ElapsedMilliseconds; writer.Close(); var procEnd = System.Diagnostics.Process.GetCurrentProcess(); var mbUsedEnd = procEnd.PrivateMemorySize64; totalmbUsed = ((mbUsedEnd - mbUsedStart) * 1.0 / 1024) / 1024; GC.Collect(); } // end run // 67 ... ? ?Nghiên cứu thuật toán khai phá tập phổ biến Eclat biến thể? ?? Luận văn chia làm chương: Chương Tổng quan khai phá tập phổ biến: Giới thiệu tổng quan khai phá tập phổ biến Phân loại hai giải thuật. .. quan vấn đề khai phá liệu, với trọng tâm kỹ thuật khai phá liệu luật kết hợp Bài toán quan trọng khai phá luật kết hợp phổ biến khai phá tập phổ biến Vấn đề với toán khai phá tập phổ biến khơng... phương pháp khai phá tập phổ biến luật kết hợp 10 1.5 Dàn tập mục liệu 11 1.6 Thuật toán vét cạn khai phá tập phổ biến 12 1.7 Thuật toán Apriori .13 1.8 Thuật toán

Ngày đăng: 17/05/2021, 14:37

Từ khóa liên quan

Mục lục

  • bia luan van

  • luanvanths-huongly (1)

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

Tài liệu liên quan