策略运行错误:Bin edges must be unique


(993210oo) #1

回测的时候没有报这个错误,实际运行的时候报错,可以怎么修改??

[2018-12-03 19:07:22.957328] INFO: bigquant: instruments.v2 开始运行..
[2018-12-03 19:07:23.038871] INFO: bigquant: 命中缓存
[2018-12-03 19:07:23.039835] INFO: bigquant: instruments.v2 运行完成[0.082559s].
[2018-12-03 19:07:23.053615] INFO: bigquant: advanced_auto_labeler.v2 开始运行..
[2018-12-03 19:07:23.345726] INFO: 自动数据标注: 加载历史数据: 3537 行
[2018-12-03 19:07:23.346811] INFO: 自动数据标注: 开始标注 ..
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-f57326d5c836> in <module>()
    111     benchmark='000300.SHA',
    112     drop_na_label=True,
--> 113     cast_label_int=True
    114 )
    115 

/var/app/enabled/biglearning/module2/common/modulemanagerv2.cpython-35m-x86_64-linux-gnu.so in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.__call__()

/var/app/enabled/biglearning/module2/common/moduleinvoker.cpython-35m-x86_64-linux-gnu.so in biglearning.module2.common.moduleinvoker.module_invoke()

/var/app/enabled/biglearning/module2/common/moduleinvoker.cpython-35m-x86_64-linux-gnu.so in biglearning.module2.common.moduleinvoker._invoke_with_cache()

/var/app/enabled/biglearning/module2/common/moduleinvoker.cpython-35m-x86_64-linux-gnu.so in biglearning.module2.common.moduleinvoker._invoke_with_cache()

/var/app/enabled/biglearning/module2/common/moduleinvoker.cpython-35m-x86_64-linux-gnu.so in biglearning.module2.common.moduleinvoker._module_run()

/var/app/enabled/biglearning/module2/modules/advanced_auto_labeler/v2/__init__.py in run(self)
    119 
    120         for expr in self.__label_expr:
--> 121             df['label'] = bigexpr.evaluate(df, expr, self.__user_functions)
    122 
    123         if self.__drop_na_label:

/var/app/enabled/bigexpr/impl/expression.cpython-35m-x86_64-linux-gnu.so in bigexpr.impl.expression.evaluate()

/var/app/enabled/bigexpr/impl/expression.cpython-35m-x86_64-linux-gnu.so in bigexpr.impl.expression.__evaluate_ast()

/var/app/enabled/bigexpr/impl/functions.cpython-35m-x86_64-linux-gnu.so in bigexpr.impl.functions.UserFunctions.all_wbins()

/usr/local/python3/lib/python3.5/site-packages/pandas/core/reshape/tile.py in cut(x, bins, right, labels, retbins, precision, include_lowest)
    134                               precision=precision,
    135                               include_lowest=include_lowest,
--> 136                               dtype=dtype)
    137 
    138     return _postprocess_for_cut(fac, bins, retbins, x_is_series,

/usr/local/python3/lib/python3.5/site-packages/pandas/core/reshape/tile.py in _bins_to_cuts(x, bins, right, labels, precision, include_lowest, dtype, duplicates)
    232             raise ValueError("Bin edges must be unique: {bins!r}.\nYou "
    233                              "can drop duplicate edges by setting "
--> 234                              "the 'duplicates' kwarg".format(bins=bins))
    235         else:
    236             bins = unique_bins

ValueError: Bin edges must be unique: array([-inf,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,
        nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  inf]).
You can drop duplicate edges by setting the 'duplicates' kwarg

(woshihaofeng) #5

是因为内部用了qcut() qcut 好像不允许边界出现重复值,所以返回nan


(iQuant) #7

此问题已经解决。

原因是在特定的数据上,给cut输入了有可能出现重复的边界值。已经解决。