随机森林

本文深入探讨了如何运用随机森林进行分类和回归任务。通过随机选择特征和样本,构建多个决策树并综合其预测结果,随机森林展现出了强大的预测能力和解释性。无论是在分类问题上还是回归问题中,它都是一种高效且准确的机器学习算法。
摘要由CSDN通过智能技术生成

利用随机森林进行分类:

% Since TreeBagger uses randomness we will get different results each 
% time we run this.
% This makes sure we get the same results every time we run the code.
%rng default
 
% Here we create some training data.
% The rows< represent the samples or individuals.
% The first two columns represent the individual's features.
% The last column represents the class label (what we want to predict)
trainData = [ ...
    [6,  300,  1];
    [3,  300,  0];
    [8,  300,  1];
    [11, 2000, 0];
    [3,  100,  0];
    [6,  1000, 0];
    ];
 
features = trainData(:,(1:2))
classLabels = trainData(:,3)
 
% How many trees do you want in the forest? 
nTrees = 20;
 
% Train the TreeBagger (Decision Forest).
B = TreeBagger(nTrees,features,classLabels, 'Method', 'classification');
 
% Given a new individual WITH the features and WITHOUT the class label,
% what should the class 
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值