使用Python编写一个自定义的异常值检测算法。
# 自定义异常值检测算法
def detect_outliers(data, threshold):
outliers = []
for value in data:
if abs(value) > threshold:
outliers.append(value)
return outliers
# 示例
input_data = [10, 20, 30, 40, 1000, 50, 60, 70, 80, 90, 100]
threshold_value = 100
result = detect_outliers(input_data, threshold_value)
print(result) # 输出 [1000]