Update src/streamlit_app.py

#4
by Atikarahmanda - opened
Files changed (1) hide show
  1. src/streamlit_app.py +7 -28
src/streamlit_app.py CHANGED
@@ -47,7 +47,7 @@ if method == "AHP":
47
  st.session_state.new_criterion_name = ""
48
  st.session_state.pairwise_matrix = {}
49
 
50
- # Fungsi untuk menghapus kriteria (tidak ada perubahan)
51
  def remove_criterion(idx):
52
  if len(st.session_state.criteria_list) > 1:
53
  st.session_state.criteria_list.pop(idx)
@@ -68,16 +68,13 @@ if method == "AHP":
68
  # Menghapus format tebal dan miring agar konsisten
69
  st.write(criterion['name'])
70
  with col2:
71
- # Kolom untuk tipe kriteria DIHAPUS
72
  if st.button("πŸ—‘", key=f"remove_{i}", help="Hapus kriteria"):
73
  remove_criterion(i)
74
  st.rerun()
75
 
76
- # Extract nama kriteria (variabel criteria_types DIHAPUS)
77
  criteria = [c["name"] for c in st.session_state.criteria_list]
78
- # criteria_types = {c["name"]: c["type"] for c in st.session_state.criteria_list} # <-- BARIS INI DIHAPUS
79
-
80
- # --- Setup Alternatif (tidak ada perubahan) ---
81
  st.sidebar.subheader("🏒 Manajemen Alternatif")
82
 
83
  default_alternatives = [
@@ -666,7 +663,7 @@ if run_calc:
666
  chart_data.columns = ['Alternatif', 'Skor']
667
 
668
  # Buat grafik dengan Altair
669
- chart = alt.Chart(chart_data).mark_bar().encode(
670
  x=alt.X('Alternatif:N', sort=None, axis=alt.Axis(labelAngle=0), title="Alternatif"),
671
  y=alt.Y('Skor:Q', title="Skor Akhir"),
672
  tooltip=['Alternatif', alt.Tooltip('Skor', format='.3f')]
@@ -723,7 +720,7 @@ if run_calc:
723
  chart_data.columns = ['Alternatif', 'Skor']
724
 
725
  # Buat grafik dengan Altair
726
- chart = alt.Chart(chart_data).mark_bar().encode(
727
  x=alt.X('Alternatif:N', sort=None, axis=alt.Axis(labelAngle=0), title="Alternatif"),
728
  y=alt.Y('Skor:Q', title="Skor Preferensi"),
729
  tooltip=['Alternatif', alt.Tooltip('Skor', format='.3f')]
@@ -742,25 +739,7 @@ if run_calc:
742
  if df.isnull().values.any():
743
  st.error("Isi semua nilai alternatif terlebih dahulu.")
744
  else:
745
- # if use_standard_scaler_pm:
746
- # scaler = StandardScaler()
747
- # scaled_data = scaler.fit_transform(df.values.astype(float))
748
- # df_scaled = pd.DataFrame(scaled_data, index=alternatives, columns=criteria)
749
-
750
- # # Scale to 1-5 range after standard scaling
751
- # min_val = df_scaled.min().min()
752
- # max_val = df_scaled.max().max()
753
- # df_scaled = df_scaled.apply(lambda x: 1 + 4 * (x - min_val) / (max_val - min_val)).round(0).astype(int)
754
- # st.write("πŸ“Š Data setelah Standard Scaling dan konversi ke skala 1-5:")
755
- # ideal_values = ideal_profile.values.reshape(1,-1)
756
- # scaled_ideal= scaler.transform(ideal_values)
757
- # # Create scaled ideal profile
758
- # scaled_ideal_profile = pd.Series(
759
- # scaled_ideal.flatten(),
760
- # index=criteria,
761
- # name="Scaled Ideal"
762
- # )
763
- # ideal_profile = scaled_ideal_profile.copy()
764
 
765
 
766
  def scale_custom(value, criterion):
@@ -849,7 +828,7 @@ if run_calc:
849
  chart_data.columns = ['Alternatif', 'Skor']
850
 
851
  # Buat grafik dengan Altair
852
- chart = alt.Chart(chart_data).mark_bar().encode(
853
  x=alt.X('Alternatif:N', sort=None, axis=alt.Axis(labelAngle=0), title="Alternatif"),
854
  y=alt.Y('Skor:Q', title="Skor Akhir"),
855
  tooltip=['Alternatif', alt.Tooltip('Skor', format='.3f')]
 
47
  st.session_state.new_criterion_name = ""
48
  st.session_state.pairwise_matrix = {}
49
 
50
+ # Fungsi untuk menghapus kriteria
51
  def remove_criterion(idx):
52
  if len(st.session_state.criteria_list) > 1:
53
  st.session_state.criteria_list.pop(idx)
 
68
  # Menghapus format tebal dan miring agar konsisten
69
  st.write(criterion['name'])
70
  with col2:
 
71
  if st.button("πŸ—‘", key=f"remove_{i}", help="Hapus kriteria"):
72
  remove_criterion(i)
73
  st.rerun()
74
 
75
+ # Extract nama kriteria
76
  criteria = [c["name"] for c in st.session_state.criteria_list]
77
+ # --- Setup Alternatif ---
 
 
78
  st.sidebar.subheader("🏒 Manajemen Alternatif")
79
 
80
  default_alternatives = [
 
663
  chart_data.columns = ['Alternatif', 'Skor']
664
 
665
  # Buat grafik dengan Altair
666
+ chart = alt.Chart(chart_data).mark_bar(color='#00466e').encode(
667
  x=alt.X('Alternatif:N', sort=None, axis=alt.Axis(labelAngle=0), title="Alternatif"),
668
  y=alt.Y('Skor:Q', title="Skor Akhir"),
669
  tooltip=['Alternatif', alt.Tooltip('Skor', format='.3f')]
 
720
  chart_data.columns = ['Alternatif', 'Skor']
721
 
722
  # Buat grafik dengan Altair
723
+ chart = alt.Chart(chart_data).mark_bar(color='#00466e').encode(
724
  x=alt.X('Alternatif:N', sort=None, axis=alt.Axis(labelAngle=0), title="Alternatif"),
725
  y=alt.Y('Skor:Q', title="Skor Preferensi"),
726
  tooltip=['Alternatif', alt.Tooltip('Skor', format='.3f')]
 
739
  if df.isnull().values.any():
740
  st.error("Isi semua nilai alternatif terlebih dahulu.")
741
  else:
742
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743
 
744
 
745
  def scale_custom(value, criterion):
 
828
  chart_data.columns = ['Alternatif', 'Skor']
829
 
830
  # Buat grafik dengan Altair
831
+ chart = alt.Chart(chart_data).mark_bar(color='#00466e').encode(
832
  x=alt.X('Alternatif:N', sort=None, axis=alt.Axis(labelAngle=0), title="Alternatif"),
833
  y=alt.Y('Skor:Q', title="Skor Akhir"),
834
  tooltip=['Alternatif', alt.Tooltip('Skor', format='.3f')]