aliicemill commited on
Commit
267a919
·
verified ·
1 Parent(s): 0221b4a

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -163
app.py DELETED
@@ -1,163 +0,0 @@
1
- import streamlit as st
2
- import re
3
- import numpy as np
4
- import matplotlib.pyplot as plt
5
- from io import BytesIO
6
-
7
- # Başlık
8
- st.title("Note Analyzer Streamlit Uygulaması")
9
-
10
- # Uygulamanın çalışma prensibi görüntüleme durumu
11
- if "show_images" not in st.session_state:
12
- st.session_state.show_images = True # Varsayılan olarak resimler gösterilsin
13
-
14
- # Kullanıcıdan veri alma (Sidebar sabit kalıyor)
15
- st.sidebar.header("Girdi Alanları")
16
-
17
- # Dosya yükleme veya metin girişi seçimi
18
- input_method = st.sidebar.radio(
19
- "Notları nasıl gireceksiniz?",
20
- options=["Dosya Yükle", "Kopyala-Yapıştır"]
21
- )
22
-
23
- uploaded_file = None
24
- text_input = None
25
-
26
- if input_method == "Dosya Yükle":
27
- uploaded_file = st.sidebar.file_uploader("Notlar Dosyasını Yükleyin (TXT)", type=["txt"])
28
- elif input_method == "Kopyala-Yapıştır":
29
- text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
30
-
31
- # Diğer parametreler
32
- lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
33
- perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
34
- my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
35
- note_s_axis_diff = st.sidebar.number_input("Notlar X Ekseni Ortak Farkı", value=5, step=1)
36
- amount_s_axis_diff = st.sidebar.number_input("Miktar Y Ekseni Ortak Farkı", value=1, step=1)
37
- first_step = st.sidebar.number_input("İlk Adım", value=0, step=1)
38
- increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
39
-
40
- if st.sidebar.button("Analizi Çalıştır"):
41
- # Butona basıldığında resimleri gizle
42
- st.session_state.show_images = False
43
-
44
- # Resimler yalnızca show_images True ise gösterilir
45
- if st.session_state.show_images:
46
- st.subheader("Uygulamanın Çalışma Prensibi")
47
-
48
- # Resimlerin dosya isimlerini sırayla listele
49
- image_files = ["turkish/a.png", "turkish/b.png", "turkish/c.png", "turkish/d.png"]
50
-
51
- # Resimleri alt alta ekle
52
- for image_file in image_files:
53
- st.image(image_file, use_container_width=True)
54
-
55
- # Notları yükleme ve işleme işlemleri (Butona basıldıysa çalışır)
56
- if not st.session_state.show_images:
57
- if input_method == "Dosya Yükle" and uploaded_file is None:
58
- st.error("Lütfen bir dosya yükleyin!")
59
- elif input_method == "Kopyala-Yapıştır" and not text_input:
60
- st.error("Lütfen notları metin kutusuna yapıştırın!")
61
- else:
62
- try:
63
- # Dosya veya metin kutusundan içerik okuma
64
- if uploaded_file:
65
- content = uploaded_file.read().decode("utf-8")
66
- elif text_input:
67
- content = text_input
68
-
69
- # Veriyi işleme
70
- result = re.split(r'[ \n]+', content)
71
-
72
- # Strip fonksiyonu ve kaçış dizisi temizliği
73
- notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
74
- notes_result = list(map(lambda x: float(x), notes_result))
75
- notes_result = np.array(notes_result)
76
-
77
- # İstatistikler
78
- average_x = np.average(notes_result)
79
- min_x = notes_result.min()
80
- max_x = notes_result.max()
81
- std = np.std(notes_result)
82
- z_score = (my_note - average_x) / std
83
-
84
- # İstatistikleri ekrana yazdırma
85
- st.subheader("Genel Bilgiler")
86
- st.write(f"Katilimci Sayısı: {len(notes_result)}")
87
- st.write(f"En Düşük Not: {min_x:.2f}")
88
- st.write(f"En Yüksek Not: {max_x:.2f}")
89
- st.write(f"Ortalama Not: {average_x:.2f}")
90
- st.write(f"Standart Sapma: {std:.2f}")
91
- st.write(f"Z-Skoru: {z_score:.2f}")
92
-
93
- # Grafik oluşturma
94
- st.subheader("Not Dağılım Grafiği")
95
- unique_values, counts = np.unique(notes_result, return_counts=True)
96
- plt.figure(figsize=(10, 6))
97
- bars = plt.bar(unique_values, counts, width=0.3)
98
- plt.axvline(x=average_x, color='red', linestyle='--')
99
- plt.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
100
-
101
- if my_note in unique_values:
102
- plt.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
103
-
104
- for bar in bars:
105
- if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
106
- bar.set_color('green')
107
-
108
- plt.title(f'{lecture_name} Not Sayıları Grafiği')
109
- plt.xlabel('Notlar')
110
- plt.ylabel('Adet')
111
- plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
112
- plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
113
-
114
- # Grafik bilgileri
115
- info_text = (
116
- f"Katilimci sayısı: {len(notes_result)}\n"
117
- f"En düşük not: {min_x:.2f}\n"
118
- f"En yüksek not: {max_x:.2f}\n"
119
- f"Benim notum: {my_note:.2f}\n"
120
- f"Ortalama not: {average_x:.2f}\n"
121
- f"Standart sapma: {std:.2f}\n"
122
- f"Z-skoru: {z_score:.2f}"
123
- )
124
- plt.text(
125
- 1.05 * max(unique_values), 0.8 * max(counts),
126
- info_text,
127
- fontsize=10,
128
- color="black",
129
- ha="left",
130
- va="top",
131
- bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
132
- )
133
- plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
134
-
135
- # Grafik gösterimi
136
- st.pyplot(plt)
137
-
138
- # Grafik indirme bağlantısı
139
- buf = BytesIO()
140
- plt.savefig(buf, format="png")
141
- buf.seek(0)
142
- st.download_button(
143
- label="Grafiği İndir",
144
- data=buf,
145
- file_name="not_dagilimi.png",
146
- mime="image/png"
147
- )
148
-
149
- except Exception as e:
150
- st.error(f"Hata: {e}")
151
-
152
- # Web sayfasının altına isim ve tarih
153
- st.markdown("---")
154
- st.write("Developed by: Ali Cemil Özdemir")
155
- st.write("Date: 01.12.2024")
156
- st.write("For feedback and suggestions, you can contact me at alicemilozdemir7@gmail.com")
157
-
158
- # Grafiklerin sağ alt köşesine yazı ekleme
159
- st.markdown("""
160
- <p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
161
- Created with Note Analyzer
162
- </p>
163
- """, unsafe_allow_html=True)