윤영준 윤영준 2023-08-31
completed functionality, but flask interface needs to be done
@45a2bb502c715fef30ce04f0d53d71b88da12bab
 
tools/algo/ANOVA.py (added)
+++ tools/algo/ANOVA.py
@@ -0,0 +1,34 @@
+import numpy as np
+import pandas as pd
+from statsmodels.stats.anova import anova_lm
+from statsmodels.formula.api import ols
+from scipy.stats import stats
+from tools.algo.humidity import absolute_humidity
+from tools.algo.interpolation import interpolate_value
+from datetime import datetime
+
+if __name__ == "__main__":
+    df_weather = pd.read_csv("/home/juni/PycharmProjects/failure_analysis/data/weather/202007010000_202308310000_f.csv")
+    df_failure = pd.read_excel("/home/juni/PycharmProjects/failure_analysis/data/failure/대옹 작업내용.xlsx")
+    times = df_failure["작업 시작 시간"]
+    temp = []
+    humidity = []
+
+    for time in times:
+        temp.append(interpolate_value(df_weather, timestamp=time, col_key="기온", k=6))
+        humidity.append(interpolate_value(df_weather, timestamp=time, col_key="상대습도", k=6))
+
+    absolute_humidity = absolute_humidity(humidity, temp)
+
+    df_failure["기온"] = temp
+    df_failure["상대습도"] = humidity
+    df_failure["절대습도"] = absolute_humidity
+    df_failure['불량 여부'] = np.where(df_failure['불량 여부'] == 'F', 0, df_failure['불량 여부'])
+    df_failure['불량 여부'] = np.where(df_failure['불량 여부'] == 'T', 1, df_failure['불량 여부'])
+
+    df_failure = df_failure.loc[:,['불량 여부', '상대습도', '기온', '절대습도']]
+
+    F_statistic, pVal = stats.f_oneway(df_failure[df_failure["불량 여부"] == 0].loc[:,['상대습도', '기온', '절대습도']],
+                                       df_failure[df_failure["불량 여부"] == 1].loc[:,['상대습도', '기온', '절대습도']])
+
+    print(F_statistic, pVal)(파일 끝에 줄바꿈 문자 없음)
tools/algo/correlation.py
--- tools/algo/correlation.py
+++ tools/algo/correlation.py
@@ -26,7 +26,6 @@
     df_failure['불량 여부'] = np.where(df_failure['불량 여부'] == 'F', 0, df_failure['불량 여부'])
     df_failure['불량 여부'] = np.where(df_failure['불량 여부'] == 'T', 1, df_failure['불량 여부'])
 
-
     df = df_failure.copy()
     correlation_manufacturing_abhumidity = pointbiserialr(df["절대습도"], df["불량 여부"])
     correlation_manufacturing_rehumidity = pointbiserialr(df["상대습도"], df["불량 여부"])
Add a comment
List