Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +109 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Kullanıcıdan veri alma
|
| 11 |
+
st.sidebar.header("Girdi Alanları")
|
| 12 |
+
uploaded_file = st.sidebar.file_uploader("Notlar Dosyasını Yükleyin (TXT)", type=["txt"])
|
| 13 |
+
lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
|
| 14 |
+
perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
|
| 15 |
+
my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
|
| 16 |
+
note_s_axis_diff = st.sidebar.number_input("Notlar X Ekseni Ortak Farkı", value=5, step=1)
|
| 17 |
+
amount_s_axis_diff = st.sidebar.number_input("Miktar Y Ekseni Ortak Farkı", value=1, step=1)
|
| 18 |
+
first_step = st.sidebar.number_input("İlk Adım", value=0, step=1)
|
| 19 |
+
increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
|
| 20 |
+
|
| 21 |
+
if st.sidebar.button("Analizi Çalıştır"):
|
| 22 |
+
if uploaded_file is None:
|
| 23 |
+
st.error("Lütfen bir dosya yükleyin!")
|
| 24 |
+
else:
|
| 25 |
+
try:
|
| 26 |
+
# Dosya içeriğini okuma
|
| 27 |
+
content = uploaded_file.read().decode("utf-8")
|
| 28 |
+
result = re.split(r'[ \n]+', content)
|
| 29 |
+
|
| 30 |
+
# Veriyi filtreleme ve işleme
|
| 31 |
+
notes_result = result[first_step::increase_amount]
|
| 32 |
+
notes_result = [x for x in notes_result if x != '∅' and x != "NA"]
|
| 33 |
+
notes_result = list(map(lambda x: float(x), notes_result))
|
| 34 |
+
notes_result = np.array(notes_result)
|
| 35 |
+
|
| 36 |
+
# İstatistikler
|
| 37 |
+
average_x = np.average(notes_result)
|
| 38 |
+
min_x = notes_result.min()
|
| 39 |
+
max_x = notes_result.max()
|
| 40 |
+
std = np.std(notes_result)
|
| 41 |
+
z_score = (my_note - average_x) / std
|
| 42 |
+
|
| 43 |
+
# İstatistikleri ekrana yazdırma
|
| 44 |
+
st.subheader("Genel Bilgiler")
|
| 45 |
+
st.write(f"Katilimci Sayısı: {len(notes_result)}")
|
| 46 |
+
st.write(f"En Düşük Not: {min_x:.2f}")
|
| 47 |
+
st.write(f"En Yüksek Not: {max_x:.2f}")
|
| 48 |
+
st.write(f"Ortalama Not: {average_x:.2f}")
|
| 49 |
+
st.write(f"Standart Sapma: {std:.2f}")
|
| 50 |
+
st.write(f"Z-Skoru: {z_score:.2f}")
|
| 51 |
+
|
| 52 |
+
# Grafik oluşturma
|
| 53 |
+
st.subheader("Not Dağılım Grafiği")
|
| 54 |
+
unique_values, counts = np.unique(notes_result, return_counts=True)
|
| 55 |
+
plt.figure(figsize=(10, 6))
|
| 56 |
+
bars = plt.bar(unique_values, counts, width=0.3)
|
| 57 |
+
plt.axvline(x=average_x, color='red', linestyle='--')
|
| 58 |
+
plt.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
|
| 59 |
+
|
| 60 |
+
if my_note in unique_values:
|
| 61 |
+
plt.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
|
| 62 |
+
|
| 63 |
+
for bar in bars:
|
| 64 |
+
if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
|
| 65 |
+
bar.set_color('green')
|
| 66 |
+
|
| 67 |
+
plt.title(f'{lecture_name} Not Sayıları Grafiği')
|
| 68 |
+
plt.xlabel('Notlar')
|
| 69 |
+
plt.ylabel('Adet')
|
| 70 |
+
plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
|
| 71 |
+
plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
|
| 72 |
+
|
| 73 |
+
# Grafik bilgileri
|
| 74 |
+
info_text = (
|
| 75 |
+
f"Katilimci sayısı: {len(notes_result)}\n"
|
| 76 |
+
f"En düşük not: {min_x:.2f}\n"
|
| 77 |
+
f"En yüksek not: {max_x:.2f}\n"
|
| 78 |
+
f"Benim notum: {my_note:.2f}\n"
|
| 79 |
+
f"Ortalama not: {average_x:.2f}\n"
|
| 80 |
+
f"Standart sapma: {std:.2f}\n"
|
| 81 |
+
f"Z-skoru: {z_score:.2f}"
|
| 82 |
+
)
|
| 83 |
+
plt.text(
|
| 84 |
+
1.05 * max(unique_values), 0.8 * max(counts),
|
| 85 |
+
info_text,
|
| 86 |
+
fontsize=10,
|
| 87 |
+
color="black",
|
| 88 |
+
ha="left",
|
| 89 |
+
va="top",
|
| 90 |
+
bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
|
| 91 |
+
)
|
| 92 |
+
plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
|
| 93 |
+
|
| 94 |
+
# Grafik gösterimi
|
| 95 |
+
st.pyplot(plt)
|
| 96 |
+
|
| 97 |
+
# Grafik indirme bağlantısı
|
| 98 |
+
buf = BytesIO()
|
| 99 |
+
plt.savefig(buf, format="png")
|
| 100 |
+
buf.seek(0)
|
| 101 |
+
st.download_button(
|
| 102 |
+
label="Grafiği İndir",
|
| 103 |
+
data=buf,
|
| 104 |
+
file_name="not_dagilimi.png",
|
| 105 |
+
mime="image/png"
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
except Exception as e:
|
| 109 |
+
st.error(f"Hata: {e}")
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
matplotlib
|
| 3 |
+
numpy
|