Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import pickle
|
| 4 |
+
|
| 5 |
+
loaded_model = pickle.load(open("finalized_model.sav", 'rb'))
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def main():
|
| 9 |
+
st.image('img.jpg')
|
| 10 |
+
st.title("⚙️🔩 Engine prediction ⚙️🔩")
|
| 11 |
+
st.warning("Our Machine Learning algorithm predicts whether the elements of a machine work consistently\n\n")
|
| 12 |
+
|
| 13 |
+
with st.form(key='columns_in_form'):
|
| 14 |
+
c1, c2, c3 = st.beta_columns(3)
|
| 15 |
+
with c1:
|
| 16 |
+
airTemperature = st.slider("Air temperature [K]", 0, 1500, 750)
|
| 17 |
+
with c2:
|
| 18 |
+
processTemperatire = st.slider(
|
| 19 |
+
"Process temperature [K]", 0, 1500, 750)
|
| 20 |
+
with c3:
|
| 21 |
+
rotationSpeed = st.slider(
|
| 22 |
+
"Rotational speed [rpm]", 0, 1500, 750)
|
| 23 |
+
submitButton1 = st.form_submit_button(label='Save')
|
| 24 |
+
with st.form(key='columns_in_form2'):
|
| 25 |
+
c1, c2, c3, c4 = st.beta_columns(4)
|
| 26 |
+
with c1:
|
| 27 |
+
toolWear = st.slider("Tool wear [min]", 0, 1500, 750)
|
| 28 |
+
with c2:
|
| 29 |
+
typeL = st.select_slider('Type_L', options=[0, 1])
|
| 30 |
+
with c3:
|
| 31 |
+
typeM = st.select_slider('Type_M', options=[0, 1])
|
| 32 |
+
with c4:
|
| 33 |
+
torqueNm = st.select_slider('Torque [Nm]', options=[0, 300])
|
| 34 |
+
submitButton2 = st.form_submit_button(label='Calculate')
|
| 35 |
+
if (submitButton2):
|
| 36 |
+
d = {'Air temperature [K]': airTemperature, 'Process temperature [K]': processTemperatire,
|
| 37 |
+
'Rotational speed [rpm]': rotationSpeed, "Torque [Nm]": torqueNm, "Tool wear [min]": toolWear, "Type_L": typeL, "Type_M": typeM}
|
| 38 |
+
ser = pd.Series(data=d, index=['Air temperature [K]', 'Process temperature [K]',
|
| 39 |
+
'Rotational speed [rpm]', 'Torque [Nm]', 'Tool wear [min]', 'Type_L', 'Type_M'])
|
| 40 |
+
|
| 41 |
+
res = loaded_model.predict([ser])
|
| 42 |
+
if (res[0] == 0):
|
| 43 |
+
st.success("The machine is in good condition")
|
| 44 |
+
else:
|
| 45 |
+
st.error("The machine seems to have problems")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
if __name__ == '__main__':
|
| 50 |
+
main()
|