【发布时间】:2017-08-17 14:16:47
【问题描述】:
在 h2o.randomForest 中,假设我有 5 个输入特征 x=c("A","B","C","D","E"),是否有强制算法始终选择A,B AND 其余特征之一?
【问题讨论】:
标签: random-forest h2o
在 h2o.randomForest 中,假设我有 5 个输入特征 x=c("A","B","C","D","E"),是否有强制算法始终选择A,B AND 其余特征之一?
【问题讨论】:
标签: random-forest h2o
在这种情况下,h2o.randomForest 只是要求您传递正确的 x(用于预测的列列表)和 y(用于预测的列名),因此您将传递的任何内容都将用作输入。
您要问的是一个特定于 python 的问题。你想如何传递你需要为它编写逻辑的列列表。您可以定义以下是一个函数并根据需要使用它。
import random
myframe = ["a","b","c","d","e"]
//You can also set myframe as column name list
//myframe.remove(_use_response_column_name) this will make it generic
selectedkeys = ["a","b"]
for item in selectedkeys:
if item in myframe:
myframe.remove(item)
selectedkeys.append(random.choice(myframe))
print(selectedkeys)
print(myframe)
您只需将选定的键作为 X 的输入传递。
【讨论】: