def preprocessFeatureMat(X, Lfilt):
"""
Binarizes and blurs the feature matrix
Parameters
----------
X : 2D array
The original feature matrix (presumably output by buildFeatureMat())
Lfilt : int
The width of the hamming filter used to blur the feature matrix.
Returns
-------
X : 2D array
The modified feature matrix without blur
Xblur : 2D array
The modified feature matrix with blur
"""
Xblur = _filterRows(X, Lfilt)
# ensure that the maximum value in Xblur is 1; we do this by dividing
# by the largets value within Lfilt / 2, rather than just clamping, so
# that there's a smooth dropoff as you move away from dense groups of
# 1s in X; otherwise it basically ends up max-pooled
maxima = filters.maximum_filter1d(Xblur, Lfilt // 2, axis=1, mode='constant')
Xblur[maxima > 0] /= maxima[maxima > 0]
# have columns be adjacent in memory
return np.asfortranarray(X), np.asfortranarray(Xblur)
评论列表
文章目录