创建专家系统,改进结论

Creating an expert system, improving conclusions

将 jess 与 java 结合使用,我正在创建一个电影推荐专家系统,它依赖于有关用户的信息,例如 his/her 首选类型、his/her 年龄和电影he/she 已下载,我希望添加更多信息源(例如电影的主要演员和导演)以帮助我最终得出我的系统可以提出的四个最佳建议...

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

(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 prefers."
    (User (userId ?userId) (preferredGenre ?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)))

我的问题是:如何组合我的不同规则,使我的系统能够组合从每个单独规则中学到的信息,并使用积累的知识提出“完美”推荐

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

基于经验的推荐是“80% 的人对电影 X 竖起大拇指”或 "You liked movie Y and 80% of people who liked movie Y also liked movie X" 或 "on average, people rated this movie 4 out of 5 stars"。

临时推荐是您编造的。例如,根据匹配的 5 个指定条件中的 4 个,您的程序为电影提供 80% 的推荐。

您没有在程序中使用经验数据,因此您可以根据自己的标准确定推荐的强度。在 "recommendation expert systems" 或 "movie recommendation expert systems" 上进行 google 搜索会给您一些关于各种临时方法的想法。

这是 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>