在python中建立redis连接

shu*_*910 1 python bayesian redis

我在python中使用redisbayes库来实现朴素的贝叶斯分类.但是当我写作 -

rb = redisbayes.RedisBayes(redis=redis.Redis())
rb.train('good', 'sunshine drugs love sex lobster sloth')
Run Code Online (Sandbox Code Playgroud)

它给出以下错误 -

ConnectionError: Error 10061 connecting localhost:6379. 
No connection could be made because the target machine actively refused it.
Run Code Online (Sandbox Code Playgroud)

我试过这样做 -

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

但它给出了同样的错误.我无法找到解决方案.如何使用python建立与redis的连接,或者使用MySQL的训练数据以任何其他方式在python中进行naive bayes分类?

Jak*_*yer 5

您确实意识到您需要在本地运行Redis服务器以便能够连接到它,查看您的进程列表中redis-server是否存在并且您没有可能需要安装它的注册服务.请查看redis主页上的安装说明