for file in ['楼梯','概念漂移','趋势加周期','平稳','跑批','趋势']:
os.mkdir('/Users/sd/Desktop/anomaly_detection/png/' + file)
for file_name in os.listdir('/Users/sd/Desktop/anomaly_detection/' + file):
df = pd.read_csv('/Users/sd/Desktop/anomaly_detection/' + file + '/' + file_name)
df_anomaly = df[df['anomaly']==1]
plt.rcParams['font.sans-serif'] = ['Songti SC']
plt.rcParams['axes.unicode_minus'] = False
plt.figure(dpi=300,figsize=(12,8))
plt.title(file_name)
plt.xticks(fontsize=12,fontweight='bold')
plt.yticks(fontsize=12,fontweight='bold')
plt.xlabel('timestamp',fontsize=13,fontweight='bold')
plt.ylabel('value',fontsize=13,fontweight='bold')
plt.plot(df['timestamp'],df['value'],color='b',label='history_data')
plt.scatter(df_anomaly['timestamp'],df_anomaly['value'],color='r',label='anomaly point')
save_path = '/Users/sd/Desktop/anomaly_detection/png/' + file + '/' + file_name + '.png'
plt.savefig(save_path,format='png',bbox='tight')
异常检测画图
最新推荐文章于 2025-04-11 23:32:14 发布