for datasetCounter = 1:3 % define datasets of experiment allMyDatasets = {'desharnais','coc81_1_1','COCOMO_NASA93'}; eval(['load ',char(allMyDatasets(datasetCounter)),'.csv;']); eval(['dataset = ',char(allMyDatasets(datasetCounter)),';']); eval(['clear ',char(allMyDatasets(datasetCounter)),';']); for kernelCounter = 1:1 % define datasets of experiment % allMyKernels = {'epanechnikov','gaussian','uniform','triangular'}; allMyKernels = {'mendes'}; %define current kernel currentKernel = allMyKernels(kernelCounter); for bandwidthCounter = 1:1 % define bandwidths of experiment allMyBandwidhts = [1;2;3;4;5]; %1,2,3,4,5 are codes not actuals % define current bandwidth currentBandwidht = allMyBandwidhts(bandwidthCounter); actuals = -1 * ones(20,size(dataset,1)); actualsWithFeatures = []; pred1 = -1 * ones(20,size(dataset,1)); mre1 = -1 * ones(20,size(dataset,1)); pred1 = -1 * ones(20,size(dataset,1)); mre1Kernel = -1 * ones(20,size(dataset,1)); pred3 = -1 * ones(20,size(dataset,1)); mre3 = -1 * ones(20,size(dataset,1)); pred3Kernel = -1 * ones(20,size(dataset,1)); mre3Kernel = -1 * ones(20,size(dataset,1)); pred5 = -1 * ones(20,size(dataset,1)); mre5 = -1 * ones(20,size(dataset,1)); pred5Kernel = -1 * ones(20,size(dataset,1)); mre5Kernel = -1 * ones(20,size(dataset,1)); pred7 = -1 * ones(20,size(dataset,1)); mre7 = -1 * ones(20,size(dataset,1)); pred7Kernel = -1 * ones(20,size(dataset,1)); mre7Kernel = -1 * ones(20,size(dataset,1)); pred9 = -1 * ones(20,size(dataset,1)); mre9 = -1 * ones(20,size(dataset,1)); pred9Kernel = -1 * ones(20,size(dataset,1)); mre9Kernel = -1 * ones(20,size(dataset,1)); predBestK = -1 * ones(20,size(dataset,1)); mreBestK = -1 * ones(20,size(dataset,1)); predBestKKernel = -1 * ones(20,size(dataset,1)); mreBestKKernel = -1 * ones(20,size(dataset,1)); % a dummy to keep track of whether the best k value was found bestKFound = 0; % find the best k value for the train data if bestKFound == 0 myBestK = bestk(dataset); end % repeat 20 times for counter = 1:20 % randomize dataset dataset = randomizeDataset(dataset); % for each row in the randomized dataset do the following i = 0; while i < size(dataset,1) % increment i by 1 i = i + 1; % pick up the row myRow = dataset(i,:); % record it into actuals actuals(counter,i) = myRow(1,size(myRow,2)); % record also the features of that instance (since a lot of instances % have the same effort value, I needed to record the features too) actualsWithFeatures = [actualsWithFeatures;myRow(1,:)]; % train is the dataset minus the selected row train = dataset; train(i,:) = []; % now start predictions % below are the ones for various k values [pred3(counter,i), mre3(counter,i), sortedEffortValues] = nnkForKernel(myRow,train,3); [pred3Kernel(counter,i), mre3Kernel(counter,i)] = myKernelEstimator(myRow, train, currentKernel, sortedEffortValues, currentBandwidht); [pred5(counter,i), mre5(counter,i), sortedEffortValues] = nnkForKernel(myRow,train,5); [pred5Kernel(counter,i), mre5Kernel(counter,i)] = myKernelEstimator(myRow, train, currentKernel, sortedEffortValues, currentBandwidht); [pred7(counter,i), mre7(counter,i), sortedEffortValues] = nnkForKernel(myRow,train,7); [pred7Kernel(counter,i), mre7Kernel(counter,i)] = myKernelEstimator(myRow, train, currentKernel, sortedEffortValues, currentBandwidht); [pred9(counter,i), mre9(counter,i), sortedEffortValues] = nnkForKernel(myRow,train,9); [pred9Kernel(counter,i), mre9Kernel(counter,i)] = myKernelEstimator(myRow, train, currentKernel, sortedEffortValues, currentBandwidht); [predBestK(counter,i), mreBestK(counter,i), sortedEffortValues] = nnkForKernel(myRow,train,myBestK); [predBestKKernel(counter,i), mreBestKKernel(counter,i)] = myKernelEstimator(myRow, train, currentKernel, sortedEffortValues, currentBandwidht); end % counter end currentKernel currentBandwidht % kernelMdMREMMRECalculator(mre3,mre3Kernel,mre5,mre5Kernel,mre7,mre7Kernel,mre9,mre9Kernel,mreBestK,mreBestKKernel); kernelPred25Calculator(mre3,mre3Kernel,mre5,mre5Kernel,mre7,mre7Kernel,mre9,mre9Kernel,mreBestK,mreBestKKernel); end end end