从文档中运行
的rasa_core示例› python3 -m rasa_core.run -d models/dialogue -u models/nlu/default/current
并在对话框中的每个消息后获取此错误输出:
.../sklearn/...: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
这是Numpy的问题,它已修复但未在最新版本中发布:https://github.com/scikit-learn/scikit-learn/scikit-learn/issues/10449
在- 添加
-W ignore
python3 -W ignore -m rasa_core.run -d models/dialogue -u models/nlu/default/current
-
warnings.simplefilter
python3
>>> warnings.simplefilter('ignore', DeprecationWarning)
>>> exit()
python3 -m rasa_core.run -d models/dialogue -u models/nlu/default/current
此警告是由numpy引起的,numpy弃用了真实价值检查空数组
此更改的理由是
不可能利用空数组是错误的事实,因为由于其他原因,数组可能是错误的。
检查以下示例:
>>> import numpy as np
>>> bool(np.array([]))
False
>>> # but this is not a good way to test for emptiness, because...
>>> bool(np.array([0]))
False
解决方案
根据Scikit-Learn库上的第10449期,这已固定在库的主分支中。但是,这将在2018年8月左右可用,因此一种可能的替代方法是使用较小版本的numpy库,该库没有此问题。写这个答案的时间(
sudo pip install numpy==1.13.3
或使用PIP3如下
sudo pip3 install numpy==1.13.3
忽略警告(S(
如果我们想使用最新版本的库(在这种情况下为numpy(,该图书馆发出了折旧警告,只想让弃用警告保持沉默,那么我们可以通过使用Python警告模块的FilterWarnings方法来实现它
以下示例下面将产生上述问题中提到的弃用警告:
from sklearn import preprocessing
if __name__ == '__main__':
le = preprocessing.LabelEncoder()
le.fit([1, 2, 2, 6])
le.transform([1, 1, 2, 6])
le.inverse_transform([0, 0, 1, 2])
产生
/usr/local/lib/python2.7/dist-packages/sklearn/preprocessing/label.py.py:151:extrecationWarning:空数组的真实价值模棱两可。返回false,但是将来这将导致错误。使用
array.size > 0
检查数组不是空的。
要照顾好它,添加过滤器危害折磨warning
from sklearn import preprocessing
import warnings
if __name__ == '__main__':
warnings.filterwarnings(action='ignore', category=DeprecationWarning)
le = preprocessing.LabelEncoder()
le.fit([1, 2, 2, 6])
le.transform([1, 1, 2, 6])
le.inverse_transform([0, 0, 1, 2])
如果有多个模块发出警告,我们想选择性地警告,然后使用模块属性。例如从Scikit学习模块的默默折旧警告
warnings.filterwarnings(module='sklearn*', action='ignore', category=DeprecationWarning)
我也有同样的问题。以下解决方案对我有用。转到警告中提到的路径文件和行号,即如果您使用anaconda,请转到anaconda ency2 py2 lib lib site-packages sklearn sklearn preprocessing label.py line.py line编号:151。
>更改以下代码
if diff:
raise ValueError("y contains new labels: %s" % str(diff))
到以下
if diff.size>0:
raise ValueError("y contains new labels: %s" % str(diff))