paulus5 commited on
Commit
1b73d5d
·
verified ·
1 Parent(s): 2d9cc86

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +19 -0
utils.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+
4
+ def detect_anomalies(csv_file):
5
+
6
+ df = pd.read_csv(csv_file)
7
+
8
+ column = df.columns[0]
9
+
10
+ values = df[column]
11
+
12
+ mean = values.mean()
13
+ std = values.std()
14
+
15
+ threshold = mean + 3 * std
16
+
17
+ df["anomaly"] = values > threshold
18
+
19
+ return df, threshold