Data Mining Operation using SQL Query (Fuzzy Apriori Algorithm) - Coding it using SQL

后端 未结 1 1573
滥情空心
滥情空心 2021-01-11 17:07

So I have this Table:

Trans_ID    Name    Fuzzy_Value    Total_Item  
100          I1  0.33333333        3  
100          I2  0.33333333        3  
100                


        
相关标签:
1条回答
  • 2021-01-11 17:30

    Step 1:

    CREATE TABLE ITEMSET
    SELECT Name, SUM(Fuzzy_Value)/COUNT(*) Fuzzy_Value
    FROM trans
    GROUP BY ID
    HAVING ROUND(SUM(Fuzzy_Value), 1) >= 0.1
    

    Note the ROUND() function - it's important, because you have values like .33333 that don't sum in a happy way.

    Step 2:

    ALTER TABLE ITEMSET ADD INDEX (Name)
    
    SELECT a.Name Name1, b.Name Name2, SUM(Fuzzy_Value)/COUNT(*) Fuzzy_Value
    FROM ITEMSET a JOIN ITEMSET b ON (a.Name != b.Name)
    GROUP BY a.Name, b.Name
    HAVING ROUND(SUM(Fuzzy_Value), 1) >= 0.1
    

    Opps: I just noticed that you asked this half a year ago, so I guess there is no point in continuing. If you still need this answer leave a comment.

    0 讨论(0)
提交回复
热议问题