创建专家系统,改进结论



使用 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 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 竖起大拇指"或"你喜欢电影 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> 

最新更新