randomforest

所属分类matlab例程
开发工具:matlab
文件大小:423KB
下载次数:8
上传日期:2019-06-26 20:52:30
上 传 者皮皮达人
说明:  data=[]; a = randperm( ); %填写总数据数量 Train = data(a(1:20),:); %取1到20行为训练集 Test = data(a(21:end),:); %剩下的为测试集 % 训练数据 P_train = Train(:,2:end); T_train = Train(:,1); % 测试数据 P_test = Test(:,2:end); T_test = Test(:,1); %% 创建随机森林分类器 model = classRF_train(P_train,T_train); %% 仿真测试 [T_sim,votes] = classRF_predict(P_test,model); %%获得随机森林 ctree=ClassificationTree.fit(P_train,T_train); %%随机森林试图 view(ctree); view(ctree,'mode','graph'); %%十字交叉验证 leafs=logspace(1,2,10); N=numel(leafs); err=zeros(N,1); for n=1:N t=ClassificationTree.fit(P_train,T_train,'crossval','on','minleaf',leafs(n)); err(n)=kfoldLoss(t); end plot(leafs,err);
(Data=[]; A = randperm ();% Total number of data filled in Train = data (a (1:20),:);% from 1 to 20 behavior training sets Test = data (a (21:end),:);% The rest is the test set. % Training data P_train = Train (:, 2:end); T_train = Train (:, 1); % Test data P_test = Test (:, 2:end); T_test = Test (:, 1); %% Creating Random Forest Classifier Model = classRF_train (P_train, T_train); %% simulation test [T_sim, votes] = classRF_predict (P_test, model); %% Obtaining Random Forests Ctree = Classification Tree. fit (P_train, T_train); %% Random Forest Attempt View (ctree); View (ctree,'mode','graph'); %% Cross-validation Leafs = logspace (1,2,10); N = numel (leafs); Err = zeros (N, 1); For n = 1:N T = Classification Tree. fit (P_train, T_train,'crossval','on','minleaf', leafs (n)); Err (n) = kfoldLoss (t); End Plot (leafs, err);)

文件列表:[举报垃圾]
Windows-Precompiled-RF_MexStandalone-v0.02-.zip, 455968 , 2019-06-25
randomforest.m, 715 , 2019-06-26

近期下载者

相关文件

评论我要评论

收藏者