Catboost python特性重要性缺少1个必需的位置参数:';价值';
我试图计算python文件中的特性重要性。我通过Spark Submit运行这个python文件。因为我们的数据节点上没有安装catboost库,所以我用python手动加载它们 然后我加载模型文件并尝试计算特征重要性。在这里,我得到以下错误Catboost python特性重要性缺少1个必需的位置参数:';价值';,python,catboost,Python,Catboost,我试图计算python文件中的特性重要性。我通过Spark Submit运行这个python文件。因为我们的数据节点上没有安装catboost库,所以我用python手动加载它们 然后我加载模型文件并尝试计算特征重要性。在这里,我得到以下错误 abc = model.get_feature_importance(type=catBoost.EFstrType().FeatureImportance(), prettified=True, thread_count=-1, verbose=Fals
abc = model.get_feature_importance(type=catBoost.EFstrType().FeatureImportance(), prettified=True, thread_count=-1, verbose=False)
TypeError: __call__() missing 1 required positional argument: 'value'
请参阅下面我正在运行的代码
def getCatBoostLibraries():
files = os.listdir(os.getcwd())
with zipfile.ZipFile(os.path.abspath("catboost zip file path"), 'r') as zip_ref:
zip_ref.extractall(os.getcwd())
catboostFldrPath = os.path.abspath(os.path.join(os.getcwd(), "catboost"))
sys.path.append(catboostFldrPath)
configFile = os.path.abspath(os.path.join(catboostFldrPath, "__init__.py"))
spec = importlib.util.spec_from_file_location("catboost", configFile)
catBoost = importlib.util.module_from_spec(spec)
spec.loader.exec_module(catBoost)
return catBoost
def getFeatureImportance(modelPath):
catBoost = getCatBoostLibraries()
model = catBoost.CatBoostRegressor()
model.load_model(modelPath)
abc = model.get_feature_importance(type=catBoost.EFstrType().FeatureImportance(), prettified=True, thread_count=-1, verbose=False)
importance_score_df = pd.DataFrame(abc, columns=['features', 'featr_imp'])
return importance_score_df
在我拆下下面一行中的大括号后,它起作用了
abc = model.get_feature_importance(type=catBoost.EFstrType.FeatureImportance, prettified=True, thread_count=-1, verbose=False)