nearest neighbor approaches: memory-based reasoning and collaborative 記憶基礎推理

69
Nearest Neighbor Appro aches: Memory-Based Reasoning and Collaborative 記記記記記記

Upload: taylor

Post on 05-Jan-2016

55 views

Category:

Documents


6 download

DESCRIPTION

Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理. 報告大綱. 一、前言 二、 C ase Study :到底誰才是鄰居? 三、記憶基礎推理如何運作 ? 四、如何增進 MBR 作業效能 ? 五、 Case Study :新聞報導分類 六、反查與準度的範例 七、距離的測量 八、結論. 一、前言. 前言.   人們總是藉著過去的經驗做判斷,例如 : 當你聽到說話不捲舌 , 你會覺得她是台灣人,為什麼? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

Nearest Neighbor Approaches:

Memory-Based Reasoning and Collaborative記憶基礎推理

Page 2: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

報告大綱•一、前言•二、 Case Study :到底誰才是鄰居?•三、記憶基礎推理如何運作 ? •四、如何增進 MBR 作業效能 ?•五、 Case Study :新聞報導分類•六、反查與準度的範例•七、距離的測量•八、結論

Page 3: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

一、前言

Page 4: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

前言  人們總是藉著過去的經驗做判斷,例如 : 1. 當你聽到說話不捲舌 ,你會覺得她是台灣

人,為什麼?2. 當醫生要診斷一個病人時,會依據過去的

經驗與眼前的症狀來做判斷及比對,為什麼?

Page 5: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

MBR (Memory-Based reasoning)

•以上的敘述都是 MBR 的原理,只不過是換成了由人工智慧進行比對。根據現有的資料庫,“記憶基礎推理”先找出新資料的“鄰近資料”( Neighbor ),然後根據鄰近資料,對新資料進行分析和預測。

Page 6: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

關鍵運用 (一 )• MBR 不在乎資料的格式•必備要項• (1). 距離函數 (Distance Function)  -負責判斷兩筆資料差異到底有多大• (2). 組合函數 (Combination Function)  -將若干相似資料的結果結合,以    產生答案。

Page 7: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

關鍵運用 (二 )• MBR 的相關應用例子

– (1). 詐欺案件的判斷– (2). 顧客回應預測– (3). 最佳醫療措施選擇– (4). 顧客反應分類 (顧客抱怨單 )

Page 8: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

MBR 優點•相較於其他 Data Mining 技術時, MBR 的簡易使用常讓人低估了他的強大能力 .

•只要定義出距離函數與組合函數, MBR 的可以分析任何形式的資料 -例如 :地理區位、影像、純文字等。

•它能同時將新資料和舊資料結合,同時能從舊資料中分析出新的分類項和定義。

Page 9: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

二、到底誰才是鄰居?

Page 10: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

到底誰是鄰居?• Tuxedo 與 New York的租金 一般人的概念,地理上鄰近的城市,也就是其鄰居,租金應該都差不了多少。

  但是妥善運用 MBR 後,我們將會重新認識並且定義什麼是“鄰居”。

MBR考慮的觀點較為客觀,而非單純是 地理上的相關,而是包含人口數、 房屋價值中位數…等。

Page 11: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

圖 8.1

Page 12: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

到底誰才是真正的鄰居?• 作法:(1).從散佈圖中找出最鄰近於目標的點 (2).整合目標資訊答案 :Shelter Island & North Salem 是 Tuxedo 的鄰居

Town Population Median Rent

Rent<$500(%)

Rent$500~$750

(%)

Rent$750~$1000

(%)

Rent$1000~$1500

(%)

Rent>$1500(%)

NORent(%)

ShelterIsland

2228 $804 3.1 34.6 31.4 10.7 3.1 17

North Salem

5173 $1150 3 10.2 21.6 30.9 24.2 10.2

Page 13: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

所以,租金是…

1. Average the most common rents of the two neighbors (use midpoint of the range)• (625+1250)/2,租金約是 $938

2. Or, pick the point midway between the two median rents:– (804+1150)/2, 租金約是 $977

Page 14: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

三、如何操作 MBR ?

Page 15: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

MBR操作• MBR 有兩個明顯的分析階段 : (1)學習階段 - 產生歷史資料庫 (2) 預測階段 - 將 MBR 運用在新資料上• 運用 MBR 的三項前置準備工作 : (1) 選擇適當的訓練資料集。 (2) 找出最具效率的方式表達歷史記錄 (3)設定距離函數、組合函數和鄰近資料集的數目

Page 16: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

選擇一個歷史記錄的平衡資料集

定義 :現有資料的子群組或是訓練資料集 (Training Set)限制 :訓練資料集必須能涵蓋大部分可能情況,如此新記錄的鄰近資料才能作為良好的預測基礎

作法 :建立訓練資料集時,不同類的資料記錄的數目應該要平衡。Tip: 選擇資料組時,除確保約略相等的樣本數之外,每類最好有數十筆。

Page 17: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

訓練資料的表示方法 ( 一 )

• MBR 在預測效率取決於訓練資料組如何表示。現今最常用的是關聯式資料庫。

• 需要比對每一筆資料和此筆紀錄的距離,然後才能產生出最接近的鄰近資料集。當訓練集資料集累積越多筆資料時,比對時間將急速上升。

• 在關聯式資料庫為一筆新紀錄找尋鄰近資料集,雖需要掃描整個資料庫,但還算不會耗時太久;可是如果同時為多筆新紀錄找尋他們的鄰近資料集時,需多次完整掃描整個資料庫,將會嚴重耗用電腦資源

• 解決之道 1:縮減訓練資料集,不使用整個資料庫,見圖 8.2

Page 18: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

訓練資料的表示方法 ( 二 )

• Distance( ) 運算是可以帶進任何特定的距離機制,這個運算需要掃描整個資料庫。

•此步驟非常耗時,因此,同時保存最相似的表格 (解決之道 2),視情況加入或刪除記錄,但是這些必須透過其他的程式語言,在 SQL 環境下無法執行。

SELECT distance ( ) ,rec. categoryFROM historical_records recORDER BY 1 ASCENDING;

Page 19: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

四、如何增進 MBR 作業效率 ?

Page 20: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

增進 MBR 作業效率•減少歷史資料庫的紀錄數量,“前提”:訓練資料組的大小可以大幅的影響記憶基礎裡作業效率。

•作法:找出含有不同分類項的群集,則各級群的中心可當成縮減的訓練資料集。

•條件:不同的分類項要離的夠遠,若有重疊或界線不明時,將使 MBR 產生誤差。

•找出“ Support Records” 。

Page 21: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理
Page 22: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

五、 Case Study :新聞報導分類

Page 23: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

新聞報導分類

•採用哪些關鍵字作為分類編碼 ? 政府機關、工業、商業、產品、地區、主題

“幾乎所有的新聞稿件都有地區和主題編碼,有時甚至有三個編碼”

Page 24: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

MBR 運用依照以下四個步驟改善新聞的分類編碼作業• 1. 選擇訓練資料集• 2.設定距離函數• 3.設定鄰近資料集數量• 4.設定組合函數

Page 25: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

選擇測試資料組•測試資料組包含了 49,652 件新聞。這些資料是三個月的新聞稿與 100個消息來源。每一則平均有 2700 字 (words) 和八個編碼。

• 1.沒有經過篩選,為反映真實散佈    2. 若能採用具有更多罕見編碼的 訓練資料組會更好

Page 26: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

設定距離函數•利用“相關回饋” (Relevance Feedback)的測試標準,由任何兩則新聞稿的文字內容比對他們的相似度。

•採用最相似的新聞稿當成 MBR所需要的鄰近資料

Page 27: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

利用相關回饋建立距離函數(一 )

• 相關回饋是一種能夠讓使用者在比對相似資料庫,用以進行精細分析的強大技術。

• 作法: 1.去除沒有附載有價值意義的單字 ex: it 、 of    2. 將前 20%最常出現的詞彙去除 3.剩下的字最轉存到一個可搜尋術語 的字庫中,每個字給予加權值 (-log2fi) 4.複合語詞的納入 ex: United States 、 New York

5.計算兩篇報導之間的相關回饋分數 score(A,B) 為 A與 B各自的字的權值的加總

Page 28: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

利用相關回饋建立距離函數(二 )

•相關回饋是利用現有函數的修正用來取代真正的距離函數。

•公式:

•利用上面的公式將相關回饋分析轉換成一般的距離公式。

Page 29: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

設定組合函數 (一 )• 組合函數採用加權總值技術 (Weighted Summation Technique) :每一筆鄰近資料都有一個距離倒數成正比的權值,所以越相近的資料組就有越高的加權值。

• 表 8.3 為未分類新聞找出相似者相似者 距離 權重 編碼

1 0.076 0.924 R/FE,R/CA,R/CO

2 0.346 0.654 R/FE,R/JA,R/CA

3 0.369 0.631 R/FE,R/JA,R/MI

4 0.393 0.607 R/FE,R/JA,R/CA

Page 30: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

設定組合函數 (二 )• 表 8.4 為未分類新聞評分CODE 1 2 3 4 SCORE

R/CA 0.924 0.654 0 0.607 2.185

R/CO 0.924 0 0 0 0.924

R/FE 0.924 0.654 0.631 0.607 2.816

R/JA 0 0.654 0.631 0.607 1.892

R/MI 0 0 0.631 0 0.631

若將門檻值設為 1 ,則此篇文章可以指派的 code為 R/CA, R/FE, and R/JA

Page 31: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

設定鄰近資料集數量•此案例嘗試使用 1~11 個鄰近資料集數目,發現使用越多鄰近資料集數目,結果越好

•此例 ,因每則新聞會得到的分類項不只一個。

•較典型的問題是配置在單一編碼或分類項,此情況則較少的鄰近資料集數目,反而較好。

Page 32: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

結果 (一 )•為了測試 MBR 在編碼上的有效程度,我們將 200 則由人工 (專家 ) 及 MBR編碼的新聞稿混合結果,交由一群編輯進行複審,只有過半數同意才能被當成“合格”。

•結果:人工編碼正確的數目比上“合格”編碼數目為 88%(recall, 回想 );然而,人工編碼正確的數目比上人工編碼全部為 83%(precision, 精確 ) ,即不正確比例為17%。

Page 33: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

圖 8.4利用人工作業及 MBR 將新聞進行分類的比較

Page 34: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

結果 (二 )• MBR表現並不好 : 由 MBR 分配編碼的 recall 為80% ;而 precision僅為 72%。

•問題與原因: Q: 為什麼 MBR表現不好 ? A:因為資料數不足,無法讓 MBR 使用全由 資深編輯分類的訓練組資料 可能是因為原資料處理者的專業程度不足 結論: MBR 比其他技術能夠處理困難的問題。

Page 35: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

六、回想與準度

Page 36: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

回想與準度• 回想 (RECALL)   記憶基礎推理究竟提供了多少個正確碼。假如MBR所提供的編碼包含了每ㄧ個正確的編碼,其反查值就是 100% ,假如提供的編碼中沒有一個正確的,回想值就是 0%

• 準度 (PRECISION)  在記憶基礎推理所提供的編碼中,有多少是正確的?準度 100代表著預測的編碼百發百中,若是提供的沒一個正確,那準度就是 0

Page 37: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

回想與準度的範例 -表 8.5CODES BY

MBRCORRECT

CODESRECALL PRECISIO

N

A,B,C,D A,B,C,D 100% 100%

A,B A,B,C,D 50% 100%

A,B,C,D,E,F,G,H,

A,B,C,D 100% 50%

E,F A,B,C,D 0% 0%

A,B,E,F A,B,C,D 50% 50%

Page 38: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

利用編碼類別測量回想與準度

個人編輯對新聞編碼,回想 83%準度 88%記憶基礎推理,回想 80%準度 72%

CATEGORY RECALL PRECISION

Government 85% 87%

Industry 91% 85%

Market Sector 93% 91%

Product 69% 89%

Region 86% 64%

Subject 72% 53%

Page 39: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

七、測量距離

Page 40: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

測量距離•假設你要到一個小鎮旅行,而你想知道那裡的天氣狀況如何,但是卻沒有管道獲得資訊,因為天氣預報都只報導大城市。如果你在當地沒有朋友,則通常的作法就是查詢附近大城市的天氣狀況,就以那個城市的天氣當成判斷標準,或者綜合附近三個大城市的天氣狀況。以上所描繪的正是利用記憶基礎推理找出天氣狀況的例子,而這裡的距離函數是兩個地點的距離。

Page 41: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

距離函數的特性(一)• 妥適定義 (Well-defined) :

– 兩點之間的距離永遠是可以找出來的,且大於零• 同位 (Identity) :

– 從一點到它本身的距離一定是0• 交換性 (Commutatively) :

– 距離沒有方向性,所以A到B的距離就是B到A的距離

• 三角不等式 (Triangle Inequality)– A 與 C的距離小於或等於 A與 B的距離加 B 與 C的距離

Page 42: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

距離函數的特性(二)•妥適定義確保每ㄧ筆資料都一定有鄰近資料的存在,記憶基礎推理便是需要這些鄰近資料才能進行分析

•同位確保每ㄧ筆資料最相似的資料就是它本身

•交換性和三角不等式則將鄰近資料限定在特定區域中,增加一筆新的資料進資料庫,不會改變現有資料間的距離

Page 43: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

資料差異性-圖 8.5

•B的最鄰近資料是A,但A卻有與多筆比B還近的鄰近資料

Page 44: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

一次建立一個單變數的距離函數

•以幾何學的角度,距離很容易推理,但問題是,我們如何為多變數且不同資料型態的資料建立距離函數?答案是:ㄧ次建立單一變數的距離函數,再組合起來。

Page 45: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

表 8.7• 行銷資料庫中的五個顧客資料

RECNUM GENDER AGE SALARY

1 Female 27 $19,000

2 male 51 $64,000

3 male 52 $105,000

4 Female 33 $55,000

5 male 45 $45,000

Page 46: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

圖 8.6

三維分佈圖中展示五筆紀錄的分佈

Page 47: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

距離矩陣• 表 8.8 顧客年齡變數的距離矩陣

27 51 52 33 45

27 0.00 0.96 1.00 0.24 0.72

51 0.96 0.00 0.04 0.72 0.24

52 1.00 0.04 0.00 0.76 0.28

33 0.24 0.72 0.76 0.00 0.48

45 0.72 0.24 0.28 0.48 0.00

Page 48: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

常見的距離加總方式•加總:

– dsum (A,B)=dgender (A,B)+dage(A,B)+dsalary(A,B)

•標準化加總 (Normalized Summation) :– dnorm (A,B)= dsum (A,B)/ max (dsum )

•歐幾里得距離:– dEuclid (A,B)=sqrt ( dgender (A,B)2+dage (A,B)2+dsalary (A,B)2)

Page 49: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

表 8.9• 三種距離函數的最近似者組合

• 此案例中,三種方式的結果完全ㄧ樣是個巧合

D sum D norm D euclid

1 1,4,5,2,3 1,4,5,2,3 1,4,5,2,3

2 2,5,3,4,1 2,5,3,4,1 2,5,3,4,1

3 3,2,5,4,1 3,2,5,4,1 3,2,5,4,1

4 4,1,5,2,3 4,1,5,2,3 4,1,5,2,3

5 5,2,3,4,1 5,2,3,4,1 5,2,3,4,1

Page 50: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

加入新的資料• 表 8.10 新顧客

RECNUM GENDER AGE SALARY

new female 45 $100,000

Page 51: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

表 8.11• 新顧客最近似者組合

1 2 3 4 5 NEIGHBORS

D sum 1.662 1.659 1.338 1.003 1.640 4,3,5,2,1

D norm 0.554 0.553 0.446 0.334 0.547 4,3,5,2,1

D euclid 0.781 1.052 1.251 0.494 1.000 4,1,5,2,3

Page 52: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

其他資料形式的距離函數

•郵遞區號•電話號碼•產品編號

Page 53: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

常見的組合函數

•民主方式 (democracy)•加權投票

Page 54: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

民主方式 (democracy)

•記憶基礎推理可使用的組合函數就是讓最近似的K個鄰近資料投票選出答案

•為了避免同票的情況,K必須是奇數,當類別數為C時,鄰近資料應該要有 c+1 個

Page 55: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

民主方式案例• 表 8.12 顧客流失紀錄

RECNUM GENDER AGE SALARY INACTIVE

1 Female 27 $19,000 No

2 male 51 $$64,000 Yes

3 male 52 $105,000 Yes

4 Female 33 $55,000 Yes

5 male 45 $45,000 No

new female 45 $100,000 ?

Page 56: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

民主方式案例• 表 8.13 使用 MBR 判斷新顧客是否會流失

NEIGHBORS NEIGHBORATTRITION

K=1 K=2 K=3 K=4 K=5

d sum 4,3,5,2,1 Y,Y,N,Y,N yes yes yes yes yes

d euclid 4,1,5,2,3 Y,N,N,Y,Y yes ? No ? yes

K=1 K=2 K=3 K=4 K=5

d sum Yes,100% Yes,100% Yes,67% Yes,75% Yes,60%

d euclid Yes,1005 yes,50% No,67% Yes,50% Yes,60%

• 表 8.14 流失預測的信心水準

Page 57: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

加權投票•加權投票 ( 類似股東民主 ) 和民主方式類似,不同之處在於每一票的加權值和他與新資料的距離成反比 (距離加 1的倒數 )

•加權對於結果和信心水準會有影響,主要的作用還是在消除鄰近資料為複數的情況下,無法判斷的結果 (得票數相同 ) 。

•至於使用或不使用加權,可透過使用測試資料集比較何者有較好的表現,再來決定

•例,見表 8.15與 8.16

Page 58: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

Collaborative Filtering: A Nearest Neighbor Approach to Making

Recommendations

Page 59: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

合作篩選 合作篩選共有三個步驟 ( 為一個新顧客提供建議 ) :

• 建立新顧客的 Profile ,即令新顧客對某些品項( 例如電影、音樂、餐廳等 ) 的偏好進行評分。 

• 使用相似性或距離的測量,比較新顧客與其它就顧客的 profiles ,找出偏好最接近的幾個顧客 ( 鄰近資料集 )

• 利用某種 combination function計算新顧客對某項尚未評分的品項的評分預測值

•  

Page 60: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

合作篩選案例

•圖 8.7

( 1/2(-1) + 1/4 (-4) )/( 1/2 + 1/4 ) = -1.5/0.75 = -2

Page 61: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

• A good collaborative filtering system gives its users a chance to comment on the predictions and adjust the profile accordingly.

• If it turns that the customer really like the item and gives it a rating of 4, his new profile will be in slightly different neighborhood and original neighbors’ opinions will count less for this new customer’s next recommendation.

Page 62: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

八、結論

Page 63: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

獲得最佳結果MBR 是一個很有效的 Data Mining 技術,它可以應用在許多的直接 Data Mining問題上。

1.選擇正確訓練資料集 (1)足夠的資料數量 (2) 增加某些罕見分類項的資料數量 (3)約略相等的資料數量2.距離函數 (1)加總法:較具有緩衝效果 (2)歐幾里得:注重每一個變數都必須維持在較小 

   的差值

Page 64: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

獲得最佳結果 (二 )3 . 鄰近資料數量 (1).需要由“分布狀況”和“面對的問     題”決定 (2). 鄰近資料的數量必須比分類項至少 多”1”4 . 基本函數組合 加權投票對於類別變數有效,但在連續數值時,建議可以結合迴歸分析和最似鄰近資料模式,計算出最適線後,進行推測。

Page 65: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

MBR 優點•結論容易推測 MBR 能列出最似鄰近資料的特性,方便我們看出結果是如何產生

•運用在任何資料型態、甚至是非關聯式資料上

只依靠兩種機制:距離函數與組合函數

•任何數量的變數下都能運作良好  MBR 的效能主要是受訓練組資料的數量多寡決定,將較之下原始 資料變數多寡,並不會有太大影響

•訓練資料集容易建立  當有新分類項產生時,可直接加入訓練資料組中

Page 66: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

MBR缺點

•在分類和預測上運算作業繁複 需要一一運用距離含數計算出每一筆新資料和每一筆訓練資料組紀錄之間的差異

•訓練資料組需要大量紀錄  MBR 的訓練資料組就是模式,而資料數量越大越好,且必須要有 一定的樣本數目

•高度依賴距離函數和組合函數 結果取決於距離函數和組合函數及鄰近資料數。

Page 67: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

何時應用 MBR ?

• MBR 是一種對分類和預測都有效的直接式資料採礦技術,和其他技術比較起來,更能針對特定情形進行分析。

1.整體規律性不能提供良好解釋時 2. 資料非常複雜時

Page 68: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

SAS EM

• An assumption for the Memory-Based Reasoning node is that the variables that have status of use are numeric, orthogonal to each other, and standardized. You can use the Princomp/Dmneural or the Singular Value Decomposition nodes to generate numeric, orthogonal, and standardized variables that can be used as inputs for the Memory-Based Reasoning node.

Page 69: Nearest Neighbor Approaches: Memory-Based Reasoning and Collaborative 記憶基礎推理

• In Enterprise Miner, the k-nearest neighbors are determined by the Euclidean distance between an observation and the probe. Based on the target values of the k-nearest neighbors, each of the k-nearest neighbors votes on the target value for a probe. The votes are the posterior probabilities for the binary or nominal target variable.

• The following display shows the voting approach of these neighbors for a binary target variable when different values of k are specified.

• In this example, observations 7, 12, 35, 108, and 334 are the five closest observations to the probe, where observations 108 and 35 have the shortest and the longest distances to the probe, respectively.

• The k-nearest neighbors are first k observations that have the closest distances to the probe. If the value of k is set to 3, then the target values of the first three nearest neighbors (108, 12, and 7) are used. The target values for these three neighbors are Y, N, and Y. Therefore, the posterior probability for the probe to have the target value Y is 2/3 (67%).