sampledata.m.svn-base

来自「a function inside machine learning」· SVN-BASE 代码 · 共 19 行

SVN-BASE
19
字号
function [newX, newY] = sampleData(X, y, sampleSize); 
%Take a random sample of the data 

if (nargin ~= 3)
    fprintf('%s\n', help(sprintf('%s', mfilename)));
    error('Incorrect number of inputs - see above usage instructions.');
end

numExamples = size(X, 1); 
sampleSize = min(sampleSize, numExamples); 

permutationVector = randperm(numExamples);
sampleIndexVector = permutationVector(1:sampleSize); 

newX = X(sampleIndexVector, :); 
newY = y(sampleIndexVector, :); 

fprintf('Subsampled data from %d to %d examples\n', numExamples, sampleSize); 

⌨️ 快捷键说明

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