zhuxi преди 2 години
родител
ревизия
aa1bd8eb0e
променени са 2 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 5 2
      LIB/MIDDLE/Anomaly_Detection/V1_0_0/anomalyPCA.py
  2. 2 0
      LIB/MIDDLE/Anomaly_Detection/V1_0_0/main_detection.py

+ 5 - 2
LIB/MIDDLE/Anomaly_Detection/V1_0_0/anomalyPCA.py

@@ -68,9 +68,12 @@ def transform(df_data_pro,model,df_data):
     X_train_inverse=pd.DataFrame(data=X_train_inverse,index=df_data_pro.index)
     #异常指数
     anomalyScoresModel=anomalyScores(df_data_pro,X_train_inverse)
-    anomalyScoresModel=savgol_filter(anomalyScoresModel,15,3)
     df_data2=df_data.copy()
-    df_data2['anomalyScores_'+str(model)]=anomalyScoresModel
+    if len(anomalyScoresModel)>15:
+        anomalyScoresModel=savgol_filter(anomalyScoresModel,15,3)
+        df_data2['anomalyScores_'+str(model)]=anomalyScoresModel
+    else:
+        df_data2['anomalyScores_'+str(model)]=0
     return df_data2
 
 #判断离群

+ 2 - 0
LIB/MIDDLE/Anomaly_Detection/V1_0_0/main_detection.py

@@ -83,6 +83,7 @@ for k in range(l):
                             end_time='0000-00-00 00:00:00'
                         else:
                             end_time=outliers.loc[outliers.index[-1],'时间']
+                            end_time=end_time+'0:00'
                         code='C493'
                         level=4
                         info='热失控预警'
@@ -97,6 +98,7 @@ for k in range(l):
                             end_time='0000-00-00 00:00:00'
                         else:
                             end_time=outliers.loc[outliers.index[-1],'时间']
+                            end_time=end_time+'0:00'
                             df_diag_ram_sn['end_time']=end_time
                             with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\06BatSafetyAlarm\热失控报警.txt','a') as file:
                                 file.write(str(tuple(df_diag_ram_sn.iloc[-1]))+'\n')