[Your-Name-Here] - Fab Futures - Data Science
Home About
In [3]:
import numpy as np
import matplotlib.pyplot as plt
import sklearn
from sklearn.datasets import fetch_openml
import pandas as pd
from io import StringIO
import os

np.set_printoptions(precision=1)

# ------------------------------------------------------------
# 1. LOAD MNIST DATA (NO TENSORFLOW)
# ------------------------------------------------------------
print("Loading MNIST from openml (sklearn)...")

mnist = fetch_openml("mnist_784", version=1, as_frame=False)
X = mnist.data
y = mnist.target.astype(int)

print(f"MNIST data shape: {X.shape}")

# Plot MNIST sample scatter
plt.scatter(X[:, 200], X[:, 400], c=y, s=3)
plt.xlabel("pixel 200")
plt.ylabel("pixel 400")
plt.title("MNIST vs pixels 200 and 400")
plt.colorbar(label="digit")
plt.show()

# ------------------------------------------------------------
# 2. STANDARDIZE + PCA
# ------------------------------------------------------------
scaler = sklearn.preprocessing.StandardScaler()
Xscale = scaler.fit_transform(X)

pca = sklearn.decomposition.PCA(n_components=10)
pca.fit(Xscale)

print("Explained variance:", pca.explained_variance_)

Xpca = pca.transform(Xscale)

plt.scatter(Xpca[:, 0], Xpca[:, 1], c=y, s=3)
plt.xlabel("principal component 1")
plt.ylabel("principal component 2")
plt.title("MNIST vs two principal components")
plt.colorbar(label="digit")
plt.show()

# ------------------------------------------------------------
# 3. LOAD CSV DATA
# ------------------------------------------------------------
csv_text = """Sl. No.,Name,Attendance,Topic,Exploration,Communication,Creativity,Any Additional Comment
1,Ashish Wakley,TRUE,Climate Change,Good,Good,Very Good,very confident but need to explore more.
2,Dorji Tshewang,TRUE,Climate Change,Good,Good,Good,"Limited only to textbook, need to be confident and explore more"
3,Jigme Namgyel,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Oral presentation, Most of the time he is silence and hardly speak "
4,Kelden Drukda,TRUE,Climate Change,Need improvement,Need improvement,Very Good,"Didnot see effort on exploration, poor in communication"
5,Kinga Tobgay,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
6,Kinley Dendup,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
7,Kinley Tshering,TRUE,Climate Change,Good,Need improvement,Need improvement,Poor communication skills.
8,Lekden Thujee Drakpa,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,Did not explore for information.Got few points from the sister.Very poor communication.(noding and in words only)
9,Pema Namgay,TRUE,Climate Change,Very Good,Very Good,Very Good,Exploration done well and mentioned the sources . Language very fluent and confident
10,Rinzin Dorji,TRUE,Climate Change,Good,Need improvement,Need improvement,oral presentation/ responding in Dzongkha and lack of fluency.
11,Samten Nima,TRUE,Climate Change,Good,Need improvement,Need improvement,Need to improve communication skills.
12,Sherub Phuntsho,TRUE,Climate Change,Good,Good,Need improvement,"Didnot gather informationwell (fragmented source), Cannot speak fluently"
13,Sherub Wangchuk,TRUE,Climate Change,Good,Good,Need improvement,Need to explore more and improve communication
14,Sonam Rabten,TRUE,Climate Change,Good,Good,Need improvement,Lack of confidence and need to explore more on the given topic.
15,Sonam Tobden,TRUE,Climate Change,Good,Very Good,Need improvement,very confident and fluent
16,Tashi Yoezer,TRUE,Climate Change,Good,Good,Good,confident and fluent while speaking but need to explore moreC
17,Thukten Rigtsel Dorji,TRUE,Climate Change,Good,Very Good,Good,Conident and fluent while speaking but need to explore more on the given topic.
18,Yonten Yoezer,TRUE,Climate Change,Good,Need improvement,Need improvement,Need to be more confident while communicating. He hasn't explored it but discussed it with his friend.
19,Dechen Pem,TRUE,Climate Change,Good,Very Good,Need improvement,Topic Air pollution/very well prepared.fluent with presentation. answered the questions well.
20,Dechen Zangmo,TRUE,Climate Change,Good,Need improvement,Good,"Reading from the text,  not confident and need to explore more."
21,Dorji Choden,TRUE,Climate Change,Very Good,Very Good,Good,fluent and well prepared.
22,Jigme Metho,TRUE,Climate Change,Need improvement,Need improvement,Good,"not able anwer based on her presentation, lack of fluency"
23,Kamala Sunar,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Not confident at all, lacks basic information on the topic- not explored"
24,Kinzang Lhazin,TRUE,Climate Change,Need improvement,Good,Good,"no internet facilities and phone, prepared the presentation with help of friends."
25,Namgay Choden,TRUE,Climate Change,Good,Very Good,Need improvement,confident while speaking in dzongkha but lacking fluency in English.
26,Pema Dema,TRUE,Climate Change,Good,Need improvement,Need improvement,"reading, lack of fluency need to improve on pronuncation"
27,Pema Wangmo,TRUE,Climate Change,Good,Good,Need improvement,"Not confident at all (reading from the text), numerous grammatical errors "
28,Pema Yangchen,TRUE,Climate Change,Good,Good,Need improvement,need to be more confident and improve communication
29,Sangay Choden,TRUE,Climate Change,Good,Good,Need improvement,Confident and fluent in speaking but need to explore more.
30,Sonam Choki,TRUE,Climate Change,Good,,Good,Presented with the help of chart paper. Poor communication and lack of confidence.
31,Tenzin Chokey,TRUE,Climate Change,Good,Need improvement,Good,lack of fluency
32,Thukten Ngawang Choden,TRUE,Climate Change,Very Good,Very Good,Very Good,"confident,well prepared,"
33,Tshering Choden S,TRUE,Climate Change,Good,Good,Good,Need to explore more and improve communication
34,Tshering Choden Z,TRUE,Climate Change,Good,Good,Good,"Reading done well, Fluency lacks while responding"
35,Tshering Yangzom,TRUE,Climate Change,Good,Good,Good,"presentation is channeled only to Bhutan so need to explore more, improve communication "
36,Ugyen Dema,TRUE,Climate Change,Good,Good,Good,Presented with the help of chart paper. responded in Dzongkha.
37,Ugyen lhaden,TRUE,Climate Change,Good,Need improvement,Need improvement,"lack of confidence, hardly speak and need to explore more."
38,Ugyen Yangzom,TRUE,Climate Change,Good,Very Good,Good,"Oral presentation-confident, need to explore more on the given topic"
39,Yeshi lham,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Cannot read from the written text, need exploration, build confidence"
"""

df = pd.read_csv(StringIO(csv_text))

print("\nCSV Loaded:")
print(df.head())

# ------------------------------------------------------------
# 4. MAP TEXT RATINGS TO SCORES
# ------------------------------------------------------------
rating_map = {
    "Very Good": 3,
    "Good": 2,
    "Need improvement": 1,
    np.nan: 0
}

for col in ["Exploration", "Communication", "Creativity"]:
    df[col + "_score"] = df[col].map(rating_map)

print("\nCSV with Encoded Scores:")
print(df[["Name", "Exploration_score", "Communication_score", "Creativity_score"]].head())

# ------------------------------------------------------------
# 5. SIMPLE PLOT (CSV)
# ------------------------------------------------------------
plt.figure(figsize=(12,5))
plt.bar(df["Name"], df["Exploration_score"])
plt.xticks(rotation=90)
plt.ylabel("Exploration Score")
plt.title("Exploration Scores for Grade VIII E")
plt.show()
Loading MNIST from openml (sklearn)...
MNIST data shape: (70000, 784)
No description has been provided for this image
Explained variance: [40.6 29.1 26.9 20.8 18.1 15.8 13.8 12.5 11.  10. ]
No description has been provided for this image
CSV Loaded:
   Sl. No.            Name  Attendance           Topic       Exploration  \
0        1   Ashish Wakley        True  Climate Change              Good   
1        2  Dorji Tshewang        True  Climate Change              Good   
2        3   Jigme Namgyel        True  Climate Change  Need improvement   
3        4   Kelden Drukda        True  Climate Change  Need improvement   
4        5    Kinga Tobgay        True  Climate Change              Good   

      Communication        Creativity  \
0              Good         Very Good   
1              Good              Good   
2  Need improvement  Need improvement   
3  Need improvement         Very Good   
4              Good  Need improvement   

                              Any Additional Comment  
0           very confident but need to explore more.  
1  Limited only to textbook, need to be confident...  
2  Oral presentation, Most of the time he is sile...  
3  Didnot see effort on exploration, poor in comm...  
4  Well prepared but need to explore more on the ...  

CSV with Encoded Scores:
             Name  Exploration_score  Communication_score  Creativity_score
0   Ashish Wakley                  2                    2                 3
1  Dorji Tshewang                  2                    2                 2
2   Jigme Namgyel                  1                    1                 1
3   Kelden Drukda                  1                    1                 3
4    Kinga Tobgay                  2                    2                 1
No description has been provided for this image
In [5]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from io import StringIO

# ------------------------------------------------------------
# 1. LOAD YOUR CSV DATA
# ------------------------------------------------------------
csv_text = """Sl. No.,Name,Attendance,Topic,Exploration,Communication,Creativity,Any Additional Comment
1,Ashish Wakley,TRUE,Climate Change,Good,Good,Very Good,very confident but need to explore more.
2,Dorji Tshewang,TRUE,Climate Change,Good,Good,Good,"Limited only to textbook, need to be confident and explore more"
3,Jigme Namgyel,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Oral presentation, Most of the time he is silence and hardly speak "
4,Kelden Drukda,TRUE,Climate Change,Need improvement,Need improvement,Very Good,"Didnot see effort on exploration, poor in communication"
5,Kinga Tobgay,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
6,Kinley Dendup,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
7,Kinley Tshering,TRUE,Climate Change,Good,Need improvement,Need improvement,Poor communication skills. 
8,Lekden Thujee Drakpa,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,Did not explore for information.Got few points from the sister.Very poor communication.(noding and in words only)
9,Pema Namgay,TRUE,Climate Change,Very Good,Very Good,Very Good,Exploration done well and mentioned the sources . Language very fluent and confident
10,Rinzin Dorji,TRUE,Climate Change,Good,Need improvement,Need improvement,oral presentation/ responding in Dzongkha and lack of fluency.
11,Samten Nima,TRUE,Climate Change,Good,Need improvement,Need improvement,Need to improve communication skills.
12,Sherub Phuntsho,TRUE,Climate Change,Good,Good,Need improvement,"Didnot gather informationwell (fragmented source), Cannot speak fluently"
13,Sherub Wangchuk,TRUE,Climate Change,Good,Good,Need improvement,Need to explore more and improve communication
14,Sonam Rabten,TRUE,Climate Change,Good,Good,Need improvement,Lack of confidence and need to explore more on the given topic.
15,Sonam Tobden,TRUE,Climate Change,Good,Very Good,Need improvement,very confident and fluent
16,Tashi Yoezer,TRUE,Climate Change,Good,Good,Good,confident and fluent while speaking but need to explore moreC
17,Thukten Rigtsel Dorji,TRUE,Climate Change,Good,Very Good,Good,Conident and fluent while speaking but need to explore more on the given topic.
18,Yonten Yoezer,TRUE,Climate Change,Good,Need improvement,Need improvement,Need to be more confident while communicating. He hasn't explored it but discussed it with his friend.
19,Dechen Pem,TRUE,Climate Change,Good,Very Good,Need improvement,Topic Air pollution/very well prepared.fluent with presentation. answered the questions well.
20,Dechen Zangmo,TRUE,Climate Change,Good,Need improvement,Good,"Reading from the text,  not confident and need to explore more."
21,Dorji Choden,TRUE,Climate Change,Very Good,Very Good,Good,fluent and well prepared.
22,Jigme Metho,TRUE,Climate Change,Need improvement,Need improvement,Good,"not able anwer based on her presentation, lack of fluency"
23,Kamala Sunar,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Not confident at all, lacks basic information on the topic- not explored"
24,Kinzang Lhazin,TRUE,Climate Change,Need improvement,Good,Good,"no internet facilities and phone, prepared the presentation with help of friends."
25,Namgay Choden,TRUE,Climate Change,Good,Very Good,Need improvement,confident while speaking in dzongkha but lacking fluency in English.
26,Pema Dema,TRUE,Climate Change,Good,Need improvement,Need improvement,"reading, lack of fluency need to improve on pronuncation"
27,Pema Wangmo,TRUE,Climate Change,Good,Good,Need improvement,"Not confident at all (reading from the text), numerous grammatical errors "
28,Pema Yangchen,TRUE,Climate Change,Good,Good,Need improvement,need to be more confident and improve communication
29,Sangay Choden,TRUE,Climate Change,Good,Good,Need improvement,Confident and fluent in speaking but need to explore more.
30,Sonam Choki,TRUE,Climate Change,Good,,Good,Presented with the help of chart paper. Poor communication and lack of confidence.  
31,Tenzin Chokey,TRUE,Climate Change,Good,Need improvement,Good,lack of fluency
32,Thukten Ngawang Choden,TRUE,Climate Change,Very Good,Very Good,Very Good,"confident,well prepared,"
33,Tshering Choden S,TRUE,Climate Change,Good,Good,Good,Need to explore more and improve communication
34,Tshering Choden Z,TRUE,Climate Change,Good,Good,Good,"Reading done well, Fluency lacks while responding"
35,Tshering Yangzom,TRUE,Climate Change,Good,Good,Good,"presentation is channeled only to Bhutan so need to explore more, improve communication "
36,Ugyen Dema,TRUE,Climate Change,Good,Good,Good,Presented with the help of chart paper. responded in Dzongkha.
37,Ugyen lhaden,TRUE,Climate Change,Good,Need improvement,Need improvement,"lack of confidence, hardly speak and need to explore more."
38,Ugyen Yangzom,TRUE,Climate Change,Good,Very Good,Good,"Oral presentation-confident, need to explore more on the given topic"
39,Yeshi lham,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Cannot read from the written text, need exploration, build confidence"
"""

df = pd.read_csv(StringIO(csv_text))
print(df.head())


# ------------------------------------------------------------
# 2. DUMMY AUDIO SIGNAL (so spectrogram works)
# ------------------------------------------------------------
rate = 44100  # sampling rate (Hz)
duration = 5   # seconds
t = np.linspace(0, duration, int(rate * duration))

# Make a simple mixed-frequency signal
data = (
    0.5 * np.sin(2 * np.pi * 440 * t) +   # 440 Hz tone
    0.3 * np.sin(2 * np.pi * 880 * t) +   # 880 Hz tone
    0.2 * np.random.randn(len(t))         # noise
)


# ------------------------------------------------------------
# 3. YOUR SPECTROGRAM PLOT
# ------------------------------------------------------------
plt.figure(figsize=(10, 5))
plt.specgram(data, Fs=rate, scale='linear', cmap='inferno')
plt.ylim(0, 2000)
plt.title("Spectrogram")
plt.xlabel('time (s)')
plt.ylabel('frequency (Hz)')
plt.show()
   Sl. No.            Name  Attendance           Topic       Exploration  \
0        1   Ashish Wakley        True  Climate Change              Good   
1        2  Dorji Tshewang        True  Climate Change              Good   
2        3   Jigme Namgyel        True  Climate Change  Need improvement   
3        4   Kelden Drukda        True  Climate Change  Need improvement   
4        5    Kinga Tobgay        True  Climate Change              Good   

      Communication        Creativity  \
0              Good         Very Good   
1              Good              Good   
2  Need improvement  Need improvement   
3  Need improvement         Very Good   
4              Good  Need improvement   

                              Any Additional Comment  
0           very confident but need to explore more.  
1  Limited only to textbook, need to be confident...  
2  Oral presentation, Most of the time he is sile...  
3  Didnot see effort on exploration, poor in comm...  
4  Well prepared but need to explore more on the ...  
No description has been provided for this image
In [6]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import butter, filtfilt
import pandas as pd
from io import StringIO

# ------------------------------------------------------------
# 1. LOAD YOUR CSV
# ------------------------------------------------------------
csv_text = """Sl. No.,Name,Attendance,Topic,Exploration,Communication,Creativity,Any Additional Comment
1,Ashish Wakley,TRUE,Climate Change,Good,Good,Very Good,very confident but need to explore more.
2,Dorji Tshewang,TRUE,Climate Change,Good,Good,Good,"Limited only to textbook, need to be confident and explore more"
3,Jigme Namgyel,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Oral presentation, Most of the time he is silence and hardly speak "
4,Kelden Drukda,TRUE,Climate Change,Need improvement,Need improvement,Very Good,"Didnot see effort on exploration, poor in communication"
5,Kinga Tobgay,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
6,Kinley Dendup,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
7,Kinley Tshering,TRUE,Climate Change,Good,Need improvement,Need improvement,Poor communication skills. 
8,Lekden Thujee Drakpa,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,Did not explore for information.Got few points from the sister.Very poor communication.(noding and in words only)
9,Pema Namgay,TRUE,Climate Change,Very Good,Very Good,Very Good,Exploration done well and mentioned the sources . Language very fluent and confident
10,Rinzin Dorji,TRUE,Climate Change,Good,Need improvement,Need improvement,oral presentation/ responding in Dzongkha and lack of fluency.
11,Samten Nima,TRUE,Climate Change,Good,Need improvement,Need improvement,Need to improve communication skills.
12,Sherub Phuntsho,TRUE,Climate Change,Good,Good,Need improvement,"Didnot gather informationwell (fragmented source), Cannot speak fluently"
13,Sherub Wangchuk,TRUE,Climate Change,Good,Good,Need improvement,Need to explore more and improve communication
14,Sonam Rabten,TRUE,Climate Change,Good,Good,Need improvement,Lack of confidence and need to explore more on the given topic.
15,Sonam Tobden,TRUE,Climate Change,Good,Very Good,Need improvement,very confident and fluent
16,Tashi Yoezer,TRUE,Climate Change,Good,Good,Good,confident and fluent while speaking but need to explore moreC
17,Thukten Rigtsel Dorji,TRUE,Climate Change,Good,Very Good,Good,Conident and fluent while speaking but need to explore more on the given topic.
18,Yonten Yoezer,TRUE,Climate Change,Good,Need improvement,Need improvement,Need to be more confident while communicating. He hasn't explored it but discussed it with his friend.
19,Dechen Pem,TRUE,Climate Change,Good,Very Good,Need improvement,Topic Air pollution/very well prepared.fluent with presentation. answered the questions well.
20,Dechen Zangmo,TRUE,Climate Change,Good,Need improvement,Good,"Reading from the text,  not confident and need to explore more."
21,Dorji Choden,TRUE,Climate Change,Very Good,Very Good,Good,fluent and well prepared.
22,Jigme Metho,TRUE,Climate Change,Need improvement,Need improvement,Good,"not able anwer based on her presentation, lack of fluency"
23,Kamala Sunar,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Not confident at all, lacks basic information on the topic- not explored"
24,Kinzang Lhazin,TRUE,Climate Change,Need improvement,Good,Good,"no internet facilities and phone, prepared the presentation with help of friends."
25,Namgay Choden,TRUE,Climate Change,Good,Very Good,Need improvement,confident while speaking in dzongkha but lacking fluency in English.
26,Pema Dema,TRUE,Climate Change,Good,Need improvement,Need improvement,"reading, lack of fluency need to improve on pronuncation"
27,Pema Wangmo,TRUE,Climate Change,Good,Good,Need improvement,"Not confident at all (reading from the text), numerous grammatical errors "
28,Pema Yangchen,TRUE,Climate Change,Good,Good,Need improvement,need to be more confident and improve communication
29,Sangay Choden,TRUE,Climate Change,Good,Good,Need improvement,Confident and fluent in speaking but need to explore more.
30,Sonam Choki,TRUE,Climate Change,Good,,Good,Presented with the help of chart paper. Poor communication and lack of confidence.  
31,Tenzin Chokey,TRUE,Climate Change,Good,Need improvement,Good,lack of fluency
32,Thukten Ngawang Choden,TRUE,Climate Change,Very Good,Very Good,Very Good,"confident,well prepared,"
33,Tshering Choden S,TRUE,Climate Change,Good,Good,Good,Need to explore more and improve communication
34,Tshering Choden Z,TRUE,Climate Change,Good,Good,Good,"Reading done well, Fluency lacks while responding"
35,Tshering Yangzom,TRUE,Climate Change,Good,Good,Good,"presentation is channeled only to Bhutan so need to explore more, improve communication "
36,Ugyen Dema,TRUE,Climate Change,Good,Good,Good,Presented with the help of chart paper. responded in Dzongkha.
37,Ugyen lhaden,TRUE,Climate Change,Good,Need improvement,Need improvement,"lack of confidence, hardly speak and need to explore more."
38,Ugyen Yangzom,TRUE,Climate Change,Good,Very Good,Good,"Oral presentation-confident, need to explore more on the given topic"
39,Yeshi lham,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Cannot read from the written text, need exploration, build confidence"
"""

df = pd.read_csv(StringIO(csv_text))
print("CSV Loaded:")
print(df.head())

# encode ratings
rating_map = {"Very Good": 3, "Good": 2, "Need improvement": 1, np.nan: 0}
for col in ["Exploration", "Communication", "Creativity"]:
    df[col + "_score"] = df[col].map(rating_map)

# simple CSV plot
plt.figure(figsize=(10,4))
plt.bar(df["Name"], df["Exploration_score"])
plt.xticks(rotation=90)
plt.title("Exploration Scores (Grade VIII E)")
plt.show()


# ------------------------------------------------------------
# 2. YOUR ORIGINAL FILTERING CODE
# ------------------------------------------------------------
npts = 1000
noise = 0.2
x = np.linspace(-10, 10, npts)
data = np.tanh(x) + np.random.normal(0, noise, npts)

plt.plot(data)
plt.title('data')
plt.show()

order = 5
frequency = 20000

# low-pass filter
low = 500
b, a = butter(order, low, btype='low', fs=frequency, output='ba', analog=False)
filtlow = filtfilt(b, a, data)
plt.plot(filtlow)
plt.title('low pass')
plt.show()

# high-pass filter
high = 5000
b, a = butter(order, high, btype='high', fs=frequency, output='ba', analog=False)
filthigh = filtfilt(b, a, data)
plt.plot(filthigh)
plt.title('high pass')
plt.show()

# band-pass filter
low = 25
high = 1000
b, a = butter(order, [low, high], btype='band', fs=frequency, output='ba', analog=False)
filtband = filtfilt(b, a, data)
plt.plot(filtband)
plt.title('band pass')
plt.show()
CSV Loaded:
   Sl. No.            Name  Attendance           Topic       Exploration  \
0        1   Ashish Wakley        True  Climate Change              Good   
1        2  Dorji Tshewang        True  Climate Change              Good   
2        3   Jigme Namgyel        True  Climate Change  Need improvement   
3        4   Kelden Drukda        True  Climate Change  Need improvement   
4        5    Kinga Tobgay        True  Climate Change              Good   

      Communication        Creativity  \
0              Good         Very Good   
1              Good              Good   
2  Need improvement  Need improvement   
3  Need improvement         Very Good   
4              Good  Need improvement   

                              Any Additional Comment  
0           very confident but need to explore more.  
1  Limited only to textbook, need to be confident...  
2  Oral presentation, Most of the time he is sile...  
3  Didnot see effort on exploration, poor in comm...  
4  Well prepared but need to explore more on the ...  
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [7]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# ------------------------------------------------------------
# 1. LOAD YOUR CSV DATA
# ------------------------------------------------------------
csv_text = """Sl. No.,Name,Attendance,Topic,Exploration,Communication,Creativity,Any Additional Comment
1,Ashish Wakley,TRUE,Climate Change,Good,Good,Very Good,very confident but need to explore more.
2,Dorji Tshewang,TRUE,Climate Change,Good,Good,Good,"Limited only to textbook, need to be confident and explore more"
3,Jigme Namgyel,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Oral presentation, Most of the time he is silence and hardly speak "
4,Kelden Drukda,TRUE,Climate Change,Need improvement,Need improvement,Very Good,"Didnot see effort on exploration, poor in communication"
5,Kinga Tobgay,TRUE,Climate Change,Good,Good,Need improvement,Well prepared but need to explore more on the given topic.
...
39,Yeshi lham,TRUE,Climate Change,Need improvement,Need improvement,Need improvement,"Cannot read from the written text, need exploration, build confidence"
"""

# Load the CSV from text
from io import StringIO
df = pd.read_csv(StringIO(csv_text))

print("CSV Loaded Successfully:")
print(df.head())

# Optional: Convert assessment words to numeric values
label_map = {
    "Very Good": 3,
    "Good": 2,
    "Need improvement": 1,
    np.nan: 0
}

for col in ["Exploration", "Communication", "Creativity"]:
    df[col + "_score"] = df[col].map(label_map)

# ------------------------------------------------------------
# 2. YOUR ORIGINAL DTMF + DCT CODE
# ------------------------------------------------------------

# parameters
f1 = 697   # DTMF 1
f2 = 1209  # DTMF 1
fsample = 10000
dt = 1/fsample
tmax = 0.25
fraction = 0.05

# data
time = np.arange(0, tmax, dt)
n = len(time)
samples = np.sin(2*np.pi*time*f1) + np.sin(2*np.pi*time*f2)

# plot original signal
plt.ion()
fig, ax = plt.subplots(1, 1)
ax.plot(time, samples)
plt.xlim(0, .02)
plt.xlabel('time')
plt.title('DTMF data')

# DCT
dct = np.zeros((n, n))
for i in range(n):
    dct[:, i] = np.sqrt(2/n) * np.cos(np.pi*(2*i+1)*np.arange(n)/(2*n))
dct[0, :] *= 1/np.sqrt(2)

trans = dct @ samples
freq = np.arange(n) / (2*tmax)

fig, ax = plt.subplots(1, 1)
ax.plot(freq, trans)
plt.xlim(400, 1500)
plt.xlabel('frequency')
plt.title('Discrete Cosine Transform')

# inverse DCT
inv = np.transpose(dct) @ trans
fig, ax = plt.subplots(1, 1)
ax.plot(time, inv)
plt.xlim(0, .02)
plt.xlabel('time')
plt.title('inverse Discrete Cosine Transform')

# random sample
nrandom = int(n * fraction)
index = (np.random.rand(nrandom) * n).astype(int)
random = samples[index]

fig, ax = plt.subplots(1, 1)
ax.plot(time, samples)
ax.scatter(time[index], random)
plt.xlim(0, .02)
plt.xlabel('time')
plt.title('random samples')

# gradient minimization
def gradmin(f, df, start, scale, steps):
    x = np.copy(start)
    for i in range(steps):
        x -= scale * df(x)
    return x

# minimize error
def df(x):
    global random, index, dct
    inv = np.transpose(dct) @ x
    grad = np.zeros(n)
    for i in range(n):
        grad[i] = np.sum(2 * (inv[index] - random) * dct[i, index])
    return grad

def f(x):
    global random, index
    inv = np.transpose(dct) @ x
    return np.sum((inv[index] - random)**2)

start = np.random.rand(n)
scale = 0.1
steps = 100
fit = gradmin(f, df, start, scale, steps)

fig, ax = plt.subplots(1, 1)
ax.plot(freq, fit)
plt.xlabel('frequency')
plt.title('minimize error')
plt.xlim(400,1500)

# minimize error + L2
def df(x):
    global random, index, dct
    inv = np.transpose(dct) @ x
    grad = np.zeros(n)
    for i in range(n):
        grad[i] = np.sum(2 * (inv[index] - random) * dct[i, index]) + 2 * x[i]
    return grad

def f(x):
    global random, index
    inv = np.transpose(dct) @ x
    return np.sum((inv[index] - random)**2) + np.sum(x**2)

start = np.random.rand(n)
fit = gradmin(f, df, start, scale, steps)

fig, ax = plt.subplots(1, 1)
ax.plot(freq, fit)
plt.xlabel('frequency')
plt.title('minimize error + L2 norm')
plt.xlim(400,1500)

# minimize error + L1
def df(x):
    global random, index, dct
    inv = np.transpose(dct) @ x
    grad = np.zeros(n)
    for i in range(n):
        grad[i] = np.sum(2 * (inv[index] - random) * dct[i, index]) + np.sign(x[i])
    return grad

def f(x):
    global random, index
    inv = np.transpose(dct) @ x
    return np.sum((inv[index] - random)**2) + np.sum(np.abs(x))

start = np.random.rand(n)
fit = gradmin(f, df, start, scale, steps)

fig, ax = plt.subplots(1, 1)
ax.plot(freq, fit)
plt.xlabel('frequency')
plt.title('minimize error + L1 norm')
plt.xlim(400,1500)
CSV Loaded Successfully:
  Sl. No.            Name Attendance           Topic       Exploration  \
0       1   Ashish Wakley       True  Climate Change              Good   
1       2  Dorji Tshewang       True  Climate Change              Good   
2       3   Jigme Namgyel       True  Climate Change  Need improvement   
3       4   Kelden Drukda       True  Climate Change  Need improvement   
4       5    Kinga Tobgay       True  Climate Change              Good   

      Communication        Creativity  \
0              Good         Very Good   
1              Good              Good   
2  Need improvement  Need improvement   
3  Need improvement         Very Good   
4              Good  Need improvement   

                              Any Additional Comment  
0           very confident but need to explore more.  
1  Limited only to textbook, need to be confident...  
2  Oral presentation, Most of the time he is sile...  
3  Didnot see effort on exploration, poor in comm...  
4  Well prepared but need to explore more on the ...  
Out[7]:
(400.0, 1500.0)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [ ]: