当前位置:   article > 正文

rasa_nlu_chi 测试不成功 “error“: “y should be a 1d array, got an array of shape (1, 5) instead.

y should be a 1d array, got an array of shape (1, 5) instead.

rasa_nlu_chi原始git链接:
https://github.com/crownpku/rasa_nlu_chi

rasa_nlu_chi实现博客链接

实现过程中有问题解决方法的博客:
https://ptorch.com/news/243.html

大牛写的rasa-UI链接:
https://github.com/paschmann/rasa-ui
UI安装教程:
https://blog.csdn.net/u011244708/article/details/82924823?spm=1001.2014.3001.5501
UI与nlu_chi整合问题:
https://ask.csdn.net/questions/3370686

问题贴:
https://github.com/crownpku/Rasa_NLU_Chi/issues


训练Rasa NLU的模型

python -m rasa_nlu.train -c sample_configs/config_jieba_mitie_sklearn.yml --data data/examples/rasa/demo-rasa_zh.json --path models
  • 1

启动rasa_nlu的后台服务:

python -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml --path models
  • 1

打开一个新的terminal,我们现在就可以使用curl命令获取结果了, 尝试下面命令均不成功:

curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "project": "rasa_nlu_test", "model": "models\default\model_20210617-142700"}' | python -mjson.tool
  • 1
curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "project": "", "model": "models\default\model_20210617-142700"}' | python -mjson.tool
  • 1
curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "model": "models\default\model_20210617-142700"}' | python -mjson.tool
  • 1
curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?"}' | python -mjson.tool
  • 1

curl -XPOST localhost:5000/parse -d ‘{“q”:“我发烧了该吃什么药?”, “model”: “models\default\model_20210617-111551”}’ | python -mjson.tool

E:\1rasa\code\Rasa_NLU_Chi\Rasa_NLU_Chi-master\models\default\model_20210617-111551

测试命令始终报错
在这里插入图片描述
更换测试方式:
打开浏览器,地址中输入

http://localhost:5000/parse?q=你好
  • 1

报错:
在这里插入图片描述

尝试scikit-learn降级:
https://github.com/RasaHQ/rasa/issues/1436

报错:

rasa 2.5.0 requires networkx<2.6,>=2.4, but you have networkx 2.1 which is incompatible.
rasa 2.5.0 requires packaging<21.0,>=20.0, but you have packaging 17.1 which is incompatible.
rasa 2.5.0 requires pykwalify<1.9,>=1.7, but you have pykwalify 1.6.0 which is incompatible.
rasa 2.5.0 requires scikit-learn<0.25,>=0.22, but
  • 1
  • 2
  • 3
  • 4

重新装这四个的最小匹配版本

rasa-nlu 0.14.4

rasa 2.5.0 requires cloudpickle<1.7,>=1.2, but you have cloudpickle 0.6.1 which is incompatible.
rasa 2.5.0 requires jsonschema<3.3,>=3.2, but you have jsonschema 2.6.0 which is incompatible.
rasa 2.5.0 requires matplotlib<3.4,>=3.1, but you have matplotlib 2.2.5 which is incompatible.
rasa 2.5.0 requires packaging<21.0,>=20.0, but you have packaging 18.0 which is incompatible.
rasa 2.5.0 requires ruamel.yaml<0.17.0,>=0.16.5, but you have ruamel-yaml 0.15.100 which is incompatible.
rasa 2.5.0 requires scikit-learn<0.25,>=0.22,

问题贴:按照教程发送请求后,返回"error": “y should be a 1d array, got an array of shape (1, 5) instead.”

实测成功!!热泪!!

找到sklearn_intent_classifier.py
C:\Users\Administrator\Desktop\Rasa_NLU_Chi\rasa_nlu\classifiers\sklearn_intent_classifier.py
return self.le.inverse_transform(y) 修改为 return
self.le.inverse_transform(np.squeeze(y))

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

问题:curl测试仍然不成功
尝试方法1

可以参考train.py ,def create_argument_parser():
parser.add_argument(’–project’, python -m rasa_nlu.train -c
sample_configs/config_jieba_mitie_sklearn.yml --data
data/examples/rasa/demo-rasa_zh.json --path rasa_nlu_test --project
rasa_nlu_test

不成功,待续……

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/343624
推荐阅读
相关标签
  

闽ICP备14008679号