aliicemill commited on
Commit
830e866
·
verified ·
1 Parent(s): 4b2eabe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -116
app.py CHANGED
@@ -4,29 +4,27 @@ import numpy as np
4
  import matplotlib.pyplot as plt
5
  from io import BytesIO
6
 
7
- # CSS ile sidebar sabitle
8
- st.markdown(
9
- """
10
  <style>
11
- [data-testid="stSidebar"] {
12
- position: fixed;
13
- top: 0;
14
- height: 100%;
15
- }
 
16
  </style>
17
- """,
18
- unsafe_allow_html=True,
19
- )
20
 
21
- # Başlık
22
- st.title("Note Analyzer Streamlit Uygulaması")
 
23
 
24
- # Durum değişkeni (başlangıçta False)
25
- if "analysis_started" not in st.session_state:
26
- st.session_state.analysis_started = False
27
 
28
- # "Uygulamanın Çalışma Prensibi" sadece analiz başlamadan önce gösterilir
29
- if not st.session_state.analysis_started:
30
  st.subheader("Uygulamanın Çalışma Prensibi")
31
 
32
  # Resimlerin dosya isimlerini sırayla listele
@@ -34,9 +32,9 @@ if not st.session_state.analysis_started:
34
 
35
  # Resimleri alt alta ekle
36
  for image_file in image_files:
37
- st.image(image_file, use_container_width=True)
38
 
39
- # Sidebar: Kullanıcıdan veri alma
40
  st.sidebar.header("Girdi Alanları")
41
 
42
  # Dosya yükleme veya metin girişi seçimi
@@ -62,100 +60,12 @@ amount_s_axis_diff = st.sidebar.number_input("Miktar Y Ekseni Ortak Farkı", val
62
  first_step = st.sidebar.number_input("İlk Adım", value=0, step=1)
63
  increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
64
 
65
- # Analiz butonuna basıldığında durum değişkenini True yapar ve çıktıları gösterir
66
  if st.sidebar.button("Analizi Çalıştır"):
67
- st.session_state.analysis_started = True
68
-
69
- if input_method == "Dosya Yükle" and uploaded_file is None:
70
- st.error("Lütfen bir dosya yükleyin!")
71
- elif input_method == "Kopyala-Yapıştır" and not text_input:
72
- st.error("Lütfen notları metin kutusuna yapıştırın!")
73
- else:
74
- try:
75
- # Dosya veya metin kutusundan içerik okuma
76
- if uploaded_file:
77
- content = uploaded_file.read().decode("utf-8")
78
- elif text_input:
79
- content = text_input
80
-
81
- # Veriyi işleme
82
- result = re.split(r'[ \n]+', content)
83
- notes_result = result[first_step::increase_amount]
84
- notes_result = [x for x in notes_result if x != '∅' and x != "NA"]
85
- notes_result = list(map(lambda x: float(x), notes_result))
86
- notes_result = np.array(notes_result)
87
-
88
- # İstatistikler
89
- average_x = np.average(notes_result)
90
- min_x = notes_result.min()
91
- max_x = notes_result.max()
92
- std = np.std(notes_result)
93
- z_score = (my_note - average_x) / std
94
-
95
- # İstatistikleri ekrana yazdırma
96
- st.subheader("Genel Bilgiler")
97
- st.write(f"Katilimci Sayısı: {len(notes_result)}")
98
- st.write(f"En Düşük Not: {min_x:.2f}")
99
- st.write(f"En Yüksek Not: {max_x:.2f}")
100
- st.write(f"Ortalama Not: {average_x:.2f}")
101
- st.write(f"Standart Sapma: {std:.2f}")
102
- st.write(f"Z-Skoru: {z_score:.2f}")
103
-
104
- # Grafik oluşturma
105
- st.subheader("Not Dağılım Grafiği")
106
- unique_values, counts = np.unique(notes_result, return_counts=True)
107
- plt.figure(figsize=(10, 6))
108
- bars = plt.bar(unique_values, counts, width=0.3)
109
- plt.axvline(x=average_x, color='red', linestyle='--')
110
- plt.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
111
-
112
- if my_note in unique_values:
113
- plt.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
114
-
115
- for bar in bars:
116
- if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
117
- bar.set_color('green')
118
-
119
- plt.title(f'{lecture_name} Not Sayıları Grafiği')
120
- plt.xlabel('Notlar')
121
- plt.ylabel('Adet')
122
- plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
123
- plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
124
-
125
- # Grafik bilgileri
126
- info_text = (
127
- f"Katilimci sayısı: {len(notes_result)}\n"
128
- f"En düşük not: {min_x:.2f}\n"
129
- f"En yüksek not: {max_x:.2f}\n"
130
- f"Benim notum: {my_note:.2f}\n"
131
- f"Ortalama not: {average_x:.2f}\n"
132
- f"Standart sapma: {std:.2f}\n"
133
- f"Z-skoru: {z_score:.2f}"
134
- )
135
- plt.text(
136
- 1.05 * max(unique_values), 0.8 * max(counts),
137
- info_text,
138
- fontsize=10,
139
- color="black",
140
- ha="left",
141
- va="top",
142
- bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
143
- )
144
- plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
145
-
146
- # Grafik gösterimi
147
- st.pyplot(plt)
148
-
149
- # Grafik indirme bağlantısı
150
- buf = BytesIO()
151
- plt.savefig(buf, format="png")
152
- buf.seek(0)
153
- st.download_button(
154
- label="Grafiği İndir",
155
- data=buf,
156
- file_name="not_dagilimi.png",
157
- mime="image/png"
158
- )
159
-
160
- except Exception as e:
161
- st.error(f"Hata: {e}")
 
4
  import matplotlib.pyplot as plt
5
  from io import BytesIO
6
 
7
+ # CSS ile kaydırılabilir sidebar oluşturma
8
+ st.markdown("""
 
9
  <style>
10
+ [data-testid="stSidebar"] {
11
+ position: fixed;
12
+ top: 0;
13
+ height: 100vh;
14
+ overflow: auto;
15
+ }
16
  </style>
17
+ """, unsafe_allow_html=True)
 
 
18
 
19
+ # "Analizi Çalıştır" butonuna basıldı mı kontrolü
20
+ if "analysis_run" not in st.session_state:
21
+ st.session_state.analysis_run = False
22
 
23
+ # Başlık
24
+ if not st.session_state.analysis_run:
25
+ st.title("Note Analyzer Streamlit Uygulaması")
26
 
27
+ # Açıklama Resimleri
 
28
  st.subheader("Uygulamanın Çalışma Prensibi")
29
 
30
  # Resimlerin dosya isimlerini sırayla listele
 
32
 
33
  # Resimleri alt alta ekle
34
  for image_file in image_files:
35
+ st.image(image_file, use_container_width=True) # Yeni parametre kullanıldı
36
 
37
+ # Kullanıcıdan veri alma (Sidebar sabit kalıyor)
38
  st.sidebar.header("Girdi Alanları")
39
 
40
  # Dosya yükleme veya metin girişi seçimi
 
60
  first_step = st.sidebar.number_input("İlk Adım", value=0, step=1)
61
  increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
62
 
 
63
  if st.sidebar.button("Analizi Çalıştır"):
64
+ st.session_state.analysis_run = True
65
+ # Analiz işlemleri buradan itibaren devam edecek...
66
+
67
+ # Analiz çıktıları aşağıda yer alır.
68
+ if st.session_state.analysis_run:
69
+ # Analiz kodunu buraya yaz
70
+ st.subheader("Analiz Sonuçları")
71
+ st.write("Burada analiz sonuçları görüntülenecek.")