Cài đặt thuật toỏn F-Apriori

Một phần của tài liệu TÌM HIỂU MỘT SỐ LỚP TOÁN TỬ KÉO THEO VÀ ỨNG DỤNG MỘT VÀI BÀI TOÁN CỦA CƠ SỞ DỮ LIỆU MỜ (Trang 74)

Sau khi cài đặt thuật toỏn F-Apriori, cỏc bước tiến hành khai thỏc dữ liệu gồm:

 Bước 1:Mờ hoỏ số liệu ban đầu

- Chọn nguồn dữ liệu cần khai thỏc, ở bước này: đầu tiờn người dựng nhập vào một tệp tin cú nội dung gồm hai dũng

+ Dũng 1 gồm : Số bản ghi và số thuộc tớnh của CSDL cần khai thỏc dữ liệu.

+ Dũng 2 gồm: số cỏc từ được mờ hoỏ của mỗi thuộc tớnh trong CSDL. Tiếp theo người dựng nhập vào tệp tin chớnh là CSDL cần khai thỏc, chương trỡnh sẽ mờ húa số liệu để chuyển số liệu gốc ban đầu sang số liệu mờ.

- Lưu lại tệp số liệu đó được mờ hoỏ.

Ở bước này người dựng nhập vào tệp tin chứa số liệu đó được mờ hoỏ, sau đú chọn cỏc tham số như t-chuẩn hoặc t-chuẩn cú ngưỡng, độ hỗ trợ, độ chắc chắn để tỡm cỏc mệnh đề, và từ đú đưa ra cỏc luật kết hợp. Kết quả cú thể khỏc nhau tuỳ theo tham số được chọn.

Thuật toỏn đó cài đặt chưa được ứng dụng vào thực tế, chỉ là cỏc CSDL giả định.

Bài toỏn tỡm số liệu về bệnh nhõn rối loạn chức năng gan

Đối với những bệnh nhõn rối loạn chức năng gan thỡ những chỉ số sau đõy cần được tỡm hiểu và đỏnh giỏ trong quỏ trỡnh điều trị bệnh:

- Thể tớch tiểu thể trung bỡnh - Kiềm - Alannine - Atpatac - Glutamin - Tiờu thụ đồ uống cú cồn

Số liệu của cỏc chỉ số trờn được lưu vào một tệp tin dạng text, tệp tin gồm sỏu thuộc tớnh, mỗi chỉ số ứng với một thuộc tớnh.

KẾT LUẬN Những vấn đề đó đƣợc giải quyết trong luận văn.

Luận văn đó tổng hợp những nột chớnh về logớc mờ núi chung và t-chuẩn, t-chuẩn cú ngưỡng, phộp kộo theo mờ núi riờng, bước đầu ỏp dụng t-chuẩn cú ngưỡng để khai thỏc luật kết hợp mờ. Sau đõy là những điểm chớnh mà luận văn đó tập trung giải quyết.

Trong chương I luận văn đó trỡnh bày tổng quan về logớc mờ, cụ thể là đưa ra định nghĩa chi tiết về tập mờ và quan hệ mờ (đặc biệt nhấn mạnh đến cỏc phộp toỏn về logớc mờ, trong đú cú t-chuẩn, t-đối chuẩn, phộp phủ định, đõy là cỏc phộp toỏn làm cơ sở cho cỏc phộp kộo theo cụ thể), phộp kộo theo và phõn loại phộp kộo theo, vấn đề ỏp dụng phộp kộo theo trong suy luận mờ.

Chương II trỡnh bày chi tiết về t-chuẩn cú ngưỡng, ỏp dụng t-chuẩn cú ngưỡng trong suy luận mờ, phộp kộo theo cú ngưỡng. Đõy là những vấn đề mới đang được cỏc nhà khoa học trong và ngoài nước nghiờn cứu cả về mặt lý thuyết và những ứng dụng vào thực tiễn.

Chương III luận văn trỡnh bày về cơ sở dữ liệu mờ và luật kết hợp mờ, mối quan hệ giữa luật kết hợp mờ và phộp kộo theo mờ. Ở chương này cũng trỡnh bày khỏi quỏt thuật toỏn Apriori để tỡm luật kết hợp núi chung và dựa trờn thuật toỏn này đưa ra được thuật toỏn F-Apriori tỡm luật kết hợp mờ.

Chương IV trỡnh bày bước đầu ứng dụng phộp kộo theo vào tớnh toỏn luật kết hợp mờ và cài đặt thuật toỏn F-Apriori đó nờu ở chương III trờn một số cơ sở dữ liệu đơn giản.

Cụng việc nghiờn cứu trong tƣơng lai

Cỏc hướng nghiờn cứu tiếp theo của đề tài tập trung vào ba hướng chớnh:

 Ứng dụng thuật toỏn F-Apriori vào cỏc bài toỏn trong thực tế..

 Ứng dụng cỏc toỏn tử mờ cú ngưỡng vào tớnh toỏn luật kết hợp mờ

 Thuật toỏn khai phỏ dữ liệu: đưa ra được cỏc thuật toỏn mạnh hơn với mục đớch khai phỏ được cỏc luật kết hợp cú hiệu quả, phự hợp với thực tiễn.

TÀI LIỆU THAM KHẢO Tiếng Việt

[1] B. C. Cường và L. C. Ngọc (2005), “Một số lớp toỏn tử mờ cú ngưỡng”, Preprint 05/05, Viờn Toỏn học, Viện Khoa học và Cụng nghệ Quốc gia.

[2] B. C. Cường và L. C. Ngọc (2005), “Luật kết hợp mờ và T- chuẩn cú ngưỡng”, Preprint 05/06, Viờn Toỏn học, Viện Khoa học và Cụng nghệ Quốc gia.

[3] Nguyễn Cụng Hào, Cỏc phộp toỏn quan hệ và phụ thuộc hàm mờ dựa trờn số mờ hỡnh thang, tạp chớ khoa học Đại học Huế, Số 20 (2003), 33-38

[4] B.C.Cường và N.D.Phước (chủ biờn), hệ mờ mạng nơ ron và ứng dụng, NXB Khoa học kỹ thuật, Hà nội 2001.

[5] Hoàng Minh Giang (2005), Tỡm hiểu một số thuật toỏn khai phỏ luật kết hợp và ứng dụng, Luận văn thạc sỹ- Đại học Bỏch Khoa Hà Nội.

Tiếng Anh

[6] R.Argawal, T. Imielinski and A. Swam (1993) “Mining Association Rules Between Sets of Item in Large Databases”, Proceeding of the 1993 ACM SIGMOD International Conference on Management of Data, volume 22(2) of SIGMOD Record, pages 207-216, ACM Press. [7] R. Argawal and R. Srikant (1994), “Fast Algorithms for

Mining Association Rules in Large Databases”, IBM Research Report RJ9839, IBM Almaden Research Center, San Jose, California, June 1994.

[8] B. C. Cuong, Nguyen Hoang Phuong, Ho Khanh Le, Bui Truong Son and Koichi Yamada (2003) “Fuzzy Inference Methods Employing T-norm with threshold and Their Implementation”, Journal of Advanced Computational Inteligence and Intelligence Informatics , vol.7, n.3, 2003, pages 362-369

[9] Buckles B.P, Petry F.E. (1982), A Fuzzy Representation of Data for Relational databases, Fuzzy Sets and Systems 7 (3), 213-226.

[10] B. C. Cuong and L. C. Ngoc (2004), “Some Remarks on Fuzzy Operators with Threshold”, Proceeding of the Sixth International Conference on Fuzzy Systems, AFSS’ 2004, December 15-16, 2004, Hanoi, pages 174-179.

[11] B.C.Cuong, L.B.Long, P.V.Loi, D.V.Hieu, Some properties of t-norms with threshold, proceedings of the second Viet Nam - Japan Symposium on Fuzzy Systems and Applications, VJFUZZY‟2001, Hanoi,2001,28-33

[12] M. De Cock C. Cornelis E. E. Kerre (2003), “Fuzzy Association Rules: a Two-Sided Approach”, Proceedings of International Conference on Fuzzy Information Processing - Theories and Applications 2003, 687-691. [13] Gert De Cooman (1997), “Possibility Theory II:

Conditional Possibility”, International Journal of General Systems, Vol. 25, 1997.

[14] D. Dubois and H. Prade (1990), “The Logical View of Conditioning and Its Applications to Possibility and Evidence Theories”, International Journal of Approximate Reasoning, 4:23-46, 1990.

[15] D. Dubois and H. Prade (1998), “Basic Notions of Possibility Theory”, Handbook of Fuzzy Computation,

Institute of Physics Publishing Ltd.

[16] B.Goethals (2002), Efficient Frequent Pattern Mining. PhD thesis, University Limburg.

[17] H.Thuan, T.T. Thanh (2002), Fuzzy Functionnal Dependencies with Linguistic Quantifiers, Tạp chớ khoa học và điều khiển học, Tập 18(2), 97-108.

[18] Renộ Jager (1995), Fuzzy Logic in Control, page 1-72. [19] C. M. Kuok, Ada Fu and Man Hon Wong (1998), “Mining

Fuzzy Association Rules in Databases”, SIGMOD Record, 1998.

[20] Lee, C.C. (1990a).Fuzzy Logic in control systems: fuzzy logic controller-part &ii IEEE Transactions on Systems, Man, and Cybernetics 20(2),404-435

[21] Lee, C.C. (1990b).Fuzzy Logic in control systems: fuzzy logic controller-part &ii IEEE Transactions on Systems, Man, and

[22] Hung.T.Nguyen and Elbert A. Walker, A First Course in Fuzzy Logic, Tr.87-88, Second Edition, Chapmam & Hall, London, 2000.

[23] R. Srikant and R. Argawal (1996), “Mining Quantitative Association Rules in Large Relational Databases”,

Prooceedings of ACM SIGMOD, pages 1-12.

[24] L. A. Zadeh (1978), “Fuzzy sets as a basis for a theory of possibility”, Fuzzy Sets and Systems, 1, 2-28.

[25] H.J.Zimmermann, Fuzzy Set Theory and its Applications, Second Edition, Kluwer Acad. Pub, Dordrecht,1991.

PHỤ LỤC

Private Sub PropositionMiner() Dim FileNum As Integer

Dim Candidate(1000, 10) As Byte Dim CandidateSupp(1000) As Single Dim NumOfCan As Integer

Dim I As Integer Dim J As Integer Dim K As Integer Dim d(255) As Single Dim Tmp As Single

Dim Candidate2(255, 255) As Boolean Dim Diff As Boolean

Dim PassThreshold As Boolean On Error GoTo InError

'Khởi tạo các mệnh đề ứng viên độ dài 1

NumOfCan = 0 For I = 1 To NumOfAttribute For J = 1 To NumOfWord(I) NumOfCan = NumOfCan + 1 Candidate(NumOfCan, 1) = (I - 1) * 8 + (J - 1) CandidateSupp(NumOfCan) = 0 Next Next 'Đếm hỗ trợ các mệnh đề độ dài 1 FileNum = FreeFile MaxLength = 1 NumOfProposition(0) = 0

Open InFileName For Input As #FileNum For I = 1 To NumOfRecord For J = 1 To NumOfAttribute For K = 1 To NumOfWord(J) Input #FileNum, d((J - 1) * 8 + (K - 1)) Next Next For J = 1 To NumOfCan

CandidateSupp(J) = CandidateSupp(J) + d(Candidate(J, 1))

'Cộng dồn các độ ủng hộ để tính độ hỗ trợ Next Next Close FileNum 'Ghi nhận các mệnh đề độ dài 1, có độ hỗ trợ đủ lớn NumOfProposition(1) = 0 For I = 1 To NumOfCan

If CandidateSupp(I) > Xichma Then

NumOfProposition(1) = NumOfProposition(1) + 1 Proposition(NumOfProposition(1), 1) = Candidate(I, 1) PropositionSupp(NumOfProposition(1)) = CandidateSupp(I) End If Next If NumOfProposition(1) = 0 Then MaxLength = 0

Exit Sub End If

'Khởi tạo tập các mệnh đề ứng viên độ dài 2 ………

………..

'Khởi tạo tập các mệnh đề ứng viên độ dài 3

NumOfCan = 0

For I = NumOfProposition(1) + 1 To NumOfProposition(2) - 1 For J = I + 1 To NumOfProposition(2)

If (Proposition(I, 1) = Proposition(J, 1)) And (Proposition(I, 2) \ 8 < Proposition(J, 2) \ 8) And Candidate2(Proposition(I, 2), Proposition(J, 2)) Then NumOfCan = NumOfCan + 1 Candidate(NumOfCan, 1) = Proposition(I, 1) Candidate(NumOfCan, 2) = Proposition(I, 2) Candidate(NumOfCan, 3) = Proposition(J, 2) CandidateSupp(NumOfCan) = 0 End If Next Next

'Tiến hành vòng lặp từ bước thứ 3 trở lên

Do While NumOfCan > 0

MaxLength = MaxLength + 1

'Đếm độ hỗ trợ của các mệnh đề ứng viên

FileNum = FreeFile

Open InFileName For Input As #FileNum For I = 1 To NumOfRecord For J = 1 To NumOfAttribute For K = 1 To NumOfWord(J) Input #FileNum, d((J - 1) * 8 + (K - 1)) Next Next For J = 1 To NumOfCan Tmp = 1 If chkThreshold.Value Then PassThreshold = True For K = 1 To MaxLength If d(Candidate(J, K)) < Threshold(Candidate(J, K)) Then PassThreshold = False Exit For End If Next End If

If chkThreshold.Value And (Not PassThreshold) Then Select Case cbt2.Text

Case "Multiplication" For K = 1 To MaxLength Tmp = Tmp * d(Candidate(J, K)) Next Case "Lukarsewicz" For K = 1 To MaxLength Tmp = Lukarsewicz(Tmp, d(Candidate(J, K)))

Next …………..

……… Else

Select Case cbt1.ListIndex Case 0 For K = 1 To MaxLength Tmp = Min(Tmp, d(Candidate(J, K))) Next Case 1 For K = 1 To MaxLength Tmp = Tmp * d(Candidate(J, K)) Next Case 2 For K = 1 To MaxLength Tmp = Lukarsewicz(Tmp, d(Candidate(J, K))) Next ……… ………. End Select End If CandidateSupp(J) = CandidateSupp(J) + Tmp Next Next Close FileNum 'Ghi nhận các mệnh đề có độ hỗ trợ đủ lớn NumOfProposition(MaxLength) = NumOfProposition(MaxLength - 1) For I = 1 To NumOfCan

If CandidateSupp(I) > Xichma Then NumOfProposition(MaxLength) = NumOfProposition(MaxLength) + 1 For J = 1 To MaxLength Proposition(NumOfProposition(MaxLength), J) = Candidate(I, J) Next PropositionSupp(NumOfProposition(MaxLength)) = CandidateSupp(I) End If Next If NumOfProposition(MaxLength) = NumOfProposition(MaxLength - 1) Then MaxLength = MaxLength - 1 Exit Sub End If

'Khởi tạo tập mệnh đề ứng viên cho vòng lặp tiếp theo

NumOfCan = 0 For I = NumOfProposition(MaxLength - 1) + 1 To NumOfProposition(MaxLength) - 1 For J = I + 1 To NumOfProposition(MaxLength) Diff = False For K = 1 To MaxLength - 1

Diff = True Exit For End If Next

If (Not Diff) And (Proposition(I, MaxLength) \ 8 < Proposition(J, MaxLength) \ 8) And Candidate2(Proposition(I, MaxLength), Proposition(J, MaxLength)) Then

NumOfCan = NumOfCan + 1 For K = 1 To MaxLength

Candidate(NumOfCan, K) = Proposition(I, K) Next

Candidate(NumOfCan, MaxLength + 1) = Proposition(J, MaxLength) CandidateSupp(NumOfCan) = 0 End If Next Next Loop Exit Sub InError:

MsgBox "Fuzzy Database file is not valid", vbOKOnly + vbCritical, "Warning!"

End Sub

**************************************************************

Private Sub RuleMiner()

Dim Candidate(1000, 10) As Byte Dim NumOfCan As Integer

Dim I As Integer Dim J As Integer Dim K As Integer Dim I1 As Integer Dim I2 As Integer Dim I3 As Byte Dim I4 As Byte

Dim Candidate2(255, 255) As Boolean Dim MaxLengthHead As Integer

Dim Diff As Boolean Dim Match As Boolean Dim SuppRule As Single Dim RuleLength As Byte Dim Rule(10) As Byte

Dim RuleHeadTemp(10) As Byte Dim RuleBodyTemp(10) As Byte Dim NumOfCertHead As Integer Dim RuleIndex As Integer NumOfRule = 0 For I1 = 2 To MaxLength RuleLength = I1 For I2 = NumOfProposition(RuleLength - 1) + 1 To NumOfProposition(RuleLength) RuleIndex = I2 SuppRule = PropositionSupp(RuleIndex) For I = 1 To RuleLength

Rule(I) = Proposition(RuleIndex, I) Next

'Khởi tạo các phần đầu ứng viên độ dài 1

NumOfCan = 0

For I = 1 To RuleLength NumOfCan = NumOfCan + 1

Candidate(NumOfCan, 1) = Rule(I) Next

'Xác định các phần đầu độ dài 1 làm cho luật tin chắc NumOfCertHead = NumOfRule + 1

For I = 1 To NumOfCan K = 0

For J = 1 To RuleLength

If Rule(J) <> Candidate(I, 1) Then K = K + 1 RuleBodyTemp(K) = Rule(J) End If Next J = NumOfProposition(RuleLength - 2) Do J = J + 1 Match = True For I3 = 1 To RuleLength - 1

If Proposition(J, I3) <> RuleBodyTemp(I3) Then Match = False

Exit For End If Next

Loop While Not Match

If SuppRule / PropositionSupp(J) > Gamma Then NumOfRule = NumOfRule + 1

RuleSupp(NumOfRule) = SuppRule

RuleCert(NumOfRule) = SuppRule / PropositionSupp(J) RuleHead(NumOfRule, 1) = Candidate(I, 1) RuleHeadLength(NumOfRule) = 1 RuleBodyLength(NumOfRule) = RuleLength - 1 For K = 1 To RuleLength - 1 RuleBody(NumOfRule, K) = RuleBodyTemp(K) Next End If Next

If (RuleLength = 2) Or (NumOfRule < NumOfCertHead) Then GoTo Thoat

End If

'Khởi tạo tập các phần đầu ứng viên độ dài 2 ……….

………..

'Tiến hành vòng lặp từ bước thứ 3 trở lên

MaxLengthHead = 2

Do While (NumOfCan > 0) And (MaxLengthHead < RuleLength - 1)

'Xác định các phần đầu ứng viên làm cho luật tin chắc NumOfCertHead = NumOfRule + 1 For I = 1 To NumOfCan K = 0 I3 = 0 I4 = 1 Do While I3 <= RuleLength I3 = I3 + 1

If (I4 < MaxLengthHead) And (Rule(I3) = Candidate(I, I4)) Then I4 = I4 + 1 Else K = K + 1 RuleBodyTemp(K) = Rule(I3) End If Loop J = NumOfProposition(RuleLength - MaxLengthHead - 1) Do J = J + 1 Match = True

For I3 = 1 To RuleLength - MaxLengthHead

If Proposition(J, I3) <> RuleBodyTemp(I3) Then Match = False

Exit For End If Next

Loop While Not Match

If SuppRule / PropositionSupp(J) > Gamma Then NumOfRule = NumOfRule + 1

RuleSupp(NumOfRule) = SuppRule

RuleCert(NumOfRule) = SuppRule / PropositionSupp(J) For K = 1 To MaxLengthHead

RuleHead(NumOfRule, K) = Candidate(I, K) Next

For K = 1 To RuleLength - MaxLengthHead RuleBody(NumOfRule, K) = RuleBodyTemp(K) Next RuleHeadLength(NumOfRule) = MaxLengthHead RuleBodyLength(NumOfRule) = RuleLength - MaxLengthHead End If Next

If NumOfRule < NumOfCertHead Then GoTo Thoat

End If

'Khởi tạo tập phần đầu ứng viên cho vòng lặp tiếp

theo

NumOfCan = 0

For I = NumOfCertHead To NumOfRule - 1 For J = I + 1 To NumOfRule

Diff = False

If RuleHead(I, K) \ 8 <> RuleHead(J, K) \ 8 Then Diff = True

Exit For End If Next

If (Not Diff) And (RuleHead(I, MaxLengthHead) \ 8 < RuleHead(J, MaxLengthHead) \ 8) And Candidate2(RuleHead(I, MaxLengthHead), RuleHead(J, MaxLengthHead)) Then

NumOfCan = NumOfCan + 1 For K = 1 To MaxLengthHead Candidate(NumOfCan, K) = RuleHead(I, K) Next Candidate(NumOfCan, MaxLengthHead + 1) = RuleHead(J, MaxLengthHead) End If Next Next Loop Thoat: Next Next End Sub

PDF Merger

Thank you for evaluating AnyBizSoft PDF Merger! To remove this page, please

register your program!

Go to Purchase Now>>

 Merge multiple PDF files into one

 Select page range of PDF to merge

 Select specific page(s) to merge

 Extract page(s) from different PDF files and merge into one

Một phần của tài liệu TÌM HIỂU MỘT SỐ LỚP TOÁN TỬ KÉO THEO VÀ ỨNG DỤNG MỘT VÀI BÀI TOÁN CỦA CƠ SỞ DỮ LIỆU MỜ (Trang 74)