Spaces:
Sleeping
Sleeping
Delete note_analyzer.py
Browse files- note_analyzer.py +0 -97
note_analyzer.py
DELETED
|
@@ -1,97 +0,0 @@
|
|
| 1 |
-
import sys
|
| 2 |
-
import re
|
| 3 |
-
import numpy as np
|
| 4 |
-
import matplotlib.pyplot as plt
|
| 5 |
-
|
| 6 |
-
# Komut satırı argümanlarını al
|
| 7 |
-
addressOfNotes = sys.argv[1]
|
| 8 |
-
lectureName = sys.argv[2]
|
| 9 |
-
perfectScore = int(sys.argv[3])
|
| 10 |
-
myNote = float(sys.argv[4])
|
| 11 |
-
noteSAxisSCommonDifference = int(sys.argv[5])
|
| 12 |
-
amountSAxisSCommonDifference = int(sys.argv[6])
|
| 13 |
-
firstStep = int(sys.argv[7]) # Yeni parametre
|
| 14 |
-
increaseAmount = int(sys.argv[8]) # Yeni parametre
|
| 15 |
-
|
| 16 |
-
# Dosya okuma
|
| 17 |
-
with open(addressOfNotes, mode="r", encoding="utf-8") as file:
|
| 18 |
-
belge = file.read()
|
| 19 |
-
|
| 20 |
-
# Belgedeki veriyi ayıklamak
|
| 21 |
-
result = re.split(r'[ \n]+', belge)
|
| 22 |
-
|
| 23 |
-
# Filtreleme: '∅' dışındaki sayıları alıyoruz
|
| 24 |
-
notes_result = result[firstStep::increaseAmount] # Slicing
|
| 25 |
-
notes_result = [x for x in notes_result if x != '∅' and x != "NA"] # '∅'yi dışarıda bırakıyoruz
|
| 26 |
-
|
| 27 |
-
# Sayıları float'a dönüştürme
|
| 28 |
-
notes_result = list(map(lambda x: float(x), notes_result))
|
| 29 |
-
notes_result = np.array(notes_result)
|
| 30 |
-
|
| 31 |
-
# Genel bilgiler
|
| 32 |
-
average_x = np.average(notes_result)
|
| 33 |
-
min_x = notes_result.min()
|
| 34 |
-
max_x = notes_result.max()
|
| 35 |
-
std = np.std(notes_result)
|
| 36 |
-
|
| 37 |
-
z_score = (myNote - average_x) / std
|
| 38 |
-
|
| 39 |
-
# Grafik şekli için verilerin sayılması
|
| 40 |
-
unique_values, counts = np.unique(notes_result, return_counts=True)
|
| 41 |
-
|
| 42 |
-
# Grafik için
|
| 43 |
-
plt.figure(figsize=(10, 6)) # Grafik boyutunu ayarlayabilirsiniz
|
| 44 |
-
|
| 45 |
-
# Çubuk grafik çizimi
|
| 46 |
-
bars = plt.bar(unique_values, counts, width=0.3)
|
| 47 |
-
|
| 48 |
-
# Başlık ve etiketler
|
| 49 |
-
plt.title(lectureName + ' Not Sayilari Grafiği')
|
| 50 |
-
plt.xlabel('Notlar')
|
| 51 |
-
plt.ylabel('Adet')
|
| 52 |
-
|
| 53 |
-
# Kırmızı dikey çizgi çizme
|
| 54 |
-
plt.axvline(x=average_x, color='red', linestyle='--')
|
| 55 |
-
|
| 56 |
-
# Ortalama değeri yazma
|
| 57 |
-
plt.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
|
| 58 |
-
|
| 59 |
-
# "Benim notum"un yazılması
|
| 60 |
-
if myNote in unique_values:
|
| 61 |
-
plt.text(myNote, counts[unique_values == myNote][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
|
| 62 |
-
|
| 63 |
-
# "Benim notum"un çubuğunu yeşil renkte yapmak
|
| 64 |
-
for bar in bars:
|
| 65 |
-
if bar.get_x() <= myNote < bar.get_x() + bar.get_width(): # myNote için çubuğu buluyoruz
|
| 66 |
-
bar.set_color('green')
|
| 67 |
-
|
| 68 |
-
# X ekseninde 0'dan 70'e kadar olan tam sayıları göstermek
|
| 69 |
-
plt.xticks(range(0, perfectScore, noteSAxisSCommonDifference), rotation=90)
|
| 70 |
-
plt.yticks(range(0, max(counts), amountSAxisSCommonDifference), rotation=0)
|
| 71 |
-
|
| 72 |
-
# Grafiğe genel bilgileri ekleme
|
| 73 |
-
info_text = (
|
| 74 |
-
f"Katilimci sayisi: {len(notes_result)}\n"
|
| 75 |
-
f"En düşük not: {min_x:.2f}\n"
|
| 76 |
-
f"En yüksek not: {max_x:.2f}\n"
|
| 77 |
-
f"Benim notum: {myNote:.2f}\n"
|
| 78 |
-
f"Ortalama not: {average_x:.2f}\n"
|
| 79 |
-
f"Standart sapma: {std:.2f}\n"
|
| 80 |
-
f"Z-skoru: {z_score:.2f}"
|
| 81 |
-
)
|
| 82 |
-
plt.text(
|
| 83 |
-
1.05 * max(unique_values), 0.8 * max(counts), # Metni sağ üst köşeye yerleştirme
|
| 84 |
-
info_text,
|
| 85 |
-
fontsize=10,
|
| 86 |
-
color="black",
|
| 87 |
-
ha="left",
|
| 88 |
-
va="top",
|
| 89 |
-
bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
|
| 90 |
-
)
|
| 91 |
-
|
| 92 |
-
# Subplot ayarlarını yapma
|
| 93 |
-
plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
|
| 94 |
-
|
| 95 |
-
# Grafiği kaydetme
|
| 96 |
-
plt.savefig('/tmp/analysis_plot.png')
|
| 97 |
-
print("Analiz tamamlandı ve grafik kaydedildi: /tmp/analysis_plot.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|