forked from Vikrant7981/anomaly_detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre_processing_insights.py
36 lines (26 loc) · 1.04 KB
/
pre_processing_insights.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# imports
import os
import pandas as pd
import numpy as np
import seaborn as sns
sns.set(color_codes=True)
import matplotlib.pyplot as plt
data_dir = 'Here place the location of unzipped BearingData Set2 folder'
merged_data = pd.DataFrame()
for filename in os.listdir(data_dir):
dataset=pd.read_csv(os.path.join(data_dir, filename), sep='\t')
dataset_mean_abs = np.array(dataset.abs().mean())
dataset_mean_abs = pd.DataFrame(dataset_mean_abs.reshape(1,4))
dataset_mean_abs.index = [filename]
merged_data = merged_data.append(dataset_mean_abs)
merged_data.columns = ['Bearing 1','Bearing 2','Bearing 3','Bearing 4']
merged_data.index = pd.to_datetime(merged_data.index, format='%Y.%m.%d.%H.%M.%S')
merged_data = merged_data.sort_index()
merged_data.to_csv('./dataset/dataset_Bearing_rough.csv')
merged_data.head()
dataset_train = merged_data['2004-02-12 11:02:39':'2004-02-13 23:52:39']
dataset_test = merged_data['2004-02-13 23:52:39':]
dataset_train.plot(figsize = (12,6))
plt.show()
dataset_test.plot(figsize = (12,6))
plt.show()