2024-09-28 20:49:44 发布
网友
有没有什么方法可以识别用来构造RandomForest{Classifier, Regressor}对象中每棵树的样本?在
RandomForest{Classifier, Regressor}
我要找的是保持.inbag“在这个R实现中:http://math.furman.edu/~dcs/courses/math47/R/library/randomForest/html/randomForest.html
回答我自己的问题(在scikit学习邮件列表上的@amueller的帮助下-谢谢!),这是一个计算袋内矩阵的函数:
from sklearn.ensemble.forest import _generate_sample_indices def calc_inbag(n_samples, forest): n_trees = forest.n_estimators inbag = np.zeros((n_samples, n_trees)) for t_idx in range(n_trees): sample_idx = _generate_sample_indices(forest.estimators_[t_idx].random_state, n_samples) inbag[:, t_idx] = np.bincount(sample_idx, minlength=n_samples) return inbag
回答我自己的问题(在scikit学习邮件列表上的@amueller的帮助下-谢谢!),这是一个计算袋内矩阵的函数:
相关问题 更多 >
编程相关推荐