创建专家系统,改善结论

时间:2017-05-10 22:29:15

标签: recommendation-engine clips expert-system jess

使用jess和java,我正在创建一个电影推荐专家系统,它依赖于用户的信息,如他/她的首选类型,他/她的年龄,以及他/她下载的电影,我在寻找添加更多信息来源(如主要演员和电影导演),以帮助我最终得到我的系统可以提出的四个最佳建议......

到目前为止,这是我的代码:

(deftemplate User 
(declare (from-class User)))

(deftemplate Movie 
    (declare (from-class Movie)))

(deftemplate Download 
    (declare (from-class Download)))

(deftemplate Recommendation 
    (declare (from-class Recommendation)))

(deftemplate similar
    (slot movieId1)
    (slot movieId2))

(defrule find-similar
    ?movie1<-(Movie (movieId ?id1)(movieGenre ?genre))
    ?movie2<-(Movie (movieId ?id2&:(<> ?id2 ?id1))(movieGenre ?genre))
    =>
    (assert (similar (movieId1 ?id1) (movieId2 ?id2))))

(defrule recommend-movie-based-on-user-genre
    "Recommends movies that has the same genre the user preffers."
    (User (userId ?userId) (prefferdGenre ?genre))
    (Movie (movieId ?movieId) (movieGenre ?genre))
    (not (Download (userId ?userId) (movieId ?movieId)))
    (not (Recommendation (userId ?userId) (movieId ?movieId)))
    =>
    (add (new Recommendation ?userId ?movieId)))

(defrule recommend-movie-based-on-downloads
    "Recommends movies similar to the ones the user has downloaded."
    (Download (userId ?userId) (movieId ?movieId))
    (similar (movieId1 ?movieId) (movieId2 ?movieId2))
    (not (Download (userId ?userId) (movieId ?movieId2)))
    (not (Recommendation (userId ?userId) (movieId ?movieId2)))
    =>
    (add (new Recommendation ?userId ?movieId2)))

我的问题是:我如何结合我的不同规则,使我的系统能够将从每个规则中学到的信息结合起来,并利用累积的知识提出“完美”的建议

1 个答案:

答案 0 :(得分:1)

首先,您必须了解基于经验数据的建议和基于特定方法的建议之间存在差异。

基于经验的推荐是“80%的人给电影X竖起大拇指”或“你喜欢电影Y和80%喜欢电影Y的人也喜欢电影X”或“平均来说,人们评价这部电影4颗星,最高分5英寸“。

特别推荐是你构成的。例如,根据5个指定标准中的4个匹配,您的程序会为电影提供80%的推荐值。

您没有在您的计划中使用经验数据,因此您可以根据自己的标准确定推荐的强度。谷歌搜索“推荐专家系统”或“电影推荐专家系统”将为您提供有关各种临时方法的一些想法。

这是CLIPS中用于组合推荐权重(从0到100)的临时方法:

CLIPS> (clear)
CLIPS> 
(deftemplate recommendation
   (slot movie)
   (slot weight)
   (multislot reasons))
CLIPS>    
(defrule combine-weights
  ?rec1 <- (recommendation (movie ?movie) 
                           (reasons $?reasons1) 
                           (weight ?w1))
  ?rec2 <- (recommendation (movie ?movie) 
                           (reasons $?reasons2&~$?reasons1) 
                           (weight ?w2&:(<= ?w2 ?w1)))
  =>
  (retract ?rec2)
  (modify ?rec1 (weight (/ (- (* 100 (+ ?w1 ?w2)) (* ?w1 ?w2)) 100))
                (reasons ?reasons1 ?reasons2)))
CLIPS>                 
(assert (recommendation (movie "Aliens") (weight 80) (reasons genre)))
<Fact-1>
CLIPS> 
(assert (recommendation (movie "Aliens") (weight 60) (reasons downloads)))
<Fact-2>
CLIPS> 
(agenda)
0      combine-weights: f-1,f-2
For a total of 1 activation.
CLIPS> (watch facts)
CLIPS> (run)
<== f-2     (recommendation (movie "Aliens") (weight 60) (reasons downloads))
<== f-1     (recommendation (movie "Aliens") (weight 80) (reasons genre))
==> f-3     (recommendation (movie "Aliens") (weight 92.0) (reasons genre downloads))
CLIPS>