aliicemill commited on
Commit
2cb1cdb
·
verified ·
1 Parent(s): f565cfb

Delete ingilizce.py

Browse files
Files changed (1) hide show
  1. ingilizce.py +0 -163
ingilizce.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
- # Title
8
- st.title("Note Analyzer Streamlit Application")
9
-
10
- # Image display state
11
- if "show_images" not in st.session_state:
12
- st.session_state.show_images = True # Default: images are shown
13
-
14
- # Sidebar input area
15
- st.sidebar.header("Input Fields")
16
-
17
- # File upload or text input selection
18
- input_method = st.sidebar.radio(
19
- "How will you provide the notes?",
20
- options=["Upload File", "Copy-Paste"]
21
- )
22
-
23
- uploaded_file = None
24
- text_input = None
25
-
26
- if input_method == "Upload File":
27
- uploaded_file = st.sidebar.file_uploader("Upload the Notes File (TXT)", type=["txt"])
28
- elif input_method == "Copy-Paste":
29
- text_input = st.sidebar.text_area("Paste the Notes Here", height=200)
30
-
31
- # Other parameters
32
- lecture_name = st.sidebar.text_input("Course Name", value="Course Name")
33
- perfect_score = st.sidebar.number_input("Maximum Exam Score", value=100, step=1)
34
- my_note = st.sidebar.number_input("My Score", value=0.0, step=0.1)
35
- note_s_axis_diff = st.sidebar.number_input("Score X-Axis Step Size", value=5, step=1)
36
- amount_s_axis_diff = st.sidebar.number_input("Frequency Y-Axis Step Size", value=1, step=1)
37
- first_step = st.sidebar.number_input("First Step", value=0, step=1)
38
- increase_amount = st.sidebar.number_input("Step Increase", value=1, step=1)
39
-
40
- if st.sidebar.button("Run Analysis"):
41
- # Hide images when the button is clicked
42
- st.session_state.show_images = False
43
-
44
- # Show images only if show_images is True
45
- if st.session_state.show_images:
46
- st.subheader("How the Application Works")
47
-
48
- # List the image filenames in order
49
- image_files = ["english/a.png", "english/b.png", "english/c.png", "english/d.png"]
50
-
51
- # Display images one below the other
52
- for image_file in image_files:
53
- st.image(image_file, use_container_width=True)
54
-
55
- # Load and process notes (Only works if the button is clicked)
56
- if not st.session_state.show_images:
57
- if input_method == "Upload File" and uploaded_file is None:
58
- st.error("Please upload a file!")
59
- elif input_method == "Copy-Paste" and not text_input:
60
- st.error("Please paste the notes into the text area!")
61
- else:
62
- try:
63
- # Read content from file or text area
64
- if uploaded_file:
65
- content = uploaded_file.read().decode("utf-8")
66
- elif text_input:
67
- content = text_input
68
-
69
- # Process the data
70
- result = re.split(r'[ \n]+', content)
71
-
72
- # Clean and filter the data
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
- # Statistics
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
- # Display statistics
85
- st.subheader("General Information")
86
- st.write(f"Number of Participants: {len(notes_result)}")
87
- st.write(f"Lowest Score: {min_x:.2f}")
88
- st.write(f"Highest Score: {max_x:.2f}")
89
- st.write(f"Average Score: {average_x:.2f}")
90
- st.write(f"Standard Deviation: {std:.2f}")
91
- st.write(f"Z-Score: {z_score:.2f}")
92
-
93
- # Create plot
94
- st.subheader("Score Distribution Graph")
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), 'Average Score', 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], 'My\nScore', 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} Score Distribution')
109
- plt.xlabel('Scores')
110
- plt.ylabel('Count')
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
- # Add graph information
115
- info_text = (
116
- f"Number of participants: {len(notes_result)}\n"
117
- f"Lowest score: {min_x:.2f}\n"
118
- f"Highest score: {max_x:.2f}\n"
119
- f"My score: {my_note:.2f}\n"
120
- f"Average score: {average_x:.2f}\n"
121
- f"Standard deviation: {std:.2f}\n"
122
- f"Z-score: {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
- # Display the plot
136
- st.pyplot(plt)
137
-
138
- # Download button for the plot
139
- buf = BytesIO()
140
- plt.savefig(buf, format="png")
141
- buf.seek(0)
142
- st.download_button(
143
- label="Download Graph",
144
- data=buf,
145
- file_name="score_distribution.png",
146
- mime="image/png"
147
- )
148
-
149
- except Exception as e:
150
- st.error(f"Error: {e}")
151
-
152
- # Footer
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
- # Add a note at the bottom right corner of the page
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)