异常检测画图

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')

版权声明:本文为happy_wealthy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。