Một số kỹ thuật phân cụm dữ liệu và ứng dụng phân loại khách hàng sử dụng dịch vụ viễn thông

80 29 0
Một số kỹ thuật phân cụm dữ liệu và ứng dụng phân loại khách hàng sử dụng dịch vụ viễn thông

Đ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

ĐẠI HỌC THÁI NGUYÊN TRƢỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG NGUYỄN ĐÔNG HUY MỘT SỐ KỸ THUẬT PHÂN CỤM DỮ LIỆU VÀ ỨNG DỤNG PHÂN LOẠI KHÁCH HÀNG SỬ DỤNG DỊCH VỤ VIỄN THÔNG LUẬN VĂN THẠC SĨ CÔNG NGHỆ THÔNG TIN Thái Nguyên - 2014 LỜI CẢM ƠN Trong trình làm luận văn, thân em nhận đƣợc nhiều giúp đỡ bảo tận tình thầy giáo, giúp đỡ, tạo điều kiện gia đình, bạn bè để hồn thành khóa luận tiến độ Em xin trân trọng cảm ơn thầy giáo TS Nguyễn Huy Đức trực tiếp hƣớng dẫn nhiệt tình, bảo cặn kẽ trình làm luận văn Em xin gửi lời cám ơn chân thành tới Ban lãnh đạo nhà trƣờng, cán 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 thuận lợi để em hồn thành tốt khóa luận Học viên Nguyễn Đơng Huy LỜI CAM ĐOAN Em xin cam đoan kiến thức trình bày luận văn em tìm hiểu, nghiên cứu trình bày lại theo cách hiểu em Trong trình làm luận văn em có tham khảo tài liệu liên quan ghi rõ nguồn tài liệu tham khảo Phần lớn kiến thức em trình bày luận văn chƣa đƣợc trình bày hồn chỉnh tài liệu Thái Nguyên, ngày 10 tháng năm 2014 Học viên Nguyễn Đông Huy MỤC LỤC LỜI CẢM ƠN LỜI CAM ĐOAN MỤC LỤC DANH SÁCH HÌNH VẼ DANH SÁCH BẢNG BIỂU DANH MỤC CÁC TỪ VIẾT TẮT LỜIMỞ ĐẦU 10 CHƢƠNG 1: TỔNG QUAN VỀ KHAI PHÁ DỮ LIỆU 10 1.1 Khai phá liệu phát tri thức 11 1.1.1 Khai phá liệu 11 1.1.2 Quá trình khám phá tri thức 12 1.1.3 Khai phá liệu lĩnh vực liên quan 13 1.1.4 Các kỹ thuật áp dụng khai phá liệu 13 1.1.5 Ứng dụng khai phá liệu 15 1.2 Kỹ thuật phân cụm khai phá liệu 16 1.2.1 Tổng quan kỹ thuật phân cụm 16 1.2.2 Ứng dụng phân cụm liệu 18 1.2.3 Các yêu cầu kỹ thuật phân cụm liệu 19 1.3 Tổng kết chƣơng 20 CHƢƠNG 2: MỘT SỐ KỸ THUẬT PHÂN CỤM DỮ LIỆU 21 2.1 Phâncụmphânhoạch 21 2.1.1 Thuật toán k-means 22 2.1.2 Thuật toán PAM 24 2.1.3 Thuật toán CLARA 28 2.1.4 Thuật toán CLARANS 29 2.2 Phân cụm phân cấp 31 2.2.1 Thuật toán BIRCH 32 2.2.2 Thuật toán CURE 35 2.3 Phân cụm dựa mật độ 37 2.3.1 Thuật toán DBSCAN 38 2.3.2 Thuật toán OPTICS 42 2.3.3 Thuật toán DENCLUE 43 2.4 Phân cụm lƣới 44 2.4.1 Thuật toán STING 45 2.4.2 Thuật toán CLIQUE 46 2.5 Phân cụm liệu dựa mô hình 47 2.5.1 Thuật toán EM 48 2.5.2 Thuật toán COBWEB 49 2.6 Phân cụm liệu mờ 49 2.7 Tổng kết chƣơng 50 CHƢƠNG 3: ỨNG DỤNG PHÂN CỤM DỮ LIỆU ĐỂ PHÂN LOẠI KHÁCH HÀNG SỬ DỤNG DỊCH VỤ VIỄN THÔNG 52 3.1 Đặt vấn đề toán 52 3.2 Cài đặt Cơ sở liệu 52 3.3 Cài đặt thuật toán 56 3.4 Đánh giá kết phân cụm thuật toán PAM 60 3.5 Kết luận chƣơng 61 KẾT LUẬN 62 TÀILIỆUTHAMKHẢO 63 PHỤ LỤC 65 DANH SÁCH HÌNH VẼ Hình 1.1.Qtrìnhkhámphátri thức 11 Hình 1.2.Cáclĩnh vựcliênquan đến khámphátri thứctrongCSDL 13 Hình 1.3.Trựcquanhóakết quảKPDLtrongOracle .15 Hình 1.4.Mơphỏngsự PCDL 16 Hình 2.1.Thuậttốnk-means 22 Hình 2.2.Hìnhdạngcụmdữ liệu đƣợc khámphábởi k-means .23 Hình2.3.Trƣờnghợp Cjmp=d(Oj,Om,2) –d(Oj,Om) khơngâm 25 Hình2.4.Trƣờng hợp Cjmp=(Oj,Op)- d(Oj,Om)có thểâm hoặcdƣơng .26 Hình2.5.Trƣờnghợp Cjmpbằngkhơng 26 Hình2.6.Trƣờnghợp Cjmp=(Oj,Op)- d(Oj,Om,2)lnâm 27 Hình 2.7.Thuậttốn PAM 27 Hình 2.8.ThuậttốnCLARA 28 Hình 2.9.ThuậttốnCLARANS .31 Hình 2.10.Cácchiến lƣợcphâncụmphâncấp 32 Hình 2.11.CâyCF đƣợcsử dụngbởi thuật tốnBIRCH 34 Hình 2.12.ThuậttốnBIRCH 35 Hình 2.13.Ví dụvềkết quảphâncụmbằngthuậttốnBIRCH .35 Hình 2.14.Cáccụmdữ liệu đƣợckhámphábởi CURE 37 Hình 2.15.ThuậttốnCURE 37 Hình 2.16.Một sốhìnhdạngkhámphá phâncụmdựa trênmật độ 38 Hình 2.17.LâncậncủaP với ngƣỡngEps 39 Hình 2.18.Mật độ-đến đƣợctrựctiếp 40 Hình 2.19.Mật độ đến đƣợc 40 Hình 2.20.Mật độ liênthơng 41 Hình 2.21.Cụmvà nhiễu 41 Hình 2.22.ThuậttốnDBSCAN .42 Hình 2.23.Thứ tự phâncụmcácđối tƣợngtheoOPTICS 43 Hình 2.24.DENCLUEvới hàmphân phối Gaussian 45 Hình2.25.Mơhìnhcấutrúcdữliệulƣới 46 Hình2.26.ThuậttốnCLIQUE 48 Hình2.27.QtrìnhnhậndạngcácơcủaCLIQUE 48 DANH SÁCH BẢNG BIỂU Hình 3.1 Các trƣờng khai báo liệu 54 Hình 3.2.Dữ liệu khách hàng .55 Hình 3.3.Dữ liệu khách hàng SQL Server 56 Hình 3.4.Giao diện chƣơng trình nhập liệu 57 Hình 3.5.Giao diện chọn tham số cho thuật toán 58 Hình 3.6.Giao diện phân cụm theo thời lƣợng gọi 58 Hình 3.7.Danh sách khách hàng thuộc cụm theo thời lƣợng gọi 59 Hình 3.8.Danh sách khách hàng thuộc cụm theo thời lƣợng gọi 59 Hình 3.9.Danh sách khách hàng thuộc cụm theo thời lƣợng gọi 59 Hình 3.10.Giao diện phân cụm theo tiền dịch vụ 60 Hình 3.11.Danh sách khách hàng thuộc cụm theo tiền dịch vụ 60 Hình 3.12.Danh sách khách hàng thuộc cụm theo tiền dịch vụ 61 Hình 3.13.Danh sách khách hàng thuộc cụm theo tiền dịch vụ 61 DANH MỤC CÁC TỪ VIẾT TẮT Stt Viết tắt Cụm từtiếngAnh CNTT InformationTechnology Côngnghệthôngtin CSDL Database Cơ sởdữliệu KDD KnowledgeDiscovery inDatabase KPDL Datamining Khaiphá dữliệu KPVB TextMining Khaiphávănbản PCDL DataClustering Phâncụmdữ liệu Cụm từtiếngViệt Khámphá trithứctrongcơ sởdữliệu LỜIMỞĐẦU Trongnhữngnămgầnđâycùngvớipháttriểnnhanhchóngcủakhoahọckỹthuậtlà sựbùngnỗvềtrithức.Khodữliệu,nguồntrithứccủanhânloạicũngtrởnênđồsộ,vơtậnlà mchovấnđềkhaitháccácnguồntrithứcđóngàycàngtrởnênnóngbỏngvàđặtratháchthứ clớnchonềncơngnghệthơngtinthếgiới Đốivớimộtdoanhnghiệpthơngtin diđộngviệcpháttriểnthbao đểkiếmtìmlợinhuậnvàothờiđiểmhiệntạiđãkhơngcịnđemlạihiệuquả.Thayvàođólà mộtphƣơngánkinhdoanhtiếnđếnpháttriểnchấtlƣợngdịchvụ vàcungcấpthêmnhiềudịchvụgiátrịgiatăng.Tuynhiêncácdịchvụtruyềnthốngnhƣtho ại,nhắntinvẫncóthểđemlạinguồnlợinhuậncaohơnnếukíchthíchđƣợcnhucầusửdụng củakháchhàng Để thực đƣợc điều đó, doanh nghiệp phải khơng ngừng giữ vững đƣợc khách hàng có mà cịn phải đƣa đƣợc chiến lƣợc phát triển kinh doanh dài hạn, phân loại đƣợc nhóm khách hàng sử dụng để từ có sách phân khúc thị trƣờng hợp lý Vì vậy, em dựa vào thực trạng nhƣ kết hợp với kỹ thuật phân cụm khai phá liệu để thực đề tài: “Một số kỹ thuật phân cụm liệu ứng dụng phân loại khách hàng sử dụng dịch vụ Viễn thông” Bố cục luận văn gồm chương: Chƣơng 1: Trình bày cách tổng quan kiến thức khai phá liệu phát tri thức, kỹ thuật phân cụm khai phá liệu Chƣơng 2: Giới thiệu số liệu phân cụm phổ biến thƣờng đƣợc sử dụng khai phá liệu phát tri thức Chƣơng 3: Sử dụng kỹ thuật phân cụm để ứng dụng vào phân loại khách hàng sử dụng dịch vụ viễn thông Trong chƣơng trình bày chƣơng trình mơ áp dụng kỹ thuật phân cụm để phân loại sử dụng dịch vụ Viễn thông Phần kết luận luận văn tổng kết lại vấn đề nghiên cứu, đánh giá kết nghiên cứu, hƣớng phát triển đề tài CHƢƠNG 1: TỔNG QUAN VỀ KHAI PHÁ DỮ LIỆU 10 // next-nearest medoid of each element int[] nextNearestMedoids; // set of medoids HashSet medoids; // set of non-meoids (maintain for finding swap candidates) HashSet nonmedoids; // set of all indexed elements // required since Java's HashSet cannot use native types int[] elements; int maxSwaps = 1000; public PAM(BaseMatrix data) : this(data, null, null) { } public PAM(BaseMatrix data, DistanceMatrix distances, int[] idx) { this.data = data; if (data == null || data.NRows() == 0) { throw new Exception("Data matrix is empty."); } if (idx == null) { // initially, use index all data elements in original order int m = data.NRows(); idx = new int[m]; for (int i = 0; i < m; ++i) 66 { idx[i] = i; } } this.idx = idx; if (distances == null) { this.distances = new DistanceMatrix(data, idx); } else { this.distances = distances.subset(idx); } this.clusters = null; } public Clusters cluster(int k) { int n = size(); if (n == 0) { throw new Exception("No data elements are indexed."); } if (k > n) { throw new Exception("Number of clusters must be less than the number of data elements."); 67 } else if (k == n) { // build trivial single clusters return new Clusters(k); } this.nClusters = k; initialize(); buildPhase(); swapPhase(); clusters = new Clusters(nearestMedoids, getCost()); clusters.center = medoids; return clusters; } /** * Size Number of data elements */ public int size() { return idx.Length; } /** * Calculate the clustering cost: sum of distances to cluster medoids * @return cost */ private double getCost() { 68 double c = 0; for (int i = 0; i < nearestDistances.Length; ++i) { c += nearestDistances[i]; } return c; } private void initialize() { int m = size(); nearestDistances = new double[m]; nextNearestDistances = new double[m]; nearestMedoids = new int[m]; nextNearestMedoids = new int[m]; elements = new int[m]; medoids = new HashSet(); nonmedoids = new HashSet(); for (int ii = 0; ii < m; ++ii) { // initialize distances to infinity nearestDistances[ii] Double.PositiveInfinity; = nextNearestDistances[ii] = // initialize medoids to non-valid indices, s.t unexpected bugs trigger indexing error nearestMedoids[ii] = nextNearestMedoids[ii] = -1; elements[ii] = ii; // all (indexed) data elements are initially non-medoids 69 nonmedoids.Add(elements[ii]); } } /** * BUILD phase Select a initial set of k medoids */ private void buildPhase() { int m = size(); // select first medoid // find element with minimum total distance to all other elements double[] totalDistances = new double[m]; for (int ii = 0; ii < m; ++ii) { // sum distances to all other elements // assume distance to itself is double d = 0; for (int jj = 0; jj < m; ++jj) { d += distances.getValue(ii, jj); } totalDistances[ii] = d; } double minDistance = totalDistances[0]; int minIndex = 0; for (int ii = 0; ii < m; ++ii) { 70 if (totalDistances[ii] < minDistance) { minDistance = totalDistances[ii]; minIndex = ii; } } // add element to medoid set addMedoid(minIndex); // select remaining k - medoids double[] gains = new double[m]; for (int kk = 1; kk < nClusters; ++kk) { // consider each i as medoid candidate for (int ii = 0; ii < m; ++ii) { // if ii is already a medoid, it has negative gain to prevent it from being selected again if (medoids.Contains(elements[ii])) { gains[ii] = -1.0; } else { double gain = 0; // for each non-medoid j != i, calculate the gain for (int jj = 0; jj < m; ++jj) { 71 if (jj == ii || medoids.Contains(elements[jj])) continue; if (nearestDistances[jj] > distances.getValue(ii, jj)) { // add i will improve j's nearest distances // (if selected, i will be the new nearest neighbour of j) gain += nearestDistances[jj] - distances.getValue(ii, jj); } } gains[ii] = gain; } } // select candidate with maximum gain double maxGain = Double.NegativeInfinity; int maxIndex = -1; for (int ii = 0; ii < m; ++ii) { if (gains[ii] > maxGain) { maxGain = gains[ii]; maxIndex = ii; } } // add element to medoid set addMedoid(maxIndex); } // check that the number of medoids match the expected if (nClusters != medoids.Count) 72 { throw new Exception("Expected error in BUILD phase: Number of medoids does not match parameter k."); } } /** * SWAP phase Attempt to improve clustering quality by exchanging medoids with non-medoids */ private void swapPhase() { bool notConverged = true; bool continueLoop = true; int nSwaps = 0; while (notConverged && continueLoop) { notConverged = false; continueLoop = false; IEnumerator medIt = medoids.GetEnumerator(); while (medIt.MoveNext() && continueLoop) { int ii = medIt.Current; IEnumerator nonmedIt = nonmedoids.GetEnumerator(); while (nonmedIt.MoveNext()) { int hh = nonmedIt.Current; // Consider swapping medoid i and nonmedoid h 73 // by calculating gains by all other elements // Calculate cumulative change to distance to nearest medoid for all nonmedoids j != h double change = 0; IEnumerator nonmedIt2 = nonmedoids.GetEnumerator(); while (nonmedIt2.MoveNext()) { int jj = nonmedIt2.Current; if (jj == hh) continue; double d = nearestDistances[jj]; if (distances.getValue(ii, jj) > d) { // if removed, i will have no impact if (distances.getValue(jj, hh) < d) { // if selected, h will improve nearest distance for j change += distances.getValue(jj, hh) - d; } } else { // i cannot be closer than the nearest neighbour for j; // therefore, distances[i][j] == d // and i is currently the nearest neighbour for j double e = nextNearestDistances[jj]; if (distances.getValue(jj, hh) < e) { 74 // if i and h are swapped, h will become the nearest neighbour // nearest distance for j may improve or worsen change += distances.getValue(jj, hh) - d; } else { // if i is removed, the current next-nearest of j will be promoted to nearest change += e - d; } } } if (change < 0) { // distance to nearest medoid summed over all nonmedoids is improved: swap swap(hh, ii); //System.out.print("Swap " + hh + " and " + ii + " for change = " + change + "\n"); // non-convergence if any swap occurs, up to a maximum number of swaps (to guard against swap cycles) if (nSwaps++ < maxSwaps) { notConverged = true; } else { 75 continueLoop = false; } // reset iterator medIt = medoids.GetEnumerator(); // break out of inner loop to consider next medoid break; } } } } } private void addMedoid(int add) { medoids.Add(elements[add]); nonmedoids.Remove(elements[add]); updateNearest(add, -1); } private void swap(int add, int remove) { medoids.Add(elements[add]); nonmedoids.Remove(elements[add]); medoids.Remove(elements[remove]); nonmedoids.Add(elements[remove]); 76 updateNearest(add, remove); } /** * Update nearest and next-nearest distances * Does not check whether {@code added} or {@ removed} have been added to or removed from the medoid set * FIXME optimize * @param added Index of element added to medoid set (-1 for none) * @param removed Index of element removed from medoid set (-1 for none) */ private void updateNearest(int added, int removed) { int m = size(); if (added >= 0) { // added index is valid // check if any nearest distance improves for (int ii = 0; ii < m; ++ii) { double d = distances.getValue(ii, added); if (d < nearestDistances[ii]) { // element i is nearer to added medoid than previous nearest: update double oldDistance = nearestDistances[ii]; 77 int oldMedoid = nearestMedoids[ii]; nearestMedoids[ii] = added; nearestDistances[ii] = d; // pump nearest distance to next-nearest distance nextNearestMedoids[ii] = oldMedoid; nextNearestDistances[ii] = oldDistance; } else if (d < nextNearestDistances[ii]) { // element i is nearer to added medoid than previous next-nearest: update nextNearestMedoids[ii] = added; nextNearestDistances[ii] = d; } } } if (removed >= 0) { // removed index is valid // check if the removed medoid is the nearest or next-nearest of any element for (int ii = 0; ii < m; ++ii) { if (nearestMedoids[ii] == removed) { 78 // promote next-nearest to nearest nearestMedoids[ii] = nextNearestMedoids[ii]; nearestDistances[ii] = nextNearestDistances[ii]; // find new next-nearest updateNextNearest(ii); } else if (nextNearestMedoids[ii] == removed) { // find new next-nearest updateNextNearest(ii); } } } } /** * Update next nearest for element i * Assume nearest medoid is already set * @param ii element index to be updated */ private void updateNextNearest(int ii) { int nearestMedoid = nearestMedoids[ii]; // find the next-nearest IEnumerator it = medoids.GetEnumerator(); double minDistance = Double.PositiveInfinity; 79 int nextNearestMedoid = -1; while (it.MoveNext()) { int jj = it.Current; // ignore if j is the nearestMedoid, since we are interested in the nextnearest if (jj == nearestMedoid) continue; if (distances.getValue(ii, jj) < minDistance) { minDistance = distances.getValue(ii, jj); nextNearestMedoid = jj; } } // update nextNearestDistances[ii] = minDistance; nextNearestMedoids[ii] = nextNearestMedoid; } } } 80 ... ệulàphâncụmd? ?liệu, gồmtổngquanvềkỹthuậtphâncụm,cácứngdụngcủaphâncụm,cá cyêucầuđốivớikỹthuậtphâncụm,cáckiểudữliệuvàđộđotƣơngtự, CHƢƠNG 2: MỘT SỐ KỸ THUẬT PHÂN CỤM DỮ LIỆU Cáck? ?thuật? ?pdụngđểgiảiquyếtvấnđềPCDLđềuhƣớngtớihaimụctiêuchung:C... phân cụm để ứng dụng vào phân loại khách hàng sử dụng dịch vụ viễn thông Trong chƣơng trình bày chƣơng trình mơ áp dụng kỹ thuật phân cụm để phân loại sử dụng dịch vụ Viễn thông Phần kết luận... vào thực trạng nhƣ kết hợp với kỹ thuật phân cụm khai phá liệu để thực đề tài: ? ?Một số kỹ thuật phân cụm liệu ứng dụng phân loại khách hàng sử dụng dịch vụ Viễn thông? ?? Bố cục luận văn gồm chương:

Ngày đăng: 24/02/2021, 21:44

Từ khóa liên quan

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

Tài liệu liên quan