centersparsedata.m.svn-base
来自「a function inside machine learning」· SVN-BASE 代码 · 共 20 行
SVN-BASE
20 行
function cX = centerSparseData(X)
%Centers a sparse matrix by taking the mean of each column (feature) of M and
%subtracting the mean from feature value. NOTE: This often makes it non
%sparse!
%
%inputs
% M is the matrix to be centered
%
%outputs
% cX is the centered matrix
[numExamples, numFeatures] = size(X);
cX = sparse(numExamples, numFeatures);
meanX = mean(X);
for i=1:numFeatures
cX(:, i) = X(:, i) - meanX(i);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?