评估prolog中的规则



我想将以下决策规则转换为Prolog语言

------Decision Rules---------
if (Right-Weight <= 2.5) and (Left-Weight > 2.5) and (Left-Distance > 1.5) then class: R (proba: 95.4%) | based on 87 samples
if (Right-Weight > 2.5) and (Right-Distance <= 2.5) and (Left-Weight > 1.5) then class: R (proba: 71.08%) | based on 83 samples
if (Right-Weight <= 2.5) and (Left-Weight <= 2.5) and (Left-Distance > 2.5) then class: R (proba: 63.41%) | based on 41 samples
if (Right-Weight > 2.5) and (Right-Distance > 2.5) and (Left-Weight > 2.5) then class: L (proba: 63.54%) | based on 96 samples
if (Right-Weight > 2.5) and (Right-Distance > 2.5) and (Left-Weight <= 2.5) then class: L (proba: 98.48%) | based on 66 samples
if (Right-Weight > 2.5) and (Right-Distance <= 2.5) and (Left-Weight <= 1.5) then class: L (proba: 77.78%) | based on 27 samples
if (Right-Weight <= 2.5) and (Left-Weight <= 2.5) and (Left-Distance <= 2.5) then class: L (proba: 65.22%) | based on 23 samples
if (Right-Weight <= 2.5) and (Left-Weight > 2.5) and (Left-Distance <= 1.5) then class: L (proba: 50.0%) | based on 14 samples
-----------------------------

试图在序言中提出以下规则。

classR(Right-Weight, Left-Weight, Left-Distance) :- 
(Right-Weight <= 2.5) , (Left-Weight > 2.5) , (Left-Distance > 1.5);
(Right-Weight > 2.5) , (Right-Distance <= 2.5) , (Left-Weight > 1.5);
(Right-Weight <= 2.5) , (Left-Weight <= 2.5) , (Left-Distance > 2.5)

classL(Right-Weight, Left-Weight, Left-Distance) :-
(Right-Weight > 2.5) , (Right-Distance > 2.5) , (Left-Weight > 2.5);
(Right-Weight > 2.5) , (Right-Distance > 2.5) , (Left-Weight <= 2.5);
(Right-Weight > 2.5) , (Right-Distance <= 2.5) , (Left-Weight <= 1.5);
(Right-Weight <= 2.5) , (Left-Weight <= 2.5) , (Left-Distance <= 2.5);
(Right-Weight <= 2.5) , (Left-Weight > 2.5) , (Left-Distance <= 1.5)
evaluate(RW, LW, LD, RD, OP) :- 
((RW =< 2.5),(LW > 2.5),(LD > 1.5) -> OP = 'R';
(RW > 2.5) , (RD =< 2.5) , (LW > 1.5) -> OP = 'R';
(RW =< 2.5) , (LW =< 2.5) , (LD > 2.5) -> OP = 'R';
(RW > 2.5) , (RD > 2.5) , (LW > 2.5) -> OP = 'L';
(RW > 2.5) , (RD > 2.5) , (LW =< 2.5) -> OP = 'L';
(RW > 2.5) , (RD =< 2.5) , (LW =< 1.5) -> OP = 'L';
(RW =< 2.5) , (LW =< 2.5) , (LD =< 2.5) -> OP = 'L';
(RW =< 2.5) , (LW > 2.5) , (LD =< 1.5) -> OP = 'L').

最新更新