Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,20 +47,21 @@ def predict_fault(uploaded_csv):
|
|
| 47 |
|
| 48 |
# Merge fault descriptions
|
| 49 |
df['Predicted Fault Type'] = predicted_faults
|
| 50 |
-
df = df.merge(fault_table, left_on='Predicted Fault Type', right_on='
|
| 51 |
-
|
| 52 |
-
# Plot bar chart
|
| 53 |
fig, ax = plt.subplots()
|
| 54 |
fault_counts = df['Predicted Fault Type'].value_counts().sort_index()
|
| 55 |
fault_counts.plot(kind='bar', ax=ax)
|
| 56 |
ax.set_title("Jumlah Tipe Fault yang Diprediksi")
|
| 57 |
-
ax.set_xlabel("
|
| 58 |
-
ax.set_ylabel("
|
| 59 |
ax.set_xticks(range(4))
|
| 60 |
ax.set_xticklabels(["No Fault", "Rich", "Lean", "Low Volt"], rotation=0)
|
| 61 |
plt.tight_layout()
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
# Gradio Interface
|
| 66 |
demo = gr.Interface(
|
|
|
|
| 47 |
|
| 48 |
# Merge fault descriptions
|
| 49 |
df['Predicted Fault Type'] = predicted_faults
|
| 50 |
+
df = df.merge(fault_table, left_on='Predicted Fault Type', right_on='Tipe Kerusakan', how='left')
|
| 51 |
+
|
| 52 |
+
# Plot bar chart
|
| 53 |
fig, ax = plt.subplots()
|
| 54 |
fault_counts = df['Predicted Fault Type'].value_counts().sort_index()
|
| 55 |
fault_counts.plot(kind='bar', ax=ax)
|
| 56 |
ax.set_title("Jumlah Tipe Fault yang Diprediksi")
|
| 57 |
+
ax.set_xlabel("Tipe Fault")
|
| 58 |
+
ax.set_ylabel("Jumlah")
|
| 59 |
ax.set_xticks(range(4))
|
| 60 |
ax.set_xticklabels(["No Fault", "Rich", "Lean", "Low Volt"], rotation=0)
|
| 61 |
plt.tight_layout()
|
| 62 |
+
|
| 63 |
+
# Return output
|
| 64 |
+
return df[['Predicted Fault Type', 'Nama Kerusakan', 'Kondisi']].head(10), fig
|
| 65 |
|
| 66 |
# Gradio Interface
|
| 67 |
demo = gr.Interface(
|