File size: 3,364 Bytes
23071a2
 
 
 
000b46d
 
 
 
 
23071a2
 
 
 
 
 
000b46d
 
 
 
2a4ce38
23071a2
 
 
 
2a4ce38
 
 
23071a2
 
 
 
 
 
 
 
2a4ce38
23071a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a4ce38
 
 
 
 
 
 
 
 
 
 
 
23071a2
2a4ce38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23071a2
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt

#Huggingface
from datasets import load_dataset
from huggingface_hub import login
import os

st.set_page_config(
    page_title="Daftar Nilai Assesmen 1",
    page_icon="chart_with_upwards_trend",
    layout="wide",
)

login(token = os.environ['hf_token'])
dataset = load_dataset("irfantea/collections", data_files='Kombinasi.csv', split='train')
df = dataset.to_pandas()

#@st.cache_data
def load_data():
    df["First name"] = df["First name"].astype("string")
    df["Grade/100.00 (Simulasi)"] = df["Grade/100.00 (Simulasi)"].astype(float)
    df["Grade/100.00 (Ujian 1)"] = df["Grade/100.00 (Ujian 1)"].astype(float)
    df["Grade/100.00 (Ujian 2)"] = df["Grade/100.00 (Ujian 2)"].astype(float)
    df["Ujian 1 (15%)"] = (df["Grade/100.00 (Ujian 1)"].astype(float) * 0.15).round(2)
    df["Ujian 2 (30%)"] = (df["Grade/100.00 (Ujian 2)"].astype(float) * 0.30).round(2)
    return df

df = load_data()

def cari_npm(npm):
    df_cari = df[df["First name"] == npm]
    return df_cari
def susun_data(data_npm):
    columns_to_display = ["Surname", "First name",  "Grade/100.00 (Ujian 1)", "Ujian 1 (15%)", "Grade/100.00 (Ujian 2)", "Ujian 2 (30%)"]
    st.table(data_npm[columns_to_display])

colors = ['red', 'green', 'blue']

st.title("Grafik Batang Nilai Ujian Assesmen 1 Seluruh Mahasiswa")
kolom1, kolom2, kolom3 = st.columns(3)

with kolom1:
    grades = df["Grade/100.00 (Ujian 1)"]
    count_below_50 = (grades < 50).sum()
    count_50_to_68 = ((grades >= 50) & (grades <= 68)).sum()
    count_above_68 = (grades > 68).sum()

    data = {
        'Category': ['Below 50', '50 - 68', 'Above 68'],
        'Count': [count_below_50, count_50_to_68, count_above_68]
    }
    df_counts = pd.DataFrame(data)
    st.write("Ujian 1")    
    plt.clf()  # Clear the current figure
    plt.bar(df_counts['Category'], df_counts['Count'], color=colors)
    plt.xlabel('Rentang')
    plt.ylabel('Jumlah Mahasiswa')
    st.pyplot(plt)
    average = df["Grade/100.00 (Ujian 1)"].mean()
    median = df["Grade/100.00 (Ujian 1)"].median()
    stdev = df["Grade/100.00 (Ujian 1)"].std()
    st.info("Mean: " + str(average))
    st.info("Median: " + str(median))
    st.info("STDev: " + str(stdev))

with kolom2:    
    grades = df["Grade/100.00 (Ujian 2)"]
    count_below_50 = (grades < 50).sum()
    count_50_to_68 = ((grades >= 50) & (grades <= 68)).sum()
    count_above_68 = (grades > 68).sum()

    data = {
        'Category': ['Below 50', '50 - 68', 'Above 68'],
        'Count': [count_below_50, count_50_to_68, count_above_68]
    }
    df_counts = pd.DataFrame(data)
    st.write("Ujian 2")    
    plt.clf()  # Clear the current figure
    plt.bar(df_counts['Category'], df_counts['Count'], color=colors)
    plt.xlabel('Rentang')
    plt.ylabel('Jumlah Mahasiswa')
    st.pyplot(plt)
    average = df["Grade/100.00 (Ujian 2)"].mean()
    median = df["Grade/100.00 (Ujian 2)"].median()
    stdev = df["Grade/100.00 (Ujian 2)"].std()
    st.info("Mean: " + str(average))
    st.info("Median: " + str(median))
    st.info("STDev: " + str(stdev))

with kolom3:
    st.write("Ujian Final")

st.sidebar.info("Masukkan NPM Lengkap!")
st.title("Nilai Per Mahasiswa")
npm = st.sidebar.text_input("NPM")
if st.sidebar.button(label="Cari"):
    data_npm = cari_npm(npm)
    susun_data(data_npm)