Chapter 7
Case-based Reasoning
( 案例式推論 )
案例式推論解決問題的流程
:
1.
確認問題的狀態
2.
由過去案例中找尋相似的案例
3.
由相似的案例獲取經驗以解決目前的問題
4.
將目前的問題及解決的方法加入案例中
案例特徵
( 參數 ) 之訂定
案例特徵
( 參數 ) 權重之訂定
案例特徵
( 參數 ) 比對演算法之訂定
案例建制
案例調整
案例擷取
查詢模式
調整參數
新案例
重複案例
需求
結果
案例知識庫
查詢
適合的
案例
使用者
案例式推論運作流程
案例式推論實例
:
自動化郵件回覆客戶服務系統
以郵件進行客戶服務己成趨勢
現有的郵件客服有下列缺點
郵件回覆為人工進行
需要浪費人力回答重覆問題
無法保證即時回覆
目標
:
將傳統郵件回覆自動化
縮短客戶等待時間
提高客戶的滿意度
節省客服中心的人力應用
自動化郵件客服系統功能
自動辨識郵件目的及問題
搜尋最適合客戶的解決方案
即時產生回覆郵件
調查客戶滿意度
從雙方面調整資料庫
使用者
Server
問題分析
機制
詞庫
Q&A 資
料庫
解答機制
客服人員
介面
Q&A 儲存
機制
網
際
網
路
自動化郵件客服系統
架構
客服系統權重演算法
權重調整:
一名詞在所有集合中出現的頻率愈多,代表
此詞為一冗詞
一名詞在所屬集合中出現的頻率愈多,其他
集合中出現的頻率愈少,即有可能就是關鍵
詞
客服系統權重演算法
(cont.)
W
ij
=(
p
ij
–
n
ij
)/N
w
ij
關鍵字
i 對在文章 j 的權重
N
取樣總篇數
p
ij
關鍵字
i 在文章 j 出現的次數
n
ij
關鍵字
i 在文章 j 之外出現的次數
客服系統關鍵詞比對演算法
FAQ 關鍵詞比對:
比對客戶詢問問題與資料庫中的資料相似程
度
給予一個問題與資料庫中各筆資料介於
0 至
1 的分數,並找出分數最高的資料
Neural Networks ( 類神經網
路
)
1943 McCulloch 與 Pitts 首度提出正式的類神經計算單元。
1949 Donald Hebb 提出第一個學習法則 ---Hebbian learning rule 。
1954 Minsky 首度建造類神經電腦並測試。
1958 Frank Rosenblatt 發明感知機 (Perceptron)﹐ 可調整連接值。
1960 Bernard Widrow 與 Marcian Hoff 提出 Widrow-Hoff 學習法則
1965 Nils Nilsson 綜合當代研究並提出學習機所受的限制。
1972 Sun-Ichi Amari 提出有關臨界值的數學理論。
1982 Kohonen 研究非監督模式網路﹐建立陣列式神經元。
1982 Stephen Grossberg 與 Gail Carpenter 研究調適性迴響網路。
Advantages
prediction accuracy is generally high
robust, works when training examples contain errors
output may be discrete, real-valued, or a vector of
several discrete or real-valued attributes
fast evaluation of the learned target function
Criticism
long training time
difficult to understand the learned function (weights)
not easy to incorporate domain knowledge
A Neuron
The
n
-dimensional input vector
x
is mapped into variable
y
by
means of the scalar product and a nonlinear function mapping
k
-f
weighted
sum
Input
vector x
output y
Activation
function
weight
vector w
w
0w
1w
nx
0x
1x
nTraining a Neural Network
To obtain a set of weights that makes almost all
the tuples in the training data classified correctly
Steps
Initialize weights with random values
Feed the input tuples into the network one by one
For each unit
Compute the net input to the unit as a linear combination of
all the inputs to the unit
Compute the output value using the activation function
Compute the error
Back-Propagation Neural Network
( 倒傳遞類神經網路 )
1 2 3 n-1 nx
x
x
x
x
Output Layer
Hidden Layer
Input Layer
1 2 3 m-1 my
y
y
y
y
1W
V
11 11z
V
q qn mqW
z
n(
)
f
(
q)
f
(
)
1
範例-圖形辨識
A
010010101
Output Layer
Hidden Layer
Input Layer
1 2 3 m-1 my
y
y
y
y
1W
V
11 11z
V
q qn mqW
z
A
001011101
B
>0 >0 <0倒傳遞類神經網路
演算法
Step 1: 以最小化能量函數的結果為目標,計算訓練資料輸入向量與目標輸出向
量之間的平均平方差(
Mean square error )。
Step 2: 以下列公式調整修正權重值:
其中 且
為學習率(
Learning ra
te )。
Step 3: 以類似的方式調整修正門檻值。
Step 4: 重複 Step 1 到 Step 3 ,計算所有的訓練資料輸入向量。
Step 5: 利用測試資料測試以上訓練的網路,假如收斂,則停止;否則跳到 Step
ij ij ijW
W
W
2 1(
(
)
(
))
2
1
( ) ( )
im i i Xd
X
y
X
E
t t ij ijW
E
W
Genetic Algorithm( 基因演算法 )
源自於 John Holland 在 1975 年出版的著作 Ad
aptation in Nature and Artificial Systems
仿效自然界生物進化過程
透過基因的選擇 (selection) 交換 (crossover) 及
突變 (mutation) 產生更好的下一代
選擇 (selection) 過程
較高合適值 (fitness value) 就有較大機會獲得保留
較低合適值的解答,可能會遭到淘汰
較不易陷入 local optimal
Population ( 族體 ):
Encoding ( 編碼 ):
Crossover ( 交配 ):
Mutation ( 突變 ):
Selection ( 適者生存 ):
Fitness Function ( 適合度公式 ):
Genetic Algorithm( 基因演算法 )
基因演算法交配運算
基因演算法突變運算
Crossover randomly selects one-cut-point and
exchanges the right parts of two parents to
generate offspring.
Mutation alters one or more genes with a
probability equal to the mutation rate.
多目標最佳化配題機制
從大量試題中,選取符合出題方向和條件的試
題,進行配置,組成最佳鑑別度試卷
指定測驗時間範圍的試題配置問題模型
(Dedicated Range of Assessment Time Problem-DRAT)
符合期望測驗時間最高界限和最低界限的多目標配
題機制。
固定題數的試題配置問題模型
(Fixed Number of Test Items Problem – FNTI)
指定測驗時間範圍的試題配置問題 (D
RAT)
DRAT 目標函式:
Maximize Z =
DRAT 限制式:
X
i= 0 or 1, i = 1, 2, …, n
n i i n i i ix
x
d
1 1
n i 1r
ijx
ih
j,
j
1
,
2
,
,
m
;
n i 1t
ix
il
;
n i 1t
ix
iu
;
DRAT 的試題配置基因演算法 (1
/5)
概念程度下限先決基因演算法
(Concept Lower-bound First Genetic approach – CLFG)
CLFG 的進行步驟
1. 建立母體 (Encoding)
X 為染色體,包含有 n 個基因
X = [x
1, x
2, …, x
n]
= w
dtu ipt_u
dtu =
DRAT 的試題配置基因演算法 (2/
5)
2. 適配等級 (Fitness ranking)
R = dc
ipt
dc =
= w
dtl ipt_l
w = (
ind
ix
i) / average(u, l)
dtl =
適配函數 v(S
k) =
m j n ir
ijx
ih
j 1(
1)
n i i ix
t
l
1
n i 1t
ix
iu
n i n i ix
x
d
R
DRAT 的試題配置基因演算法 (3
/5)
3. 物競天擇 (Selection)
計算各染色體的適配值
v(S
k) , k = 1,2, … , pop_size + offspring_size
加總所有染色體
S
k的適配值和選取機率
P
k= v(S
k) / V
計算各染色體 S
k的累積選取機率
pop size offspring size k ks
v
V
_ _ 1(
)
kq
DRAT 的試題配置基因演算法 (4
/5)
4. 交配 (Crossover)
A[1110011001] A’[1110011
011
]
B[0100100011]
B’[0100100
001
]
Procedure: crossover
Begin
k = 0
while (k ≤ c / 2) do
flag = 0
while flag = 0 do
Generate random numbers R
1and R
2from discrete interval
[1,K].
If R
1≠ R
2then flag=1
end while
DRAT 的試題配置基因演算法 (5/
5)
5. 突變 (Mutation)
A[11100110
0
1] A’[11100110
1
1]
P = ( 1 / n )
Procedure: mutation
Begin
for(i=1, i ≤ nk, i++){
Generate random number y
ifrom discrete interval [0, 1].
Mutation function(P,
y
i) }
End
固定題數的試題配置問題 (FNTI)
FNTI 目標函式:
Maximize Z =
FNTI 限制式:
x
1≥ 1
x
i+1> x
i ,1 ≤ i ≤ q_num – 1
num q id
xi _ 1
num q ir
xijh
j
m
_ 1,
1
,
2
,...,
FNTI 的試題配置基因演算法 (1/
5)
試題數目先決基因演算法
(Feasible Item First Genetic approach – FIFG)
FIFG 的進行步驟
1. 建立母體
X 為染色體,包含有 q_num 個基因
X = [x
1, x
2, …, x
q_num]
X = [25, 118, …., 803]
基因值代表著一題試題的編號
FNTI 的試題配置基因演算法 (2/5)
2. 適配等級 (Fitness ranking)
R = dc
ipt
dc =
適配函數 v(S
k) =
m j n i xh
r
ij 1(
1)
n i 1d
xiR
FNTI 的試題配置基因演算法 (3/5)
3. 物競天擇 (Selection)
計算各染色體的適配值
v(S
k) , k = 1,2, … , pop_size + offspring_size
加總所有染色體
S
k的適配值和選取機率
P
k= v(S
k) / V
計算各染色體 S
k的累積選取機率
pop size offspring size k ks
v
V
_ _ 1(
)
kq
FNTI 的試題配置基因演算法 (4/5)
4. 交配 (Crossover)
A[12,15, 96,112,193,243] A’[12,15,96
,185,256,356
]
B[3,56,108,185,256,356] B’[3,56,108
,112,193,243
]
有兩相同基因值時,隨機更換其中一值,直到沒
有相同基因值為止
試卷中不可有二題相同的試題
Cut point
FNTI 的試題配置基因演算法 (5/
5)
5. 突變 (Mutation)
A[
3,8,56,66,
256
,515
] A’[
3,8,56,66,
346
,515
]
P = ( 1 / n )
Procedure: mutation
Begin
for (m = 1, m ≤ q_num k, m++){
Generate random number r
mfrom discrete interval [0, 1]
Generate random number RC from discrete interval [1, n]
mutation function(P, r
m, RC) }
試題參數調整演算法
鑑別度
難度
)
(
X
maxX
minN
S
S
D
H L
)
(
2
)
2
(
min max minX
X
N
X
N
S
S
P
H L
實驗題庫樣本資料