[问题] Numpy array filter

楼主: rossy (Rossy)   2017-07-25 14:38:19
大家好
最近在学习Python Data Visulization,利用一个叫做is_outlier的函数找出资料里的outlier:
def is_outlier(points, threshold = 3.5):
if len(points.shape) == 1:
points = points[:,None]
median = np.median(points, axis = 0)
diff = np.sum((points = median)**2, axis = -1)
diff = np.sqrt(diff)
med_abs_deviation = np.median(diff)
modified_z_score = 0.6745*diff/med_abs/deviation
return modified_z_score > threshold
x = np.random.randmon(100)
x = no.r_[x, -49, 95, 100, -100]
filtered = x[~is_outlier(x)]
想请教大家,在函数内的points[:,None]是什么意思?
还有为何filtered的值会是剔除outlier的numpy array呢?
是因为return modified_z_score > threshold这个判断式会对整个array里的值做判断,然后True的值就放到filtered里面吗?
楼主: rossy (Rossy)   2017-07-26 23:46:00
已解决

Links booklink

Contact Us: admin [ a t ] ucptt.com