Meera2602 commited on
Commit
407d829
โ€ข
1 Parent(s): 75f089c

app.py updated

Browse files
Files changed (2) hide show
  1. .streamlit/config.toml +7 -0
  2. app2.py +132 -0
.streamlit/config.toml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # .streamlit/config.toml
2
+ [theme]
3
+ primaryColor = "#1E90FF"
4
+ backgroundColor = "#F0F0F0"
5
+ secondaryBackgroundColor = "#E8E8E8"
6
+ textColor = "#000000"
7
+ font = "sans serif"
app2.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_extras import add_vertical_space
3
+ import streamlit.components.v1 as components
4
+ from annotated_text import annotated_text
5
+ import pandas as pd
6
+ import json
7
+ import plotly.express as px
8
+ import plotly.graph_objs as go
9
+ from src.Predictive_Maintenance.pipelines.prediction_pipeline import prediction
10
+
11
+ st.set_page_config(layout='wide')
12
+
13
+ # Custom CSS to further beautify the app
14
+ st.markdown("""
15
+ <style>
16
+ /* Change the background color */
17
+ .stApp {
18
+ background-color: #F0F0F0;
19
+ }
20
+ /* Customize sidebar */
21
+ .css-1lcbmhc {
22
+ background-color: #E8E8E8 !important;
23
+ }
24
+ /* Style headings */
25
+ h1 {
26
+ color: #1E90FF;
27
+ }
28
+ h2 {
29
+ color: #1E90FF;
30
+ }
31
+ h3 {
32
+ color: #1E90FF;
33
+ }
34
+ /* Style text */
35
+ .css-1v3fvcr p {
36
+ color: #000000;
37
+ }
38
+ </style>
39
+ """, unsafe_allow_html=True)
40
+
41
+ with st.sidebar:
42
+ st.title("๐Ÿ”ง Predictive Maintenance Project")
43
+ choice = st.radio("Choose from the below options:", ["Main", "EDA", "Monitoring Reports", "Performance Measures", "Prediction"])
44
+
45
+ if choice == "Main":
46
+ with open("frontend/main/main_page.md", "r") as file:
47
+ readme_contents = file.read()
48
+ st.markdown(readme_contents)
49
+
50
+ elif choice == "EDA":
51
+ st.title('๐Ÿ” Exploratory Data Analysis')
52
+
53
+ questions = [
54
+ ("What are the minimum, maximum, and typical values for 'air temperature', 'process temperature', 'rotational speed', 'torque', and 'tool wear'?", "reports/q3.png", "Rotational speed may or may not be actual outliers, therefore we keep them in the dataset for now."),
55
+ ("How is the 'productID' variable distributed across the dataset? Specifically, how many instances correspond to low, medium, and high-quality variants?", "reports/q2.png", "Low quality variant makes up majority of the dataset with 60% of the data, followed by medium quality variant with 30% and high quality variant with 10%"),
56
+ ("What is the frequency distribution of the target label 'machine failure' in the dataset? How many instances indicate a failure compared to those that do not?", "reports/q1.png", "The success rate of the machine is 96.52% and the highest type of failure is HDF (Heat Dissipation Failure) with 1.15% failure rate."),
57
+ ("Is the 'rotational speed' higher for high-quality products than for low-quality products? Is there any correlation of 'productIDs' with other continuous variable?", "reports/q5.png", "Process Temperature seems to have an effect on high quality variant machines. Therefore we can say that Process Temperature is correlated with machine type."),
58
+ ("Is there any correlation between the continuous variables and the 'machine failure' label? For example, does the tool wear increase the likelihood of machine failure?", "reports/q4.png", "Null Hypothesis: There is no significant relationship between the different columns and Machine Failure\nAlternate Hypothesis: There is a significant relationship between the tool wear and the machine failure label", "reports/h0.png"),
59
+ ("Are there any significant interactions or non-linear relationships between the variables that could be important for predictive maintenance? For example, does torque increase non-linearly with rotational speed?", "reports/q6.png", "Among all possible combinations of continuous variables, Rotational Speed vs Torque have a negative correlation and process temperature vs air temperature have a positive correlation."),
60
+ ("Are there any discernible patterns or anomalies in the timing of machine failures? How do machine failure rates change over time?", None, "At present the data does not show recorded time of the failure neither it shows the time of sensor data capture. Hence it is difficult to comment on failure rates over time."),
61
+ ("Are there any notable differences in the distribution of continuous variables between different product types?", "reports/q8.png", "Process Temperature seems to have an effect on high quality variant machines. Therefore we can say that Process Temperature is correlated with machine type."),
62
+ ("How does the occurrence of machine failure vary with different operating conditions, such as air temperature and rotational speed?", "reports/q92.png", "Process Temperature seems to have an effect on high quality variant machines. Therefore we can say that Process Temperature is correlated with machine type.")
63
+ ]
64
+
65
+ for idx, (question, img, explanation, *extra_img) in enumerate(questions):
66
+ st.header(f'Question {idx + 1}')
67
+ st.write(question)
68
+ if img:
69
+ st.image(img)
70
+ st.write(f"**{explanation}**")
71
+ if extra_img:
72
+ st.image(extra_img[0])
73
+
74
+ elif choice == "Performance Measures":
75
+ st.title("๐Ÿ“ˆ Performance Measures")
76
+
77
+ models = [
78
+ ("Model 1", "Random Forest Classifier", "reports/model1n.png"),
79
+ ("Model 2", "Random Forest Classifier-registered", "reports/model2n.png")
80
+ ]
81
+
82
+ for model_title, model_description, img in models:
83
+ st.title(model_title)
84
+ annotated_text((f"Best {model_title}", model_description))
85
+ st.image(img)
86
+
87
+ elif choice == "Monitoring Reports":
88
+ st.title("๐Ÿ“Š Monitoring Reports")
89
+
90
+ options = st.selectbox('Choose the reports:', ('Data Report', 'Model 1 report', 'Model 2 report'))
91
+
92
+ report_files = {
93
+ 'Data Report': "reports/data_drift.html",
94
+ 'Model 1 report': "reports/classification_performance_report.html",
95
+ 'Model 2 report': "reports/classification_performance_report2.html"
96
+ }
97
+
98
+ if options in report_files:
99
+ with open(report_files[options], "r", encoding="utf-8") as f:
100
+ html_report = f.read()
101
+ components.html(html_report, scrolling=True, height=700)
102
+
103
+ elif choice == "Prediction":
104
+ st.title('๐Ÿ”ฎ Predictive Maintenance')
105
+ st.write("**Please enter the following parameters**")
106
+
107
+ col1, col2 = st.columns(2)
108
+
109
+ with col1:
110
+ type = st.selectbox('Type', ('Low', 'Medium', 'High'))
111
+ st.write('You selected:', type)
112
+
113
+ rpm = st.number_input('RPM', value=1500.0)
114
+ st.write('The current rpm is ', rpm)
115
+
116
+ torque = st.number_input('Torque', value=75)
117
+ st.write('The current torque is ', torque)
118
+
119
+ with col2:
120
+ tool_wear = st.number_input('Tool Wear', value=25.00)
121
+ st.write('The current tool wear is ', tool_wear)
122
+
123
+ air_temp = st.number_input('Air Temperature', value=35.4)
124
+ st.write('The current air temperature is ', air_temp)
125
+
126
+ process_temp = st.number_input('Process Temperature', value=46.65)
127
+ st.write('The current process temperature is ', process_temp)
128
+
129
+ if st.button("Predict"):
130
+ result1, result2 = prediction(type, rpm, torque, tool_wear, air_temp, process_temp)
131
+ st.write("Machine Failure?: ", result1)
132
+ st.write("Type of Failure: ", result2)