📄 centersparsedata.m.svn-base
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -