?? workbench_rankboost.m
字號(hào):
clear all;close all;disp('RankBoostt');%--------------------------------------------------------------------------% Ranking parameters%--------------------------------------------------------------------------T=50; % number of boosting roundsverbose=1;plot_enable=1;graph_type='full';%--------------------------------------------------------------------------% Load a sample data set%--------------------------------------------------------------------------disp('Loading the Burges data set ...');addpath ..\..\Data\Burges_ICML2005_datad=1;S=6;N_train=1000;N_test=5000;N=N_train+N_test;[X,y]=Burges_data_1(d,N,S);%[X,y]=Burges_data_2(d,N,S);%--------------------------------------------------------------------------% Split it into training and test set.%--------------------------------------------------------------------------disp('Splitting it into training and test set ...');X_train=X(:,1:N_train);y_train=y(:,1:N_train);X_test=X(:,N_train+1:N);y_test=y(:,N_train+1:N);clear X;clear y;%--------------------------------------------------------------------------% Standardize the training data%--------------------------------------------------------------------------addpath ..\..\Data\disp('Normalizing the data ...');whiten=1;[X_train,mean_vector,A]=data_standardization(X_train,whiten,plot_enable);%--------------------------------------------------------------------------% Standardize the test data%--------------------------------------------------------------------------[X_test]=data_standardization_test_data(X_test,mean_vector,A,plot_enable);%--------------------------------------------------------------------------% Convert the data to a format which my code understands%--------------------------------------------------------------------------disp('Formatting the training data ...');[data_train]=convert_data_to_ranking_format(X_train,y_train,graph_type);clear X_train;clear y_train;disp('Formatting the test data ...');[data_test]=convert_data_to_ranking_format(X_test,y_test,graph_type);clear X_test;clear y_test;%--------------------------------------------------------------------------% Train the model%--------------------------------------------------------------------------disp('Training using RankBoost ...');[model,time_taken]=RankBoost_train(data_train,T,verbose,plot_enable);disp(sprintf('Time taken =%f seconds',time_taken));%--------------------------------------------------------------------------% Test the performance on the training set%--------------------------------------------------------------------------disp('Evaluating the performance on the training set ...');[o_train]=RankBoost_ranking_function(data_train.X_raw,T,model);[WMW_train]=compute_WMW(data_train,o_train,1);disp(sprintf('WMW of the training set =%f',WMW_train)); %--------------------------------------------------------------------------% Test the performance on the test set%--------------------------------------------------------------------------disp('Evaluating the performance on the test set ...');[o_test]=RankBoost_ranking_function(data_test.X_raw,T,model);[WMW_test]=compute_WMW(data_test,o_test,1);disp(sprintf('WMW of the test set =%f',WMW_test));%--------------------------------------------------------------------------% Plot to see the ranking function learnt%--------------------------------------------------------------------------figure;subplot(2,2,1);plot(data_train.X_raw(1,:),data_train.y_raw,'b.');hold on;plot(data_train.X_raw(1,:),o_train,'r.');title('Training data');subplot(2,2,2);plot(data_test.X_raw(1,:),data_test.y_raw,'b.');hold on;plot(data_test.X_raw(1,:),o_test,'r.');title('Test data');
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -