使用其他笔记本电脑的功能时出现键错误40

时间:2019-06-20 13:37:46

标签: python jupyter-notebook

我正在木星笔记本中使用随机森林来预测某些东西。我在同一工作目录中有一个单独的笔记本,在其中指定了功能。我可以使用功能笔记本中的所有功能(例如数据转换功能),但是不能使用sklearn中包含RandomForestClassifier的特定功能。 (输入键错误:40)

我使用:

import import_ipynb

导入功能

在笔记本的开头,导入功能笔记本,然后使用functions.function_name调用功能。

我已经尝试过重新启动内核并重新加载功能。

在笔记本电脑中调用该功能

clf = functions.random_forest_classifier(X_train, y_train, n_estimators      = 30, max_depth = 40)

这是功能笔记本中的功能

def random_forest_classifier(X_train, y_train, n_estimators,  max_depth):

clf = RandomForestClassifier(n_estimators, max_depth)
clf.fit(X_train, y_train)

return clf

我在做什么错了?

1 个答案:

答案 0 :(得分:0)

我查找了签名:RandomForestClassifier(n_estimators=’warn’, criterion=’gini’, max_depth=None, ...)

您的代码RandomForestClassifier(n_estimators, max_depth)应该为RandomForestClassifier(n_estimators, max_depth=max_depth)

相关问题