scope.int 不一致地返回 int 值
作者: Mathu-lmn创建于 2024年12月9日更新于 2026年7月24日
你好,我在使用 hyperopt 时遇到一个问题,scope.int 函数返回的不是 int,而是 float: sklearn.utils._param_validation.InvalidParameterError: RandomForestClassifier 的 'min_samples_leaf' 参数必须是 [1, inf) 范围内的 int 或 (0.0, 1.0) 范围内的 float。但我得到的是 2.0。以下是使用 hyperopt 但无法运行的 Python 代码: Python 'min_samples_leaf': scope.int(hp.quniform('min_samples_leaf', 1, 20, 1)) 也许我被 "scope.int" 这个名称误导了,但我认为它应该返回 2 而不是 2.0。
内容来源: hyperopt/hyperopt