4

I have a machine's fault(s) occurrence data (in terms of 0 & 1) with respect to 1 minute time intervals. 0 stands for no fault occurred and 1 stands for say a particular fault occurred. So continuous 0's means no fault occurred in a time duration and continuous 1's means a fault continuously occurred in a time duration. I have provided sample data structure as below, now how can I do a time series analysis Fault A on the data provided below and based on analysis how I can do a forecasting like "When Fault A will occur in future time stamps?"

# Time series multivariate
import pandas as pd
import numpy as np

df = pd.DataFrame({'timestamp':pd.date_range('2022-05-01 00:01:00', periods=18, freq='T'),
                   'fault_code':['A']*4+['B']*3+['A']*2+['C']*5+['B']*2+['A']*1+['D']*1
                  }) 
df['pulse']    = 1

df_ts = df.pivot(index="timestamp", columns="fault_code", values="pulse")
df_ts = df_ts.fillna(0)
display(df_ts)



         fault_code A   B   C   D
timestamp               
2022-05-01 00:01:00 1   0   0   0
2022-05-01 00:02:00 1   0   0   0
2022-05-01 00:03:00 1   0   0   0
2022-05-01 00:04:00 1   0   0   0
2022-05-01 00:05:00 0   1   0   0
2022-05-01 00:06:00 0   1   0   0
2022-05-01 00:07:00 0   1   0   0
2022-05-01 00:08:00 1   0   0   0
2022-05-01 00:09:00 1   0   0   0
2022-05-01 00:10:00 0   0   1   0
2022-05-01 00:11:00 0   0   1   0
2022-05-01 00:12:00 0   0   1   0
2022-05-01 00:13:00 0   0   1   0
2022-05-01 00:14:00 0   0   1   0
2022-05-01 00:15:00 0   1   0   0
2022-05-01 00:16:00 0   1   0   0
2022-05-01 00:17:00 1   0   0   0
2022-05-01 00:18:00 0   0   0   1

# Time Series Plot 
import matplotlib.pyplot as plt
import seaborn as sns

sns.set_theme(style="whitegrid") # darkgrid, whitegrid, dark, white, and ticks

faults=['A',
        'B',
        'C',
        'D'
       ]

plt.figure(figsize = (15,4))
sns.lineplot(data=df_ts[faults])
plt.show()

Time Series Plot of above Data

I want next occurrence of Fault A
         fault_code  A 
timestamp    
2022-05-01 00:19:00  ?   
2022-05-01 00:20:00  ? 
2022-05-01 00:21:00  ? 
2022-05-01 00:22:00  ? 
2022-05-01 00:23:00  ? 
2022-05-01 00:24:00  ? 
2022-05-01 00:25:00  ?

? asks what forecasted value either o or 1

0 Answers0