统计运算
统计运算
机器学习领域,常见的统计指标:
-
min(a, axis)
:axis表示是按行或按列 -
max(a, axis)
最大值 -
median(a, axis)
中位数 -
mean(a, axis, dtype)
平均值 -
std(a, axis, dtype)
标准差 -
var(a, axis, dtype)
方差 -
np.argmax(temp, axis=)
最大值对应的下标 -
np.argmin(temo, axis=)
最小值对应的下标
>>> score
array([[54, 49, 43, 89, 83],
[83, 52, 54, 46, 66],
[57, 41, 94, 50, 67],
[59, 81, 61, 45, 46],
[63, 47, 68, 48, 75],
[64, 94, 86, 61, 75],
[85, 55, 95, 59, 77],
[77, 83, 79, 86, 84],
[41, 99, 67, 69, 50],
[52, 73, 85, 90, 66]])
>>> temp = score[:4, :]
>>> temp
array([[54, 49, 43, 89, 83],
[83, 52, 54, 46, 66],
[57, 41, 94, 50, 67],
[59, 81, 61, 45, 46]])
>>> np.max(temp) # 所有元素找最大值
94
>>> np.mean(temp)
61.0
>>> np.max(temp, axis=0) # 按列求最大值
array([83, 81, 94, 89, 83])
>>> np.max(temp, axis=1) # 按行求最大值
array([89, 83, 94, 81])
>>> np.argmax(temp) # 按所有元素求最大值的索引
12
>>> np.argmax(temp, axis=0) # 按列最大值所在的索引
array([1, 3, 2, 0, 0], dtype=int64)
>>> np.argmax(temp, axis=1) # 按行最大值所在的索引
array([3, 0, 2, 1], dtype=int64)