带机器学习的食品推荐工具
koolsla的Python项目详细描述
说明
koolsla(Coleslaw)是一个基于内容机器学习的推荐工具。 用tf-idf和Cosine Similarity的力量发展起来的。
用户给出一个自然数,对应于一个唯一的菜名的id。通过tf-idf对数据集中的424508种不同菜肴进行了分析和矢量化。 根据向量化输入的余弦相似性,选择一组菜(用户设置的数量)作为推荐菜。
库尔斯拉主要是一个教育项目。
安装
您可以使用:
$ pip install koolsla
获取代码
代码位于https://github.com/abdullahselek/koolsla
匿名查看最新的开发版本:
$ git clone git://github.com/abdullahselek/koolsla.git $ cd koolsla
要安装测试依赖项,请运行:
$ pip install -Ur requirements.testing.txt
运行测试
测试套件可以针对需要pip install pytest和可选的^{tt2}的单个python版本运行。$ (如果您安装了来自requirements.testing.txt的依赖项,则会包括这些依赖项)
要使用单个python版本运行单元测试,请执行以下操作:
$ py.test -v
还要运行代码覆盖率:
$ py.test --cov=koolsla
对一组python版本运行单元测试:
$ tox
示例用法
进口推荐人:
from koolsla import recommender
使用菜号和推荐数量获取推荐:
// Returns dictionary of tuples [(dish_id_1, similarity_ratio1), (dish_id_2, similarity_ratio2), (dish_id_3, similarity_ratio3)] recommendatons = recommender.recommend(82, 3)
cli
从https://github.com/abdullahselek/koolsla获取代码后,运行命令:
$ pip install -r requirements.txt
它已经可以使用了,有详细的帮助菜单,你可以遵循。最常用的推荐功能之一:
$ python koolsla.py -d 25 --recommend 3
对于“帮助”菜单:
$ python koolsla.py --help