2013-10-30 45 views
1

我在python中使用redisbayes library来实现朴素贝叶斯分类。但是,当我写 -在python中建立redis连接

rb = redisbayes.RedisBayes(redis=redis.Redis()) 
rb.train('good', 'sunshine drugs love sex lobster sloth') 

它提供了以下错误 -

ConnectionError: Error 10061 connecting localhost:6379. 
No connection could be made because the target machine actively refused it. 

我试图做这种方式 -

pool = redis.ConnectionPool(host='localhost', port=6379, db=0) 
rb = redisbayes.RedisBayes(redis=redis.Redis(connection_pool=pool)) 

但它给了同样的错误。我无法找到解决方案。我如何建立一个使用Python的redis连接,或者这种任何其他方式来使用MySQL的训练数据在Python中做朴素贝叶斯分类?

+0

'r = redis.StrictRedis(host = YOUR_HOST,port = 6379,db = YOUR_DB)'一直对我很好。你只需要'import redis' – fedorqui

回答

4

你确实意识到你需要让本地运行的Redis服务器能够连接到它,请在你的进程列表中查看redis-server,如果它不存在,并且你没有注册服务,你可能需要安装它。看看redis homepage的安装说明

+0

我已经使用'easy_install redis'在python中安装了redis。但我如何确保redis服务器正在运行 – shubhi1910

+0

这不是redis。 这就是客户端库 –

+0

行..我从https://github.com/rgl/redis/downloads得到它.. 感谢您的回答:) – shubhi1910