Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,11 +37,33 @@ def predict_status(UDI, air_temp, proc_temp, speed, torque, tool_wear):
|
|
| 37 |
# Make a prediction
|
| 38 |
prediction = model.predict(sample_df)[0]
|
| 39 |
|
| 40 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
if prediction == 0:
|
| 42 |
-
|
| 43 |
else:
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# Define custom CSS for professional UI/UX
|
| 47 |
custom_css = """
|
|
|
|
| 37 |
# Make a prediction
|
| 38 |
prediction = model.predict(sample_df)[0]
|
| 39 |
|
| 40 |
+
# Initialize the reason list
|
| 41 |
+
reasons = []
|
| 42 |
+
|
| 43 |
+
# Define acceptable ranges for each feature
|
| 44 |
+
acceptable_ranges = {
|
| 45 |
+
"Air temperature [K]": (150, 500),
|
| 46 |
+
"Process temperature [K]": (150, 500),
|
| 47 |
+
"Rotational speed [rpm]": (500, 1500),
|
| 48 |
+
"Torque [Nm]": (100, 800),
|
| 49 |
+
"Tool wear [min]": (50, 300)
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
# Check each feature and add reasons if outside acceptable range
|
| 53 |
+
for feature, (low, high) in acceptable_ranges.items():
|
| 54 |
+
value = sample_input[feature]
|
| 55 |
+
if value < low:
|
| 56 |
+
reasons.append(f"{feature} is too low.")
|
| 57 |
+
elif value > high:
|
| 58 |
+
reasons.append(f"{feature} is too high.")
|
| 59 |
+
|
| 60 |
+
# Generate the final result message
|
| 61 |
if prediction == 0:
|
| 62 |
+
result_message = "🔴 Machine is NOT working. " + (" ".join(reasons) if reasons else "No specific reason identified.")
|
| 63 |
else:
|
| 64 |
+
result_message = "🟢 Machine is working."
|
| 65 |
+
|
| 66 |
+
return result_message
|
| 67 |
|
| 68 |
# Define custom CSS for professional UI/UX
|
| 69 |
custom_css = """
|