ALEPH (SWI-Prolog) 中的 WARMR 算法

WARMR algorithm in ALEPH (SWI-Prolog)

我正在尝试使用 WARMR 在我的数据中查找频繁的关系模式;为此,我在 SWI-Prolog 中使用 ALEPH。然而,我正在努力弄清楚如何做到这一点以及为什么我之前的尝试没有奏效。

我想在继续处理我的完整数据之前制作一个玩具示例。为此,我从 aleph 包页面获取了玩具 "train" 数据: http://www.swi-prolog.org/pack/list?p=aleph

Aleph 手册中关于 ar 搜索的说明:

ar 实现 WARMR 系统进行的关联规则搜索类型的简化形式(参见 L. Dehaspe,1998,博士论文,Katholieke Universitaet Leuven)。在这里,Aleph 简单地找到至少涵盖一个 预先指定的正例部分。该分数由参数 pos_fraction.

指定

因此我插入了

:- set(search,ar).
:- set(pos_fraction,0.01). 

进入后台文件(并删除:- set(i,2).))并擦除负例的.n文件。我还注释掉了所有的决定和 modeh 声明逻辑,因为我们正在搜索频繁的模式,而不是规则(即在监督上下文中,头部将是一个 "output" 变量和主体中的子句 - - "inputs" 试图解释输出),即这是一项无人监督的任务。

现在,原始 trains 数据集正在尝试为 "eastbound" 列车构建规则。这是通过使用 carshapehas_car(train, car) 等谓词来完成的。最初与这些相关的所有背景知识都位于 .b 文件和五个正例(例如 eastbound(east1).) 在 .f 文件中(+ 五个反例,例如 eastbound(west1).,在 .n 文件中)。保持文件不变(保存上述更改)和 运行 induce. 不会产生合理的结果(它将 return 像 train(east1) 这样的基础术语作为 "rule", 例如)。我曾尝试将一些背景知识移动到 .f 文件中,但这也没有产生任何有意义的结果。

我该如何构建 .f 和 .b 文件?如果我们不是真的想解释任何正例(肯定会构成监督问题)而是要在数据中找到频繁模式(无监督问题),那么应该将什么放入正例文件?我错过了什么吗?

如有任何帮助,我们将不胜感激。

首先如果能用原版的WARMR我觉得还是比较好。但我认为你需要成为一名学者才能免费使用。您可以尝试申请许可证。 https://dtai.cs.kuleuven.be/ACE/

为了得到关联规则,我把所有我想要的例子都放在了f文件中。 n 文件中可以包含示例,或者我认为它是空的。

我唯一改变的是:

 :- set(search,ar).
 :- set(pos_fraction,0.01).  

在.b 文件中。保留确定和模式声明。

set(i,2) 将查询的长度限制为有两个额外的文字(我认为),因此您可能希望它更大。

?-read_all(train). induce.

然后您将得到一个 'good clauses' 的答案,我认为这是常见的查询。

[good clauses] eastbound(A). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), long(B). [pos cover = 2 neg cover = 0] [pos-neg] [2] eastbound(A) :- has_car(A,B), open_car(B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), shape(B,rectangle). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), wheels(B,2). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), load(B,rectangle,3). [pos cover = 1 neg cover = 0] [pos-neg] [1] eastbound(A) :- has_car(A,B), has_car(A,C). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), has_car(A,C). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), has_car(A,C). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), short(B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), closed(B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), shape(B,rectangle). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), wheels(B,2). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), load(B,triangle,1). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), has_car(A,C). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), has_car(A,C). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), long(B). [pos cover = 2 neg cover = 0] [pos-neg] [2] eastbound(A) :- has_car(A,B), open_car(B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), shape(B,rectangle). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), wheels(B,3). [pos cover = 3 neg cover = 0] [pos-neg] [3] eastbound(A) :- has_car(A,B), load(B,hexagon,1). [pos cover = 1 neg cover = 0] [pos-neg] [1] eastbound(A) :- has_car(A,B), has_car(A,C). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), short(B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), open_car(B). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), shape(B,rectangle). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), wheels(B,2). [pos cover = 5 neg cover = 0] [pos-neg] [5] eastbound(A) :- has_car(A,B), load(B,circle,1). [pos cover = 3 neg cover = 0] [pos-neg] [3] eastbound(A) :- has_car(A,B), open_car(B), shape(B,rectangle). [pos cover = 4 neg cover = 0] [pos-neg] [4]

等等等等

规则的格式为 eastbound(A):-blah blah。但它只计算东行的例子。所以把它想象成 example_covered(A):-blah blah