Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,84 +3,13 @@ import numpy as np
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
from io import BytesIO
|
| 5 |
import streamlit as st
|
| 6 |
-
import os
|
| 7 |
-
|
| 8 |
-
# Dil Seçimi
|
| 9 |
-
language = st.selectbox("Select Language / اختر اللغة / Seçiniz", ["Türkçe", "English", "عربي"])
|
| 10 |
-
|
| 11 |
-
# Dil Desteği İçin Metinler ve Görseller
|
| 12 |
-
if language == "Türkçe":
|
| 13 |
-
title_text = "Not Analyzer Streamlit Uygulaması"
|
| 14 |
-
subheader_text = "Uygulamanın Çalışma Prensibi"
|
| 15 |
-
error_message = "Lütfen bir dosya yükleyin!" # Başlangıçta error_message boş olacak
|
| 16 |
-
participant_text = "Katilimci Sayısı"
|
| 17 |
-
min_text = "En Düşük Not"
|
| 18 |
-
max_text = "En Yüksek Not"
|
| 19 |
-
avg_text = "Ortalama Not"
|
| 20 |
-
std_dev_text = "Standart Sapma"
|
| 21 |
-
z_score_text = "Z-Skoru"
|
| 22 |
-
download_text = "Grafiği İndir"
|
| 23 |
-
info_text_header = "Genel Bilgiler"
|
| 24 |
-
chart_title = "{lecture_name} Not Sayıları Grafiği"
|
| 25 |
-
xlabel = "Notlar"
|
| 26 |
-
ylabel = "Adet"
|
| 27 |
-
image_folder = "turkish" # Türkçe için resim klasörü
|
| 28 |
-
elif language == "English":
|
| 29 |
-
title_text = "Note Analyzer Streamlit Application"
|
| 30 |
-
subheader_text = "How the Application Works"
|
| 31 |
-
error_message = "Please upload a file!" # Başlangıçta error_message boş olacak
|
| 32 |
-
participant_text = "Number of Participants"
|
| 33 |
-
min_text = "Lowest Grade"
|
| 34 |
-
max_text = "Highest Grade"
|
| 35 |
-
avg_text = "Average Grade"
|
| 36 |
-
std_dev_text = "Standard Deviation"
|
| 37 |
-
z_score_text = "Z-Score"
|
| 38 |
-
download_text = "Download Graph"
|
| 39 |
-
info_text_header = "General Information"
|
| 40 |
-
chart_title = "{lecture_name} Grade Distribution Graph"
|
| 41 |
-
xlabel = "Grades"
|
| 42 |
-
ylabel = "Count"
|
| 43 |
-
image_folder = "english" # English için resim klasörü
|
| 44 |
-
else: # Arabic
|
| 45 |
-
title_text = "تطبيق تحليل الدرجات"
|
| 46 |
-
subheader_text = "مبدأ عمل التطبيق"
|
| 47 |
-
error_message = "من فضلك حمّل ملفًا!" # Başlangıçta error_message boş olacak
|
| 48 |
-
participant_text = "عدد المشاركين"
|
| 49 |
-
min_text = "أدنى درجة"
|
| 50 |
-
max_text = "أعلى درجة"
|
| 51 |
-
avg_text = "متوسط الدرجة"
|
| 52 |
-
std_dev_text = "الانحراف المعياري"
|
| 53 |
-
z_score_text = "الدرجة Z"
|
| 54 |
-
download_text = "تنزيل الرسم البياني"
|
| 55 |
-
info_text_header = "المعلومات العامة"
|
| 56 |
-
chart_title = "{lecture_name} الرسم البياني لتوزيع الدرجات"
|
| 57 |
-
xlabel = "الدرجات"
|
| 58 |
-
ylabel = "العدد"
|
| 59 |
-
image_folder = "arabic" # Arabic için resim klasörü
|
| 60 |
-
|
| 61 |
-
# Resim Dosya Yolları
|
| 62 |
-
image_files = [f"{image_folder}/{ch}.png" for ch in ['a', 'b', 'c', 'd', 'e', 'f', 'g']]
|
| 63 |
|
| 64 |
# Başlık
|
| 65 |
-
st.title(
|
| 66 |
-
|
| 67 |
-
# Açıklama ve Görselleri Gösterme (butona basılmadan önce)
|
| 68 |
-
show_intro = st.checkbox("Uygulamanın Çalışma Prensibi", value=True)
|
| 69 |
-
|
| 70 |
-
if show_intro:
|
| 71 |
-
st.subheader(subheader_text)
|
| 72 |
-
|
| 73 |
-
# Resimleri alt alta ekle
|
| 74 |
-
for image_file in image_files:
|
| 75 |
-
if os.path.exists(image_file):
|
| 76 |
-
st.image(image_file, use_container_width=True) # Yeni parametre kullanıldı
|
| 77 |
|
| 78 |
# Kullanıcıdan veri alma (Sidebar sabit kalıyor)
|
| 79 |
-
st.sidebar.header(
|
| 80 |
-
|
| 81 |
-
# Dosya yükleme veya metin girişi seçimi
|
| 82 |
-
input_method = st.sidebar.radio("Notları nasıl gireceksiniz?", options=[error_message, "Kopyala-Yapıştır"])
|
| 83 |
-
|
| 84 |
uploaded_file = None
|
| 85 |
text_input = None
|
| 86 |
|
|
@@ -89,7 +18,6 @@ if input_method == "Dosya Yükle":
|
|
| 89 |
elif input_method == "Kopyala-Yapıştır":
|
| 90 |
text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
|
| 91 |
|
| 92 |
-
# Diğer parametreler
|
| 93 |
lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
|
| 94 |
perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
|
| 95 |
my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
|
|
@@ -100,9 +28,9 @@ increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
|
|
| 100 |
|
| 101 |
if st.sidebar.button("Analizi Çalıştır"):
|
| 102 |
if input_method == "Dosya Yükle" and uploaded_file is None:
|
| 103 |
-
st.error(
|
| 104 |
elif input_method == "Kopyala-Yapıştır" and not text_input:
|
| 105 |
-
st.error(
|
| 106 |
else:
|
| 107 |
try:
|
| 108 |
if uploaded_file:
|
|
@@ -124,13 +52,13 @@ if st.sidebar.button("Analizi Çalıştır"):
|
|
| 124 |
std = np.std(notes_result)
|
| 125 |
z_score = (my_note - average_x) / std
|
| 126 |
|
| 127 |
-
st.subheader(
|
| 128 |
-
st.write(f"
|
| 129 |
-
st.write(f"
|
| 130 |
-
st.write(f"
|
| 131 |
-
st.write(f"
|
| 132 |
-
st.write(f"
|
| 133 |
-
st.write(f"
|
| 134 |
|
| 135 |
# Grafik oluşturma
|
| 136 |
unique_values, counts = np.unique(notes_result, return_counts=True)
|
|
@@ -138,28 +66,29 @@ if st.sidebar.button("Analizi Çalıştır"):
|
|
| 138 |
|
| 139 |
bars = ax.bar(unique_values, counts, width=0.3)
|
| 140 |
ax.axvline(x=average_x, color='red', linestyle='--')
|
| 141 |
-
ax.text(average_x + 1.5, max(counts),
|
| 142 |
|
| 143 |
if my_note in unique_values:
|
| 144 |
-
ax.text(my_note, counts[unique_values == my_note][0],
|
| 145 |
|
| 146 |
for bar in bars:
|
| 147 |
if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
|
| 148 |
bar.set_color('green')
|
| 149 |
|
| 150 |
-
ax.set_title(f'{lecture_name}
|
| 151 |
-
ax.set_xlabel(
|
| 152 |
-
ax.set_ylabel(
|
| 153 |
ax.set_xticks(range(0, int(perfect_score), note_s_axis_diff))
|
| 154 |
ax.set_yticks(range(0, max(counts), amount_s_axis_diff))
|
| 155 |
|
| 156 |
info_text = (
|
| 157 |
-
f"
|
| 158 |
-
f"
|
| 159 |
-
f"
|
| 160 |
-
f"
|
| 161 |
-
f"
|
| 162 |
-
f"
|
|
|
|
| 163 |
)
|
| 164 |
ax.text(
|
| 165 |
1.05 * max(unique_values), 0.8 * max(counts),
|
|
@@ -177,11 +106,11 @@ if st.sidebar.button("Analizi Çalıştır"):
|
|
| 177 |
buf.seek(0)
|
| 178 |
|
| 179 |
st.download_button(
|
| 180 |
-
label=
|
| 181 |
data=buf,
|
| 182 |
file_name="not_dagilimi.png",
|
| 183 |
mime="image/png"
|
| 184 |
)
|
| 185 |
|
| 186 |
except Exception as e:
|
| 187 |
-
st.error(f"Hata: {e}")
|
|
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
from io import BytesIO
|
| 5 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Başlık
|
| 8 |
+
st.title("Note Analyzer Streamlit Uygulaması")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Kullanıcıdan veri alma (Sidebar sabit kalıyor)
|
| 11 |
+
st.sidebar.header("Girdi Alanları")
|
| 12 |
+
input_method = st.sidebar.radio("Notları nasıl gireceksiniz?", options=["Dosya Yükle", "Kopyala-Yapıştır"])
|
|
|
|
|
|
|
|
|
|
| 13 |
uploaded_file = None
|
| 14 |
text_input = None
|
| 15 |
|
|
|
|
| 18 |
elif input_method == "Kopyala-Yapıştır":
|
| 19 |
text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
|
| 20 |
|
|
|
|
| 21 |
lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
|
| 22 |
perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
|
| 23 |
my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
|
|
|
|
| 28 |
|
| 29 |
if st.sidebar.button("Analizi Çalıştır"):
|
| 30 |
if input_method == "Dosya Yükle" and uploaded_file is None:
|
| 31 |
+
st.error("Lütfen bir dosya yükleyin!")
|
| 32 |
elif input_method == "Kopyala-Yapıştır" and not text_input:
|
| 33 |
+
st.error("Lütfen notları metin kutusuna yapıştırın!")
|
| 34 |
else:
|
| 35 |
try:
|
| 36 |
if uploaded_file:
|
|
|
|
| 52 |
std = np.std(notes_result)
|
| 53 |
z_score = (my_note - average_x) / std
|
| 54 |
|
| 55 |
+
st.subheader("Genel Bilgiler")
|
| 56 |
+
st.write(f"Katilimci Sayısı: {len(notes_result)}")
|
| 57 |
+
st.write(f"En Düşük Not: {min_x:.2f}")
|
| 58 |
+
st.write(f"En Yüksek Not: {max_x:.2f}")
|
| 59 |
+
st.write(f"Ortalama Not: {average_x:.2f}")
|
| 60 |
+
st.write(f"Standart Sapma: {std:.2f}")
|
| 61 |
+
st.write(f"Z-Skoru: {z_score:.2f}")
|
| 62 |
|
| 63 |
# Grafik oluşturma
|
| 64 |
unique_values, counts = np.unique(notes_result, return_counts=True)
|
|
|
|
| 66 |
|
| 67 |
bars = ax.bar(unique_values, counts, width=0.3)
|
| 68 |
ax.axvline(x=average_x, color='red', linestyle='--')
|
| 69 |
+
ax.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
|
| 70 |
|
| 71 |
if my_note in unique_values:
|
| 72 |
+
ax.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
|
| 73 |
|
| 74 |
for bar in bars:
|
| 75 |
if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
|
| 76 |
bar.set_color('green')
|
| 77 |
|
| 78 |
+
ax.set_title(f'{lecture_name} Not Sayıları Grafiği')
|
| 79 |
+
ax.set_xlabel('Notlar')
|
| 80 |
+
ax.set_ylabel('Adet')
|
| 81 |
ax.set_xticks(range(0, int(perfect_score), note_s_axis_diff))
|
| 82 |
ax.set_yticks(range(0, max(counts), amount_s_axis_diff))
|
| 83 |
|
| 84 |
info_text = (
|
| 85 |
+
f"Katilimci sayısı: {len(notes_result)}\n"
|
| 86 |
+
f"En düşük not: {min_x:.2f}\n"
|
| 87 |
+
f"En yüksek not: {max_x:.2f}\n"
|
| 88 |
+
f"Benim notum: {my_note:.2f}\n"
|
| 89 |
+
f"Ortalama not: {average_x:.2f}\n"
|
| 90 |
+
f"Standart sapma: {std:.2f}\n"
|
| 91 |
+
f"Z-skoru: {z_score:.2f}"
|
| 92 |
)
|
| 93 |
ax.text(
|
| 94 |
1.05 * max(unique_values), 0.8 * max(counts),
|
|
|
|
| 106 |
buf.seek(0)
|
| 107 |
|
| 108 |
st.download_button(
|
| 109 |
+
label="Grafiği İndir",
|
| 110 |
data=buf,
|
| 111 |
file_name="not_dagilimi.png",
|
| 112 |
mime="image/png"
|
| 113 |
)
|
| 114 |
|
| 115 |
except Exception as e:
|
| 116 |
+
st.error(f"Hata: {e}")
|