由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DataSciences版 - random forest 有没有可能保证某几个变量一直被选上
相关主题
data science 面试求教[Data Science Project Case] Parsing URLS
凑热闹转发一篇自己写的博文,轻拍DS需要会的手艺 真不少
在R里merge两个dataframe太慢了借版面问个machine learning的问题
求助 信息提取 (转载)求职要求clearance
用R做review 的summary[Data Science Project Case] Topic Learning
问一道(大)数据 algorithm (转载)Data scientist / Machine Learning Engineer 相关面试题 (转载)
R问题请教一个面试题(predictive model) (转载)
求助:关于2个python的题目请教大家一个做feature的问题
相关话题的讨论汇总
话题: label话题: features话题: test话题: tree话题: df
进入DataSciences版参与讨论
1 (共1页)
f*****y
发帖数: 822
1
google了一下,没有发现类似的问题。不知道R或者python的package可不可以做?或者
有什么简单的方法可以达到目的?
请教各位大牛。。。。。
g*****o
发帖数: 812
2
正常的想法难道不是应该把需要一直出现的和随机出现的分开, 然后只抽随机那部分么

【在 f*****y 的大作中提到】
: google了一下,没有发现类似的问题。不知道R或者python的package可不可以做?或者
: 有什么简单的方法可以达到目的?
: 请教各位大牛。。。。。

f*****y
发帖数: 822
3
不好意思,没明白你的意思,一直出现的是什么?RF有什么variable是会一直出现的吗?

【在 g*****o 的大作中提到】
: 正常的想法难道不是应该把需要一直出现的和随机出现的分开, 然后只抽随机那部分么
w**2
发帖数: 147
4
为什么要保证变量一直被选上呢?
rf的variable sets at each split就是越randomized,越好。这个每个树都不会太相
似,这样,model的variance就降低了。
大牛可以来解答一下嘛?
p****m
发帖数: 19
5
我觉着他这几个变量可能在business 上有一定的关系。如果implementation 的话,也
许可以在package里改sampling 时的weight, 让这几个的weight 变大,但这样做,有
什么drawback 就不知道了
f*****y
发帖数: 822
6
是的。有些重要的variable一定要被选上才行。但是这个难道要改package,从来没
有试过。

【在 p****m 的大作中提到】
: 我觉着他这几个变量可能在business 上有一定的关系。如果implementation 的话,也
: 许可以在package里改sampling 时的weight, 让这几个的weight 变大,但这样做,有
: 什么drawback 就不知道了

g*****o
发帖数: 812
7
我的意思是, 你把一定要选上的, 和随机挑选的分开, 只在随机挑选的里面抽, 最后加
上一定要选上的不就行了么

【在 f*****y 的大作中提到】
: 是的。有些重要的variable一定要被选上才行。但是这个难道要改package,从来没
: 有试过。

f*****y
发帖数: 822
8
你说的是这个道理。问题是给的package里面貌似没有可以直接做的。

【在 g*****o 的大作中提到】
: 我的意思是, 你把一定要选上的, 和随机挑选的分开, 只在随机挑选的里面抽, 最后加
: 上一定要选上的不就行了么

g*****o
发帖数: 812
9
难道哪些需要, 哪些不需要, 你不能手动挑出来或者用条件选择么?... 然后就分别放
到两个数组啊...

【在 f*****y 的大作中提到】
: 你说的是这个道理。问题是给的package里面貌似没有可以直接做的。
f*****y
发帖数: 822
10
请问放两个数组之后怎么办,是要自己造轮子写RandomForest的算法吗?已有的
package是个黑箱子,没提供这样的选择。

【在 g*****o 的大作中提到】
: 难道哪些需要, 哪些不需要, 你不能手动挑出来或者用条件选择么?... 然后就分别放
: 到两个数组啊...

相关主题
问一道(大)数据 algorithm (转载)[Data Science Project Case] Parsing URLS
R问题请教DS需要会的手艺 真不少
求助:关于2个python的题目借版面问个machine learning的问题
进入DataSciences版参与讨论
l*******m
发帖数: 1096
11
you could duplicate some features you prefer to see if it could lift score.

【在 f*****y 的大作中提到】
: 请问放两个数组之后怎么办,是要自己造轮子写RandomForest的算法吗?已有的
: package是个黑箱子,没提供这样的选择。

f*****y
发帖数: 822
12
This is for sure a great idea, Thanks!!

【在 l*******m 的大作中提到】
: you could duplicate some features you prefer to see if it could lift score.
Z**0
发帖数: 1119
13
如果这些变量一直选上,不是违背RF的初衷了,这些都是理论上的说法。不过你可以试
试LS的方法,把你需要的features,复制多份,看看结果有什么变化。
l*******s
发帖数: 1258
14
考虑弄个两层的classifier:先用你那几个重要variables跑一遍,第二步再用random
forest。
至于两步如何合并,可以有多种办法,比如一部分data在第一步里分类效果很显著,
score>0.999,另一部分score较低的,放到第二步。有点像boosting
还可以把第一步和第二步的score加起来,用总的score做分类。至于如何加起来,如何
调整weight,具体问题具体分析了。
t*****e
发帖数: 364
15
这个自己写一下应该不难吧:
1. boostrap 100-200 datasets from your training set
2. For each of the bootstrapped data, randomly select some features from
those features that are NOT in the important feature list (the number
selected could be a tuning parameter, usually random forest recommend p/3
for regression tree and sqrt(p) for classification tree).
3. Combine features obtained in step2 with the important several features
4. fit a decision tree using rpart (without pruning) and predict your test
set (either from independent test set or the OOB samples from training set).
5. Averaging the results from all the 100-200 bootstrapped results.

【在 f*****y 的大作中提到】
: google了一下,没有发现类似的问题。不知道R或者python的package可不可以做?或者
: 有什么简单的方法可以达到目的?
: 请教各位大牛。。。。。

t*****e
发帖数: 364
16
sorry I mean using the package tree, rpart seems to be only for regression
tree
below is some sample code, 写的太仓促难免有bug, 不过你可以大概看一下logic
require(tree)
A_train = matrix(rnorm(20000),nc=20)
Label = rnorm(nrow(A_train))
df_train = data.frame(A_train,Label)
A_test = matrix(rnorm(20000),nc=20)
Label_test = rnorm(nrow(A_test))
df_test = data.frame(A_test,Label)
Prob_all = NULL
for (k in 1:100) {
index = sample(1:length(Label),length(Label),replace = T)
indF = sample(NonSelected,floor(length(NonSelected)/3))
Features = c(Selected,indF)
df_tmp = data.frame(Label,A_train[,Features])
df_tmp_test = data.frame(Label = Label_test,A_test[,Features])
model = tree(Label~.,data = df_tmp)
results = predict(model,newdata = df_tmp_test) # if it's classification,
add type = "prob"
Prob_all = cbind(Prob_all,results)
}

).

【在 t*****e 的大作中提到】
: 这个自己写一下应该不难吧:
: 1. boostrap 100-200 datasets from your training set
: 2. For each of the bootstrapped data, randomly select some features from
: those features that are NOT in the important feature list (the number
: selected could be a tuning parameter, usually random forest recommend p/3
: for regression tree and sqrt(p) for classification tree).
: 3. Combine features obtained in step2 with the important several features
: 4. fit a decision tree using rpart (without pruning) and predict your test
: set (either from independent test set or the OOB samples from training set).
: 5. Averaging the results from all the 100-200 bootstrapped results.

f*****y
发帖数: 822
17
多谢大牛指点。

).

【在 t*****e 的大作中提到】
: 这个自己写一下应该不难吧:
: 1. boostrap 100-200 datasets from your training set
: 2. For each of the bootstrapped data, randomly select some features from
: those features that are NOT in the important feature list (the number
: selected could be a tuning parameter, usually random forest recommend p/3
: for regression tree and sqrt(p) for classification tree).
: 3. Combine features obtained in step2 with the important several features
: 4. fit a decision tree using rpart (without pruning) and predict your test
: set (either from independent test set or the OOB samples from training set).
: 5. Averaging the results from all the 100-200 bootstrapped results.

f*****y
发帖数: 822
18
google了一下,没有发现类似的问题。不知道R或者python的package可不可以做?或者
有什么简单的方法可以达到目的?
请教各位大牛。。。。。
g*****o
发帖数: 812
19
正常的想法难道不是应该把需要一直出现的和随机出现的分开, 然后只抽随机那部分么

【在 f*****y 的大作中提到】
: google了一下,没有发现类似的问题。不知道R或者python的package可不可以做?或者
: 有什么简单的方法可以达到目的?
: 请教各位大牛。。。。。

f*****y
发帖数: 822
20
不好意思,没明白你的意思,一直出现的是什么?RF有什么variable是会一直出现的吗?

【在 g*****o 的大作中提到】
: 正常的想法难道不是应该把需要一直出现的和随机出现的分开, 然后只抽随机那部分么
相关主题
求职要求clearance一个面试题(predictive model) (转载)
[Data Science Project Case] Topic Learning请教大家一个做feature的问题
Data scientist / Machine Learning Engineer 相关面试题 (转载)Data scientist / Machine Learning Engineer 相关面试题 (转载)
进入DataSciences版参与讨论
w**2
发帖数: 147
21
为什么要保证变量一直被选上呢?
rf的variable sets at each split就是越randomized,越好。这个每个树都不会太相
似,这样,model的variance就降低了。
大牛可以来解答一下嘛?
p****m
发帖数: 19
22
我觉着他这几个变量可能在business 上有一定的关系。如果implementation 的话,也
许可以在package里改sampling 时的weight, 让这几个的weight 变大,但这样做,有
什么drawback 就不知道了
f*****y
发帖数: 822
23
是的。有些重要的variable一定要被选上才行。但是这个难道要改package,从来没
有试过。

【在 p****m 的大作中提到】
: 我觉着他这几个变量可能在business 上有一定的关系。如果implementation 的话,也
: 许可以在package里改sampling 时的weight, 让这几个的weight 变大,但这样做,有
: 什么drawback 就不知道了

g*****o
发帖数: 812
24
我的意思是, 你把一定要选上的, 和随机挑选的分开, 只在随机挑选的里面抽, 最后加
上一定要选上的不就行了么

【在 f*****y 的大作中提到】
: 是的。有些重要的variable一定要被选上才行。但是这个难道要改package,从来没
: 有试过。

f*****y
发帖数: 822
25
你说的是这个道理。问题是给的package里面貌似没有可以直接做的。

【在 g*****o 的大作中提到】
: 我的意思是, 你把一定要选上的, 和随机挑选的分开, 只在随机挑选的里面抽, 最后加
: 上一定要选上的不就行了么

g*****o
发帖数: 812
26
难道哪些需要, 哪些不需要, 你不能手动挑出来或者用条件选择么?... 然后就分别放
到两个数组啊...

【在 f*****y 的大作中提到】
: 你说的是这个道理。问题是给的package里面貌似没有可以直接做的。
f*****y
发帖数: 822
27
请问放两个数组之后怎么办,是要自己造轮子写RandomForest的算法吗?已有的
package是个黑箱子,没提供这样的选择。

【在 g*****o 的大作中提到】
: 难道哪些需要, 哪些不需要, 你不能手动挑出来或者用条件选择么?... 然后就分别放
: 到两个数组啊...

l*******m
发帖数: 1096
28
you could duplicate some features you prefer to see if it could lift score.

【在 f*****y 的大作中提到】
: 请问放两个数组之后怎么办,是要自己造轮子写RandomForest的算法吗?已有的
: package是个黑箱子,没提供这样的选择。

f*****y
发帖数: 822
29
This is for sure a great idea, Thanks!!

【在 l*******m 的大作中提到】
: you could duplicate some features you prefer to see if it could lift score.
Z**0
发帖数: 1119
30
如果这些变量一直选上,不是违背RF的初衷了,这些都是理论上的说法。不过你可以试
试LS的方法,把你需要的features,复制多份,看看结果有什么变化。
相关主题
NY Lead Data Scientist, Finance Credit凑热闹转发一篇自己写的博文,轻拍
有没有做sentiment analysis的,求思路 (转载)在R里merge两个dataframe太慢了
data science 面试求教求助 信息提取 (转载)
进入DataSciences版参与讨论
l*******s
发帖数: 1258
31
考虑弄个两层的classifier:先用你那几个重要variables跑一遍,第二步再用random
forest。
至于两步如何合并,可以有多种办法,比如一部分data在第一步里分类效果很显著,
score>0.999,另一部分score较低的,放到第二步。有点像boosting
还可以把第一步和第二步的score加起来,用总的score做分类。至于如何加起来,如何
调整weight,具体问题具体分析了。
t*****e
发帖数: 364
32
这个自己写一下应该不难吧:
1. boostrap 100-200 datasets from your training set
2. For each of the bootstrapped data, randomly select some features from
those features that are NOT in the important feature list (the number
selected could be a tuning parameter, usually random forest recommend p/3
for regression tree and sqrt(p) for classification tree).
3. Combine features obtained in step2 with the important several features
4. fit a decision tree using rpart (without pruning) and predict your test
set (either from independent test set or the OOB samples from training set).
5. Averaging the results from all the 100-200 bootstrapped results.

【在 f*****y 的大作中提到】
: google了一下,没有发现类似的问题。不知道R或者python的package可不可以做?或者
: 有什么简单的方法可以达到目的?
: 请教各位大牛。。。。。

t*****e
发帖数: 364
33
sorry I mean using the package tree, rpart seems to be only for regression
tree
below is some sample code, 写的太仓促难免有bug, 不过你可以大概看一下logic
require(tree)
A_train = matrix(rnorm(20000),nc=20)
Label = rnorm(nrow(A_train))
df_train = data.frame(A_train,Label)
A_test = matrix(rnorm(20000),nc=20)
Label_test = rnorm(nrow(A_test))
df_test = data.frame(A_test,Label)
Prob_all = NULL
for (k in 1:100) {
index = sample(1:length(Label),length(Label),replace = T)
indF = sample(NonSelected,floor(length(NonSelected)/3))
Features = c(Selected,indF)
df_tmp = data.frame(Label,A_train[,Features])
df_tmp_test = data.frame(Label = Label_test,A_test[,Features])
model = tree(Label~.,data = df_tmp)
results = predict(model,newdata = df_tmp_test) # if it's classification,
add type = "prob"
Prob_all = cbind(Prob_all,results)
}

).

【在 t*****e 的大作中提到】
: 这个自己写一下应该不难吧:
: 1. boostrap 100-200 datasets from your training set
: 2. For each of the bootstrapped data, randomly select some features from
: those features that are NOT in the important feature list (the number
: selected could be a tuning parameter, usually random forest recommend p/3
: for regression tree and sqrt(p) for classification tree).
: 3. Combine features obtained in step2 with the important several features
: 4. fit a decision tree using rpart (without pruning) and predict your test
: set (either from independent test set or the OOB samples from training set).
: 5. Averaging the results from all the 100-200 bootstrapped results.

f*****y
发帖数: 822
34
多谢大牛指点。

).

【在 t*****e 的大作中提到】
: 这个自己写一下应该不难吧:
: 1. boostrap 100-200 datasets from your training set
: 2. For each of the bootstrapped data, randomly select some features from
: those features that are NOT in the important feature list (the number
: selected could be a tuning parameter, usually random forest recommend p/3
: for regression tree and sqrt(p) for classification tree).
: 3. Combine features obtained in step2 with the important several features
: 4. fit a decision tree using rpart (without pruning) and predict your test
: set (either from independent test set or the OOB samples from training set).
: 5. Averaging the results from all the 100-200 bootstrapped results.

w******l
发帖数: 34
35
但是你这个也不能保证那些重要的feature被选上啊,
每个小tree可能不选你那些个重要变量。。

).

【在 t*****e 的大作中提到】
: 这个自己写一下应该不难吧:
: 1. boostrap 100-200 datasets from your training set
: 2. For each of the bootstrapped data, randomly select some features from
: those features that are NOT in the important feature list (the number
: selected could be a tuning parameter, usually random forest recommend p/3
: for regression tree and sqrt(p) for classification tree).
: 3. Combine features obtained in step2 with the important several features
: 4. fit a decision tree using rpart (without pruning) and predict your test
: set (either from independent test set or the OOB samples from training set).
: 5. Averaging the results from all the 100-200 bootstrapped results.

t*****e
发帖数: 364
36
没懂。那些重要变量已经被force in to the model,and there is no pruning for
each tree for random forest. 请指教。

【在 w******l 的大作中提到】
: 但是你这个也不能保证那些重要的feature被选上啊,
: 每个小tree可能不选你那些个重要变量。。
:
: ).

1 (共1页)
进入DataSciences版参与讨论
相关主题
请教大家一个做feature的问题用R做review 的summary
Data scientist / Machine Learning Engineer 相关面试题 (转载)问一道(大)数据 algorithm (转载)
NY Lead Data Scientist, Finance CreditR问题请教
有没有做sentiment analysis的,求思路 (转载)求助:关于2个python的题目
data science 面试求教[Data Science Project Case] Parsing URLS
凑热闹转发一篇自己写的博文,轻拍DS需要会的手艺 真不少
在R里merge两个dataframe太慢了借版面问个machine learning的问题
求助 信息提取 (转载)求职要求clearance
相关话题的讨论汇总
话题: label话题: features话题: test话题: tree话题: df