Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
#1
by Atikarahmanda - opened
- src/streamlit_app.py +35 -9
src/streamlit_app.py
CHANGED
|
@@ -30,15 +30,41 @@ if df.isnull().values.any():
|
|
| 30 |
st.warning("β οΈ Harap lengkapi semua nilai pada tabel sebelum menjalankan perhitungan.")
|
| 31 |
st.stop()
|
| 32 |
|
| 33 |
-
|
| 34 |
-
st.subheader("
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
for i
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# --- Step 4: Ideal Profile ---
|
| 44 |
st.subheader("π― Ideal Profile (untuk Profile Matching)")
|
|
|
|
| 30 |
st.warning("β οΈ Harap lengkapi semua nilai pada tabel sebelum menjalankan perhitungan.")
|
| 31 |
st.stop()
|
| 32 |
|
| 33 |
+
if method == "AHP":
|
| 34 |
+
st.subheader("π Perbandingan Berpasangan Antar Kriteria (AHP)")
|
| 35 |
+
pairwise_matrix = pd.DataFrame(np.ones((len(criteria), len(criteria))), index=criteria, columns=criteria)
|
| 36 |
+
|
| 37 |
+
for i in range(len(criteria)):
|
| 38 |
+
for j in range(i + 1, len(criteria)):
|
| 39 |
+
val = st.number_input(
|
| 40 |
+
f"Seberapa penting '{criteria[i]}' dibandingkan '{criteria[j]}'?",
|
| 41 |
+
min_value=1/9.0, max_value=9.0, value=1.0, step=0.1,
|
| 42 |
+
key=f"{criteria[i]}_{criteria[j]}"
|
| 43 |
+
)
|
| 44 |
+
pairwise_matrix.iloc[i, j] = val
|
| 45 |
+
pairwise_matrix.iloc[j, i] = 1 / val
|
| 46 |
+
|
| 47 |
+
st.write("π Matriks Perbandingan Kriteria:")
|
| 48 |
+
st.dataframe(pairwise_matrix)
|
| 49 |
+
|
| 50 |
+
norm_matrix = pairwise_matrix / pairwise_matrix.sum()
|
| 51 |
+
weights = norm_matrix.mean(axis=1).values
|
| 52 |
+
weights /= weights.sum()
|
| 53 |
+
|
| 54 |
+
st.write("π― Bobot Kriteria dari AHP:")
|
| 55 |
+
st.dataframe(pd.Series(weights, index=criteria, name="Bobot"))
|
| 56 |
+
|
| 57 |
+
else:
|
| 58 |
+
# --- Step 3 (non-AHP): Manual Bobot Kriteria ---
|
| 59 |
+
st.subheader("βοΈ Bobot Kriteria")
|
| 60 |
+
weight_dict = {}
|
| 61 |
+
cols = st.columns(len(criteria))
|
| 62 |
+
for i, c in enumerate(criteria):
|
| 63 |
+
with cols[i]:
|
| 64 |
+
weight_dict[c] = st.number_input(f"Bobot untuk '{c}'", min_value=1.0, max_value=10.0, value=5.0, step=0.1)
|
| 65 |
+
weights = np.array([weight_dict[c] for c in criteria])
|
| 66 |
+
weights /= weights.sum() # normalize
|
| 67 |
+
|
| 68 |
|
| 69 |
# --- Step 4: Ideal Profile ---
|
| 70 |
st.subheader("π― Ideal Profile (untuk Profile Matching)")
|