python) 我只想从相关性中提取 0.9 以上的值 table
python) I want to extract only values above 0.9 from the correlation table
我的相关 table 由 1446 x 1447 组成。
其中,我只想查看大于 0.9 的数字。 (包括 0.9)
您可以使用numpy.where
with条件来查找满足条件的索引或实际值。
import numpy as np
table = np.random.rand(1446, 1447)
# get all indexes of elem having value >= 0.9
filtered_idx = np.where(table >= 0.9)
# get all elem values >= 0.9
filtered_values = table[filtered_idx]
assert all(filtered_values >= 0.9)
我的相关 table 由 1446 x 1447 组成。
其中,我只想查看大于 0.9 的数字。 (包括 0.9)
您可以使用numpy.where
with条件来查找满足条件的索引或实际值。
import numpy as np
table = np.random.rand(1446, 1447)
# get all indexes of elem having value >= 0.9
filtered_idx = np.where(table >= 0.9)
# get all elem values >= 0.9
filtered_values = table[filtered_idx]
assert all(filtered_values >= 0.9)