sudhirpgcmma02 commited on
Commit
d4f524f
·
verified ·
1 Parent(s): 1e5f430

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +32 -33
app.py CHANGED
@@ -91,8 +91,7 @@ with st.form("engine_input_form"):
91
  # Predict Button
92
  # -----------------------------
93
  if submit:
94
-
95
- input_df = pd.DataFrame({
96
  "engine_rpm": [engine_rpm],
97
  "lub_oil_pressure": [lub_oil_pressure],
98
  "fuel_pressure": [fuel_pressure],
@@ -101,46 +100,46 @@ if submit:
101
  "coolant_temp": [coolant_temp]
102
  })
103
 
104
- st.success("✅ Input captured successfully")
105
- st.write("### Input Data")
106
- st.dataframe(input_df)
107
 
108
- # Predict
109
- prediction = model.predict(input_df)[0]
110
- prob = model.predict_proba(input_df)[0][1]
111
 
112
- st.subheader("Prediction Result")
113
 
114
- if prob>=0.5:
115
  label="Maintenance Needed"
116
  st.warning(f"Engine needs Preventive maintenance. Probability: {prob:.2f}")
117
- else:
118
  label="Normal"
119
  st.success(f"Engine working normal. Probability: {prob:.2f}")
120
 
121
- # Save prediction to dataframe
122
- input_df['Engine_condition'] = label #'Normal / Preventive maintenance req '
123
- st.session_state['input_df'] = input_df
124
- st.dataframe(input_df)
125
- # -----------------------------
126
- # SAVE RECORDS SECTION
127
- # -----------------------------
128
- if st.button("Save Record"):
129
- if "input_df" in st.session_state:
130
- file_path = "records.csv"
131
-
132
- # If file exists → append
133
- if os.path.exists(file_path):
134
- existing_df = pd.read_csv(file_path)
135
- updated_df = pd.concat([existing_df, input_df], ignore_index=True)
136
- else:
137
- # Create new CSV
138
- updated_df = st.session_state['input_df']
139
 
140
- updated_df.to_csv(file_path, index=False)
141
 
142
- st.success("Record saved successfully!")
143
 
144
- else:
145
- st.error("Record not saved...Thank for analysis")
146
 
 
91
  # Predict Button
92
  # -----------------------------
93
  if submit:
94
+ input_df = pd.DataFrame({
 
95
  "engine_rpm": [engine_rpm],
96
  "lub_oil_pressure": [lub_oil_pressure],
97
  "fuel_pressure": [fuel_pressure],
 
100
  "coolant_temp": [coolant_temp]
101
  })
102
 
103
+ st.success("✅ Input captured successfully")
104
+ st.write("### Input Data")
105
+ st.dataframe(input_df)
106
 
107
+ # Predict
108
+ prediction = model.predict(input_df)[0]
109
+ prob = model.predict_proba(input_df)[0][1]
110
 
111
+ st.subheader("Prediction Result")
112
 
113
+ if prob>=0.5:
114
  label="Maintenance Needed"
115
  st.warning(f"Engine needs Preventive maintenance. Probability: {prob:.2f}")
116
+ else:
117
  label="Normal"
118
  st.success(f"Engine working normal. Probability: {prob:.2f}")
119
 
120
+ # Save prediction to dataframe
121
+ input_df['Engine_condition'] = label #'Normal / Preventive maintenance req '
122
+ st.session_state['input_df'] = input_df
123
+ st.dataframe(input_df)
124
+ # -----------------------------
125
+ # SAVE RECORDS SECTION
126
+ # -----------------------------
127
+ if st.button("Save Record"):
128
+ if "input_df" in st.session_state:
129
+ file_path = "records.csv"
130
+
131
+ # If file exists → append
132
+ if os.path.exists(file_path):
133
+ existing_df = pd.read_csv(file_path)
134
+ updated_df = pd.concat([existing_df, input_df], ignore_index=True)
135
+ else:
136
+ # Create new CSV
137
+ updated_df = st.session_state['input_df']
138
 
139
+ updated_df.to_csv(file_path, index=False)
140
 
141
+ st.success("Record saved successfully!")
142
 
143
+ else:
144
+ st.error("Record not saved...Thank for analysis")
145