acone2003
2018-12-03 16:04:37 +08:00
各位有点新进展,我把函数添加了一项,然后使用 xgboost 就没有问题。是不是 lightGBM 要依赖一些别的模块? parallel Python 要求把必要的引用显式地写在代码中。添加后的相关代码如下:
def CreateModel( ModelName, Params ):
max_depth, num_leaves, min_child_weight = 10, 20, 1
if "max_depth" in Params: max_depth = Params[ "max_depth" ]
if "num_leaves" in Params: num_leaves = Params[ "num_leaves" ]
if "min_child_weight" in Params: min_child_weight = Params[ "min_child_weight" ]
Model, IsClassifier = None, True
ModelName = ModelName.lower()
if ModelName == "lgbmregressor":
IsClassifier = False
Model = lightgbm.LGBMRegressor( max_depth=max_depth, num_leaves=num_leaves )
elif ModelName == "xgbregressor":
IsClassifier = False;
Model = xgboost.XGBRegressor( n_jobs=16, max_depth=max_depth, min_child_weight=min_child_weight )
return Model, IsClassifier