Varriety commited on
Commit
0f7c6ec
ยท
verified ยท
1 Parent(s): 9051a0b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +23 -24
src/streamlit_app.py CHANGED
@@ -361,7 +361,7 @@ with col_btn1:
361
  is_uji = st.session_state.page == "uji_kalimat"
362
  css_class = "btn-orange" if is_uji else "btn-ghost"
363
  st.markdown(f'<div class="{css_class}">', unsafe_allow_html=True)
364
- if st.button("๐Ÿ“ Uji Kalimat", use_container_width=True, key="nav_uji"):
365
  set_page("uji_kalimat"); st.rerun()
366
  st.markdown('</div>', unsafe_allow_html=True)
367
 
@@ -369,7 +369,7 @@ with col_btn2:
369
  is_batch = st.session_state.page == "analisis_batch"
370
  css_class = "btn-orange" if is_batch else "btn-ghost"
371
  st.markdown(f'<div class="{css_class}">', unsafe_allow_html=True)
372
- if st.button("๐Ÿ“Š Analisis Batch", use_container_width=True, key="nav_batch"):
373
  set_page("analisis_batch"); st.rerun()
374
  st.markdown('</div>', unsafe_allow_html=True)
375
 
@@ -580,11 +580,11 @@ elif st.session_state.page == "analisis_batch":
580
 
581
  with col_upload:
582
  st.markdown("""
583
- <p class="batch-eyebrow">Analisis Masal ยท Batch Processing</p>
584
  <h2 class="batch-title">Analisis Batch<br>Data Tweet</h2>
585
  <p class="batch-sub">
586
- Unggah file rekam jejak tweet (.txt) untuk diekstraksi dan
587
- dianalisis secara masal terhadap volatilitas pasar Bitcoin.
588
  </p>""", unsafe_allow_html=True)
589
 
590
  tweet_files = st.file_uploader(
@@ -608,7 +608,6 @@ elif st.session_state.page == "analisis_batch":
608
  st.markdown('</div>', unsafe_allow_html=True)
609
 
610
  with col_img_b:
611
- # Menambahkan margin-top agar gambar agak ke bawah
612
  st.markdown("<div style='margin-top: 4rem;'></div>", unsafe_allow_html=True)
613
  try:
614
  st.image(img_batch, use_container_width=True)
@@ -734,7 +733,7 @@ elif st.session_state.page == "analisis_batch":
734
  else:
735
  st.markdown("<hr class='vbc-divider'>", unsafe_allow_html=True)
736
 
737
- st.markdown("๐Ÿ—ฃ๏ธ Data Sentimen Mentah")
738
  raw_display_cols = ["date","raw_tweet","vader","textblob","bertweet","roberta","roberta_large"]
739
  st.dataframe(df[raw_display_cols], use_container_width=True, hide_index=True)
740
 
@@ -754,12 +753,12 @@ elif st.session_state.page == "analisis_batch":
754
  for col in models:
755
  daily_display_cols.extend([col, f"{col}_label"])
756
 
757
- st.markdown("โ‚ฟ Historis Harga & Volatilitas Bitcoin")
758
  st.dataframe(df_price[["date","price","pct_change","log_return"]], use_container_width=True, hide_index=True)
759
 
760
  df_merged = pd.merge(df_price, df_sentiment_daily, on="date", how="inner")
761
 
762
- st.markdown("๐Ÿ—‚๏ธ Dataset Final (Terintegrasi)")
763
  final_display_cols = ["date","price","pct_change","log_return"] + [c for c in daily_display_cols if c != "date"]
764
  st.dataframe(df_merged[final_display_cols], use_container_width=True, hide_index=True)
765
 
@@ -790,22 +789,8 @@ elif st.session_state.page == "analisis_batch":
790
 
791
  st.table(pd.DataFrame(corr_data))
792
 
793
- # Line chart
794
- st.subheader("๐Ÿ“ˆ Trend Analisis: Sentiment vs BTC Volatility")
795
- fig_line, ax_line = plt.subplots(figsize=(14, 6))
796
- ax_line.plot(df_merged["date"], df_merged["log_return"], label="BTC Log Return", color="#f7931a", linewidth=3)
797
- colors = ["#3B82F6","#10B981","#EC4899","#14B8A6","#6366F1"]
798
- for i, method in enumerate(["vader","textblob","roberta","roberta_large","bertweet"]):
799
- ax_line.plot(df_merged["date"], df_merged[method], label=f"Sentiment: {method.upper()}", color=colors[i], linewidth=1.5, linestyle="--", alpha=0.8)
800
- ax_line.set_title("Pergerakan Sentimen vs Log Return Bitcoin", fontsize=14, pad=15, fontweight='bold')
801
- ax_line.set_xlabel("Tanggal", fontsize=11)
802
- ax_line.set_ylabel("Nilai Metrik", fontsize=11)
803
- ax_line.legend(loc='upper left', bbox_to_anchor=(1, 1), frameon=True)
804
- plt.tight_layout()
805
- st.pyplot(fig_line)
806
-
807
  # Scatter
808
- st.markdown("### ๐Ÿ”ต Pola Distribusi Scatter")
809
  cols = st.columns(3)
810
  for idx2, method in enumerate(["vader","textblob","bertweet","roberta","roberta_large"]):
811
  with cols[idx2 % 3]:
@@ -819,6 +804,20 @@ elif st.session_state.page == "analisis_batch":
819
  plt.tight_layout()
820
  st.pyplot(fig_s)
821
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
822
  # Kesimpulan
823
  st.markdown("<hr class='vbc-divider'>", unsafe_allow_html=True)
824
  st.subheader("๐Ÿ“ Kesimpulan Otomatis")
 
361
  is_uji = st.session_state.page == "uji_kalimat"
362
  css_class = "btn-orange" if is_uji else "btn-ghost"
363
  st.markdown(f'<div class="{css_class}">', unsafe_allow_html=True)
364
+ if st.button("Uji Kalimat", use_container_width=True, key="nav_uji"):
365
  set_page("uji_kalimat"); st.rerun()
366
  st.markdown('</div>', unsafe_allow_html=True)
367
 
 
369
  is_batch = st.session_state.page == "analisis_batch"
370
  css_class = "btn-orange" if is_batch else "btn-ghost"
371
  st.markdown(f'<div class="{css_class}">', unsafe_allow_html=True)
372
+ if st.button("Analisis Batch", use_container_width=True, key="nav_batch"):
373
  set_page("analisis_batch"); st.rerun()
374
  st.markdown('</div>', unsafe_allow_html=True)
375
 
 
580
 
581
  with col_upload:
582
  st.markdown("""
583
+ <p class="batch-eyebrow">Analisis Batch Processing</p>
584
  <h2 class="batch-title">Analisis Batch<br>Data Tweet</h2>
585
  <p class="batch-sub">
586
+ Unggah file tweets (.txt) untuk diekstraksi dan
587
+ dianalisis terhadap volatilitas harga Bitcoin.
588
  </p>""", unsafe_allow_html=True)
589
 
590
  tweet_files = st.file_uploader(
 
608
  st.markdown('</div>', unsafe_allow_html=True)
609
 
610
  with col_img_b:
 
611
  st.markdown("<div style='margin-top: 4rem;'></div>", unsafe_allow_html=True)
612
  try:
613
  st.image(img_batch, use_container_width=True)
 
733
  else:
734
  st.markdown("<hr class='vbc-divider'>", unsafe_allow_html=True)
735
 
736
+ st.markdown("๐Ÿ—ฃ๏ธ Data Sentimen")
737
  raw_display_cols = ["date","raw_tweet","vader","textblob","bertweet","roberta","roberta_large"]
738
  st.dataframe(df[raw_display_cols], use_container_width=True, hide_index=True)
739
 
 
753
  for col in models:
754
  daily_display_cols.extend([col, f"{col}_label"])
755
 
756
+ st.markdown("โ‚ฟ Data Harga & Volatilitas Bitcoin")
757
  st.dataframe(df_price[["date","price","pct_change","log_return"]], use_container_width=True, hide_index=True)
758
 
759
  df_merged = pd.merge(df_price, df_sentiment_daily, on="date", how="inner")
760
 
761
+ st.markdown("๐Ÿ—‚๏ธ Data Final")
762
  final_display_cols = ["date","price","pct_change","log_return"] + [c for c in daily_display_cols if c != "date"]
763
  st.dataframe(df_merged[final_display_cols], use_container_width=True, hide_index=True)
764
 
 
789
 
790
  st.table(pd.DataFrame(corr_data))
791
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
792
  # Scatter
793
+ st.markdown("๐Ÿ”ต Pola Distribusi Scatter Plot")
794
  cols = st.columns(3)
795
  for idx2, method in enumerate(["vader","textblob","bertweet","roberta","roberta_large"]):
796
  with cols[idx2 % 3]:
 
804
  plt.tight_layout()
805
  st.pyplot(fig_s)
806
 
807
+ # Line chart
808
+ st.subheader("๐Ÿ“ˆ Trend Analisis: Sentiment vs BTC Volatility")
809
+ fig_line, ax_line = plt.subplots(figsize=(14, 6))
810
+ ax_line.plot(df_merged["date"], df_merged["log_return"], label="BTC Log Return", color="#f7931a", linewidth=3)
811
+ colors = ["#3B82F6","#10B981","#EC4899","#14B8A6","#6366F1"]
812
+ for i, method in enumerate(["vader","textblob","roberta","roberta_large","bertweet"]):
813
+ ax_line.plot(df_merged["date"], df_merged[method], label=f"Sentiment: {method.upper()}", color=colors[i], linewidth=1.5, linestyle="--", alpha=0.8)
814
+ ax_line.set_title("Pergerakan Sentimen vs Log Return Bitcoin", fontsize=14, pad=15, fontweight='bold')
815
+ ax_line.set_xlabel("Tanggal", fontsize=11)
816
+ ax_line.set_ylabel("Nilai Metrik", fontsize=11)
817
+ ax_line.legend(loc='upper left', bbox_to_anchor=(1, 1), frameon=True)
818
+ plt.tight_layout()
819
+ st.pyplot(fig_line)
820
+
821
  # Kesimpulan
822
  st.markdown("<hr class='vbc-divider'>", unsafe_allow_html=True)
823
  st.subheader("๐Ÿ“ Kesimpulan Otomatis")