📄 workbench_rankncg_linear_direct.html
字号:
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>workbench_RankNCG_linear_direct</title> <meta name="generator" content="MATLAB 7.2"> <meta name="date" content="2006-09-28"> <meta name="m-file" content="workbench_RankNCG_linear_direct"><style>body { background-color: white; margin:10px;}h1 { color: #990000; font-size: x-large;}h2 { color: #990000; font-size: medium;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. On Gecko-based browsers, the shrink-to-fit doesn't work. */ p,h1,h2,div.content div { /* for MATLAB's browser */ width: 600px; /* for Mozilla, but the "width" tag overrides it anyway */ max-width: 600px; /* for IE */ width:expression(document.body.clientWidth > 620 ? "600px": "auto" );}pre.codeinput { background: #EEEEEE; padding: 10px;}@media print { pre.codeinput {word-wrap:break-word; width:100%;}} span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.codeoutput { color: #666666; padding: 10px;}pre.error { color: red;}p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;} </style></head> <body> <div class="content"><pre class="codeinput">clear <span class="string">all</span>;close <span class="string">all</span>;disp(<span class="string">'RankNCG linear direct'</span>);<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Ranking parameters</span><span class="comment">%--------------------------------------------------------------------------</span>CG_tolerance=1e-3; <span class="comment">% tolerance for the conjugate gradient procedure</span>epsilon=1e-6; <span class="comment">% accuracy parameter for the approximate gradient computation</span>lambda=10; <span class="comment">%regularization parameter</span><span class="comment">%method='approx'; %Gradient computation done with fast approximate erfc summation</span>method=<span class="string">'direct'</span>; <span class="comment">%Gradient computation done without any approximations</span>verbose=1;plot_enable=1;graph_type=<span class="string">'full'</span>;<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Load a sample data set</span><span class="comment">%--------------------------------------------------------------------------</span>disp(<span class="string">'Loading the Burges data set ...'</span>);addpath <span class="string">..\..\Data\Burges_ICML2005_data</span>d=1;S=6;N_train=500;N_test=5000;N=N_train+N_test;[X,y]=Burges_data_1(d,N,S);<span class="comment">%[X,y]=Burges_data_2(d,N,S);</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Split it into training and test set.</span><span class="comment">%--------------------------------------------------------------------------</span>disp(<span class="string">'Splitting it into training and test set ...'</span>);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 <span class="string">X</span>;clear <span class="string">y</span>;<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Standardize the training data</span><span class="comment">%--------------------------------------------------------------------------</span>addpath <span class="string">..\..\Data\</span>disp(<span class="string">'Normalizing the data ...'</span>);whiten=1;[X_train,mean_vector,A]=data_standardization(X_train,whiten,plot_enable);<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Standardize the test data</span><span class="comment">%--------------------------------------------------------------------------</span>[X_test]=data_standardization_test_data(X_test,mean_vector,A,plot_enable);<span class="comment">%--------------------------------------------------------------------------</span><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 Nonlinear Conjugate gradient procedure ...'</span>);[w,time_taken]=RankNCG_linear_train(data_train,CG_tolerance,lambda,method,epsilon,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]=RankNCG_linear_ranking_function(data_train.X_raw,w);[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>);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -