⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workbench_rankboost.html

📁 RankBoost算法实现
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<span class="comment">% Convert the data to a format which my code understands</span><span class="comment">%--------------------------------------------------------------------------</span>disp(<span class="string">'Formatting the training data ...'</span>);[data_train]=convert_data_to_ranking_format(X_train,y_train,graph_type);clear <span class="string">X_train</span>;clear <span class="string">y_train</span>;disp(<span class="string">'Formatting the test data ...'</span>);[data_test]=convert_data_to_ranking_format(X_test,y_test,graph_type);clear <span class="string">X_test</span>;clear <span class="string">y_test</span>;<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Train the model</span><span class="comment">%--------------------------------------------------------------------------</span>disp(<span class="string">'Training using RankBoost ...'</span>);[model,time_taken]=RankBoost_train(data_train,T,verbose,plot_enable);disp(sprintf(<span class="string">'Time taken =%f seconds'</span>,time_taken));<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Test the performance on the training set</span><span class="comment">%--------------------------------------------------------------------------</span>disp(<span class="string">'Evaluating the performance on the training set ...'</span>);[o_train]=RankBoost_ranking_function(data_train.X_raw,T,model);[WMW_train]=compute_WMW(data_train,o_train,1);disp(sprintf(<span class="string">'WMW of the training set =%f'</span>,WMW_train));<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Test the performance on the test set</span><span class="comment">%--------------------------------------------------------------------------</span>disp(<span class="string">'Evaluating the performance on the test set ...'</span>);[o_test]=RankBoost_ranking_function(data_test.X_raw,T,model);[WMW_test]=compute_WMW(data_test,o_test,1);disp(sprintf(<span class="string">'WMW of the test set =%f'</span>,WMW_test));<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Plot to see the ranking function learnt</span><span class="comment">%--------------------------------------------------------------------------</span>figure;subplot(2,2,1);plot(data_train.X_raw(1,:),data_train.y_raw,<span class="string">'b.'</span>);hold <span class="string">on</span>;plot(data_train.X_raw(1,:),o_train,<span class="string">'r.'</span>);title(<span class="string">'Training data'</span>);subplot(2,2,2);plot(data_test.X_raw(1,:),data_test.y_raw,<span class="string">'b.'</span>);hold <span class="string">on</span>;plot(data_test.X_raw(1,:),o_test,<span class="string">'r.'</span>);title(<span class="string">'Test data'</span>);</pre><pre class="codeoutput">RankBoosttLoading the Burges data set ...Splitting it into training and test set ...Normalizing the data ...Formatting the training data ...6 classes N=1000 inputs in d=1 dimensions Graph type=full Total number of pairs=385968Formatting the test data ...6 classes N=5000 inputs in d=1 dimensions Graph type=full Total number of pairs=9441945Training using RankBoost ...Boosting round   1 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.754393 r=0.637763 Z=0.000000Boosting round   2 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.657833 r=0.576919 Z=0.662174Boosting round   3 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.561906 r=0.509390 Z=0.721909Boosting round   4 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.469051 r=0.437432 Z=0.781024Boosting round   5 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.500154 r=0.462238 Z=0.836223Boosting round   6 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.387841 r=0.369497 Z=0.818080Boosting round   7 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.390374 r=0.371683 Z=0.881214Boosting round   8 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.368099 r=0.352328 Z=0.879874Boosting round   9 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.343879 r=0.330936 Z=0.891500Boosting round  10 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.351455 r=0.337665 Z=0.903703Boosting round  11 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.361689 r=0.346701 Z=0.899938Boosting round  12 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.308193 r=0.298793 Z=0.894776Boosting round  13 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.315676 r=0.305592 Z=0.920752Boosting round  14 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.311864 r=0.302132 Z=0.917275Boosting round  15 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.320190 r=0.309679 Z=0.919053Boosting round  16 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.286321 r=0.278745 Z=0.915151Boosting round  17 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.292390 r=0.284333 Z=0.930598Boosting round  18 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.314044 r=0.304112 Z=0.927915Boosting round  19 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.277714 r=0.270788 Z=0.918038Boosting round  20 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.273616 r=0.266986 Z=0.934338Boosting round  21 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.270839 r=0.264405 Z=0.936090Boosting round  22 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.289741 r=0.281896 Z=0.937267Boosting round  23 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.282290 r=0.275023 Z=0.929091Boosting round  24 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.257665 r=0.252111 Z=0.932359Boosting round  25 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.264397 r=0.258403 Z=0.942734Boosting round  26 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.271096 r=0.264645 Z=0.939965Boosting round  27 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.266797 r=0.260642 Z=0.937158Boosting round  28 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.254535 r=0.249176 Z=0.938965Boosting round  29 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.246395 r=0.241527 Z=0.944004Boosting round  30 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.258852 r=0.253221 Z=0.947254Boosting round  31 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.271068 r=0.264618 Z=0.942250Boosting round  32 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.247752 r=0.242804 Z=0.937170Boosting round  33 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.237646 r=0.233271 Z=0.946717Boosting round  34 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.249487 r=0.244436 Z=0.950659Boosting round  35 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.255004 r=0.249616 Z=0.946029Boosting round  36 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.258075 r=0.252494 Z=0.943815Boosting round  37 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.236059 r=0.231770 Z=0.942567Boosting round  38 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.238477 r=0.234056 Z=0.951267Boosting round  39 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.239911 r=0.235412 Z=0.950340Boosting round  40 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.251092 r=0.245945 Z=0.949786Boosting round  41 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.248727 r=0.243722 Z=0.945388Boosting round  42 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.229258 r=0.225324 Z=0.946331Boosting round  43 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.239838 r=0.235342 Z=0.953837Boosting round  44 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.235497 r=0.231238 Z=0.949815Boosting round  45 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.242971 r=0.238300 Z=0.951481Boosting round  46 [ 50] Weak Learner Feature   1 with theta=-0.231691 weight alpha=0.241842 r=0.237235 Z=0.948597Boosting round  47 [ 50] Weak Learner Feature   1 with theta=0.356827 weight alpha=0.232707 r=0.228595 Z=0.949037Boosting round  48 [ 50] Weak Learner Feature   1 with theta=-0.974218 weight alpha=0.232363 r=0.228270 Z=0.952540Boosting round  49 [ 50] Weak Learner Feature   1 with theta=-1.329337 weight alpha=0.235250 r=0.231004 Z=0.952670Boosting round  50 [ 50] Weak Learner Feature   1 with theta=-0.628872 weight alpha=0.234522 r=0.230314 Z=0.951576Time taken =3.390000 secondsEvaluating the performance on the training set ...WMW of the training set =1.000000Evaluating the performance on the test set ...WMW of the test set =1.000000</pre><img vspace="5" hspace="5" src="workbench_RankBoost_01.png"> <p class="footer"><br>            Published with MATLAB&reg; 7.2<br></p>      </div>      <!--##### SOURCE BEGIN #####clear all;close all;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -