File size: 2,167 Bytes
ecd49b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28a7457
ecd49b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb9e931
ecd49b8
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from PIL import Image

def run():
    # Title
    st.title('Equipment in Smart Manufacturing for Predictive Maintenance')

    # Sub Header
    st.subheader('Exploratory Data Analysis (EDA) of dataset')

    # Image
    image = Image.open('./src/image1.jpg')
    st.image(image, caption= "Factory Landscape")

    # DataFrame
    st.write('##### Data frame')
    df = pd.read_csv('./src/smart_manufacturing_dataset.csv')
    st.dataframe(df)

    # EDA distribution numerical
    st.write('##### Distribution plot numerical')
    fig = plt. figure(figsize=(15, 5))
    option = st.selectbox('Columns : ', ('temperature', 'vibration', 'humidity', 'pressure', 'energy_consumption', 'predicted_remaining_life', 'downtime_risk', 'maintenance_required'))
    sns.histplot(df[option], bins=30, kde=True)
    st.pyplot(fig)

      # EDA Heatmap correlation numerical with maintenance_required
    st.write('##### Heatmap correlation with maintenance_required')
    fig = plt. figure(figsize=(15, 10))
    sns.heatmap(df[['temperature', 'vibration', 'humidity', 'pressure', 'energy_consumption', 'predicted_remaining_life', 'downtime_risk', 'maintenance_required']].corr(), annot=True, cmap='coolwarm')
    st.pyplot(fig)

    # EDA distribution categorical vs maintenance_required
    st.write('##### Distribution plot categorical vs maintenance_required')
    fig = plt. figure(figsize=(15, 5))
    option = st.selectbox('Columns : ', ('machine_id', 'machine_status', 'anomaly_flag', 'failure_type'))
    sns.countplot(x=option, hue='maintenance_required', data=df)
    st.pyplot(fig)

    # EDA equipment that have maintenance_required=1
    top_machines = (
    df[df['maintenance_required'] == 1]
    .groupby('machine_id')
    .size()
    .sort_values(ascending=False))

    st.write('##### Equipment maintenance signal accumulation')
    fig = plt.figure(figsize=(15,5))
    sns.barplot(
    x=top_machines.index.astype(str),
    y=top_machines.values,
    hue=top_machines.index.astype(str),
    palette='rocket')
    st.pyplot(fig)

if __name__ == '__main__':
    run()