0
我必須藉助一些使用剪輯中的TP,TN,FP,FN參數的規則來計算一般預測準確度。使用規則計算剪輯中的一般預測準確度
我的規則是x1 <=0.58 AND x6 <=0.61 x5
mcg<=0.61 --> Class = cp
。
我寫了代碼,但是當我嘗試運行它時,我遇到了錯誤消息。可能有一個我找不到的錯誤。 可以請任何人幫我嗎?
這是我的代碼:
(defrule rule1
(rw6 ?x6)
(rw5 ?x5)
(rw1 ?x1)
(test (<= ?x6 0.58))
(test (<= ?x5 0.61))
(test (<= ?x1 0.61))
?fact1 <- (TP1 ?TP1)
?fact2 <- (FP1 ?FP1)
?fact3 <- (TN2 ?TN2)
?fact4 <- (TN3 ?TN3)
?fact5 <- (TN4 ?TN4)
?fact6 <- (FN2 ?FN2)
?fact7 <- (FN3 ?FN3)
?fact8 <- (FN4 ?FN4)
?fact9 <- (K1 ?K1)
?fact10 <- (K2 ?K2)
?fact11 <- (K3 ?K3)
?fact12 <- (K4 ?K4)
?fact13 <- (row (rw1 ?x1)(rw2 ?x2)(rw3 ?x3)(rw4 ?x4)(rw5 ?x5)(rw6 ?x6)(rw7 ?x7)(class ?c))
=>
(if (= ?c cp) then
(retract ?fact1 ?fact3 ?fact4 ?fact5 ?fact9)
(assert (TP1 (+ ?TP1 1))(TN2 (+ ?TN2 1))(TN3 (+ ?TN3 1))(TN4 (+ ?TN4 1))(K1 (+ ?K1 1))))
else (if (= ?c im) then
(retract ?fact2 ?fact4 ?fact5 ?fact6 ?fact10)
(assert (FP1 (+ ?FP1 1))(TN3 (+ ?TN3 1))(TN4 (+ ?TN4 1))(FN2 (+ ?FN2 1))(K2 (+ ?K2 1))))
else (if (= ?c pp) then
(retract ?fact2 ?fact3 ?fact5 ?fact7 ?fact11)
(assert (FP1 (+ ?FP1 1))(TN2 (+ ?TN2 1))(TN4 (+ ?TN4 1))(FN3 (+ ?FN3 1))(K3 (+ ?K3 1))))
else (if (= ?c om) then
(retract ?fact2 ?fact3 ?fact4 ?fact8 ?fact12)
(assert (FP1 (+ ?FP1 1))(TN2 (+ ?TN2 1))(TN3 (+ ?TN3 1))(FN4 (+ ?FN4 1))(K4 (+ ?K4 1))))
(retract ?fact13))
(defrule rule2
(K1 ?K1)
(K2 ?K2)
(K3 ?K3)
(K4 ?K4)
(TP1 ?TP1)
(FP1 ?FP1)
(FN1 ?FN1)
(TP2 ?TP2)
(FP2 ?FP2)
(FN2 ?FN2)
(TP3 ?TP3)
(FP3 ?FP3)
(FN3 ?FN3)
(TP4 ?TP4)
(FP4 ?FP4)
(FN4 ?FN4)
?fact1 <- (REC1 0)
?fact2 <- (REC2 0)
?fact3 <- (REC3 0)
?fact4 <- (REC4 0)
?fact5 <- (PRE1 0)
?fact6 <- (PRE2 0)
?fact7 <- (PRE3 0)
?fact8 <- (PRE4 0)
?fact9 <- (FMES1 0)
?fact10 <- (FMES2 0)
?fact11 <- (FMES3 0)
?fact12 <- (FMES4 0)
?fact13 <- (waREC 0)
?fact14 <- (waPRE 0)
?fact15 <- (waFMES 0)
?fact13 <- (ACC 0)
=>
(retract ?fact1 ?fact2 ?fact3 ?fact4 ?fact5 ?fact6 ?fact7 ?fact8 ?fact9 ?fact10 ?fact11 ?fact12 ?fact13)
(assert (ACC (bind ?ACC (/ (+ ?TP1 ?TP2 ?TP3 ?TP4)(+ ?TP1 ?TP2 ?TP3 ?TP4 ?FN1 ?FN2 ?FN3 ?FN4)))))
(assert (REC1 (bind ?REC1 (/ ?TP1 (+ ?TP1 ?FN1)))))
(assert (REC2 (bind ?REC2 (/ ?TP2 (+ ?TP2 ?FN2)))))
(assert (REC3 (bind ?REC3 (/ ?TP3 (+ ?TP3 ?FN3)))))
(assert (REC4 (bind ?REC4 (/ ?TP4 (+ ?TP4 ?FN4)))))
(assert (PRE1 (bind ?PRE1 (/ ?TP1 (+ ?TP1 ?FP1)))))
(assert (PRE2 (bind ?PRE2 (/ ?TP2 (+ ?TP2 ?FP2)))))
(assert (PRE3 (bind ?PRE3 (/ ?TP3 (+ ?TP3 ?FP3)))))
(ass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K1 ?K2 ?K3 ?K4)) ?FMES3)(*(/ ?K4 (+ ?K1 ?K2 ?K3 ?K4)) ?REC4)))))
你能提供正在顯示的錯誤信息嗎? –
我得到的錯誤消息如下:定義defrule:rule1 [PRNTUTIL2]語法錯誤:檢查適當的defrule語法。 ERROR:????? (defrule MAIN ::規則1 (RW6 5233) (RW5 X5) (RW1 X1) (試驗(和(<= 5233 0.58)(<= X5 0.61)(< ?= X1 0.61))) fact1 < - ?(TP1 TP1) fact2 < - ?(FP1 FP1) fact3 < - ?(TN2 TN2) fact4 < - ????(TN3 TN3) fact5 < - (TN4?TN4) FALSE – kate