99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁精彩閱讀關(guān)于數(shù)據(jù)挖掘關(guān)聯(lián)規(guī)則的Oracle實(shí)現(xiàn)
關(guān)于數(shù)據(jù)挖掘關(guān)聯(lián)規(guī)則的Oracle實(shí)現(xiàn)
2017-01-09
收藏

關(guān)于數(shù)據(jù)挖掘關(guān)聯(lián)規(guī)則的Oracle實(shí)現(xiàn)

前幾天拿到了數(shù)據(jù)挖掘基礎(chǔ)教程一書,感覺部分算法是基于統(tǒng)計學(xué)的原理的,而統(tǒng)計學(xué)是可以通過Oracle來實(shí)現(xiàn)。

其次是為了觀看德國vs西班牙的世界杯比賽,來了一點(diǎn)小小的興致,動手寫點(diǎn)小腳本。不過本文只是為了實(shí)現(xiàn)而實(shí)現(xiàn)的,沒有做任何優(yōu)化,有興趣的話,大家可以玩一玩。


關(guān)于數(shù)據(jù)挖掘關(guān)聯(lián)規(guī)則的材料,可以參見:

http://baike.baidu.com/view/1076817.htm?fr=ala0_1

關(guān)聯(lián)規(guī)則是形如X→Y的蘊(yùn)涵式,

其中且, X和Y分別稱為關(guān)聯(lián)規(guī)則的先導(dǎo)(antecedent或left-hand-side, LHS)和后繼(consequent或 right-hand-side, RHS) 。

關(guān)聯(lián)規(guī)則在D中的支持度(support)是D中事務(wù)同時包含X、Y的百分比,即概率; =X^Y/D

置信度(confidence)是包含X的事務(wù)中同時又包含Y的百分比,即條件概率。  =(X^Y)/X

關(guān)聯(lián)規(guī)則是有趣的,如果滿足最小支持度閾值和最小置信度閾值。

若給定最小支持度α = n,最小置信度β = m,則分別通過以上的X^Y/D和(X^Y)/X,可獲知是否存在關(guān)聯(lián)


使用的原始數(shù)據(jù)


反范式后的數(shù)據(jù)


待統(tǒng)計項(xiàng)


--創(chuàng)建各個購買單元項(xiàng)視圖

create view distinct_trans as select distinct tranobject from purchase;

--創(chuàng)建各個事務(wù)內(nèi)部的購買單元項(xiàng)

create view all_trans as

--可以用wm_concat函數(shù)

SELECT tranid,MAX(tranobjects) tranobjects

  FROM (select tranid,WMSYS.WM_CONCAT(tranobject) OVER(PARTITION BY tranid ORDER BY tranobject) tranobjects

         from purchase

       )

group by tranid;

--也可以用sys_connect_by_path函數(shù)

create view all_trans as

select tranid,substr(tranobjects,2) tranobjects from  --格式化前面的逗號和空格

(

  select distinct tranid,FIRST_VALUE(tranobjects) OVER(PARTITION BY tranid ORDER BY levels desc ) AS tranobjects  --保留最大的那個

   from

   (

     select tranid,sys_connect_by_path(tranobject,',') tranobjects,level levels --各購買事務(wù)的內(nèi)部排列組合

       from purchase

    connect by tranid=prior tranid and tranobject

   )

);


--對所有購買單元項(xiàng)進(jìn)行排列組合,即數(shù)據(jù)挖掘的X^Y項(xiàng)

create view all_zuhe as

select substr(sys_connect_by_path(tranobject,','),2) zuhe

  from (select distinct tranobject from purchase)

connect by nocycle tranobject


select * from all_zuhe

--篩選出符合要求的排列組合,即數(shù)據(jù)挖掘的X項(xiàng)和Y項(xiàng)

create view full_zuhe as

select a.zuhe X,b.zuhe Y from all_zuhe a,all_zuhe b

where instr(a.zuhe,b.zuhe)=0 and instr(b.zuhe,a.zuhe)=0

 and not exists(select 1 from distinct_trans c

                 where instr(a.zuhe,c.tranobject)>0 and instr(b.zuhe,c.tranobject)>0)


select * from full_zuhe  


create or replace view tongji as

select xy,xy_total,x,x_total,y,y_total,transtotal from

(

  select y||','||x xy,

         (select count(*) from all_trans a where instr(a.tranobjects,c.x||','||c.y)>0 or instr(a.tranobjects,c.y||','||c.x)>0) xy_total, --包含xy的事務(wù)數(shù)

         y,

         (select count(*) from all_trans b where instr(b.tranobjects,c.y)>0) y_total, --包含y的事務(wù)數(shù)

         x,

         (select count(*) from all_trans b where instr(b.tranobjects,c.x)>0) x_total, --包含x的事務(wù)數(shù)

         d.transtotal  --總事務(wù)數(shù)

   from full_zuhe c,(select count(distinct tranid) transtotal from purchase) d

  order by xy_total desc,x_total desc

)

 

select * from tongji where xy_total>=3 and y_total>=3


數(shù)據(jù)分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個參數(shù)驗(yàn)證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時表示是新驗(yàn)證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計時完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }