Spaces:
Sleeping
Sleeping
raymondEDS commited on
Commit ·
fa60705
1
Parent(s): 8ea6376
backgound
Browse files- reference/intake_graph +73 -0
- src/modules/__pycache__/module3.cpython-311.pyc +0 -0
- src/modules/module3.py +116 -9
reference/intake_graph
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
graph TD
|
| 2 |
+
A[Student Enrollment] --> B[Learner Profile Assessment]
|
| 3 |
+
|
| 4 |
+
B --> C[Technical Background]
|
| 5 |
+
B --> D[Mathematical Foundation]
|
| 6 |
+
B --> E[Domain Knowledge]
|
| 7 |
+
B --> F[Learning Preferences]
|
| 8 |
+
B --> G[Prior Knowledge]
|
| 9 |
+
|
| 10 |
+
C --> H[Profile Classification]
|
| 11 |
+
D --> H
|
| 12 |
+
E --> H
|
| 13 |
+
F --> H
|
| 14 |
+
G --> H
|
| 15 |
+
|
| 16 |
+
H --> I{Learner Archetype}
|
| 17 |
+
|
| 18 |
+
I -->|High Tech + High Knowledge| J[Advanced Technical Path]
|
| 19 |
+
I -->|High Tech + Low Knowledge| K[Accelerated Technical Path]
|
| 20 |
+
I -->|Low Tech + High Domain| L[Applied Research Path]
|
| 21 |
+
I -->|Low Tech + Low Knowledge| M[Foundational Path]
|
| 22 |
+
|
| 23 |
+
J --> N[Bloom's Taxonomy Outcomes]
|
| 24 |
+
K --> N
|
| 25 |
+
L --> N
|
| 26 |
+
M --> N
|
| 27 |
+
|
| 28 |
+
N --> O[Remember Level]
|
| 29 |
+
N --> P[Understand Level]
|
| 30 |
+
N --> Q[Apply Level]
|
| 31 |
+
N --> R[Analyze Level]
|
| 32 |
+
N --> S[Evaluate Level]
|
| 33 |
+
N --> T[Create Level]
|
| 34 |
+
|
| 35 |
+
O --> U[Adaptive Content Selection]
|
| 36 |
+
P --> U
|
| 37 |
+
Q --> U
|
| 38 |
+
R --> U
|
| 39 |
+
S --> U
|
| 40 |
+
T --> U
|
| 41 |
+
|
| 42 |
+
U --> V[Personalized Learning Activities]
|
| 43 |
+
|
| 44 |
+
V --> W[Personalized Clustering Curriculum]
|
| 45 |
+
|
| 46 |
+
subgraph "Content Library"
|
| 47 |
+
EE[Key Concepts & Explanations]
|
| 48 |
+
FF[Worked Examples]
|
| 49 |
+
GG[Visual Analogies]
|
| 50 |
+
HH[Code Examples]
|
| 51 |
+
II[Research Application Cases]
|
| 52 |
+
JJ[Interactive Exercises]
|
| 53 |
+
KK[Practice Questions]
|
| 54 |
+
end
|
| 55 |
+
|
| 56 |
+
U -.-> EE
|
| 57 |
+
U -.-> FF
|
| 58 |
+
U -.-> GG
|
| 59 |
+
U -.-> HH
|
| 60 |
+
U -.-> II
|
| 61 |
+
U -.-> JJ
|
| 62 |
+
U -.-> KK
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
style A fill:#e1f5fe
|
| 66 |
+
style I fill:#fff3e0
|
| 67 |
+
style J fill:#f3e5f5
|
| 68 |
+
style K fill:#f3e5f5
|
| 69 |
+
style L fill:#f3e5f5
|
| 70 |
+
style M fill:#f3e5f5
|
| 71 |
+
style N fill:#e8f5e8
|
| 72 |
+
style U fill:#fff8e1
|
| 73 |
+
style W fill:#e8f5e8
|
src/modules/__pycache__/module3.cpython-311.pyc
CHANGED
|
Binary files a/src/modules/__pycache__/module3.cpython-311.pyc and b/src/modules/__pycache__/module3.cpython-311.pyc differ
|
|
|
src/modules/module3.py
CHANGED
|
@@ -8,6 +8,13 @@ from sklearn.cluster import KMeans
|
|
| 8 |
from sklearn.preprocessing import StandardScaler
|
| 9 |
from sklearn.datasets import make_blobs
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def generate_regression_data(n_samples=100, noise=10):
|
| 12 |
"""Generate data for linear regression visualization."""
|
| 13 |
np.random.seed(42)
|
|
@@ -28,7 +35,8 @@ def generate_clustering_data(n_samples=300):
|
|
| 28 |
X, _ = make_blobs(n_samples=n_samples, centers=3, cluster_std=1.5)
|
| 29 |
return X
|
| 30 |
|
| 31 |
-
def
|
|
|
|
| 32 |
st.title("Interactive Machine Learning Visualizations")
|
| 33 |
|
| 34 |
# Introduction
|
|
@@ -55,10 +63,11 @@ def show():
|
|
| 55 |
# Generate and plot data
|
| 56 |
X, y = generate_regression_data(n_samples, noise)
|
| 57 |
|
| 58 |
-
# Create scatter plot
|
| 59 |
fig = px.scatter(x=X.flatten(), y=y,
|
| 60 |
title="Linear Regression Visualization",
|
| 61 |
-
labels={'x': 'Feature (X)', 'y': 'Target (y)'}
|
|
|
|
| 62 |
|
| 63 |
# Add regression line
|
| 64 |
model = LinearRegression()
|
|
@@ -70,6 +79,12 @@ def show():
|
|
| 70 |
name='Regression Line',
|
| 71 |
line=dict(color='red')))
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
st.plotly_chart(fig, use_container_width=True)
|
| 74 |
|
| 75 |
# Display model information
|
|
@@ -86,11 +101,12 @@ def show():
|
|
| 86 |
# Generate data
|
| 87 |
X, y = generate_classification_data()
|
| 88 |
|
| 89 |
-
# Create scatter plot
|
| 90 |
fig = px.scatter(x=X[:, 0], y=X[:, 1],
|
| 91 |
color=y.astype(str),
|
| 92 |
title="Logistic Regression Visualization",
|
| 93 |
-
labels={'x': 'Feature 1', 'y': 'Feature 2'}
|
|
|
|
| 94 |
|
| 95 |
# Add decision boundary
|
| 96 |
model = LogisticRegression()
|
|
@@ -110,6 +126,12 @@ def show():
|
|
| 110 |
opacity=0.3,
|
| 111 |
colorscale='RdBu'))
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
st.plotly_chart(fig, use_container_width=True)
|
| 114 |
|
| 115 |
# Display model information
|
|
@@ -133,19 +155,26 @@ def show():
|
|
| 133 |
kmeans = KMeans(n_clusters=n_clusters, random_state=42)
|
| 134 |
clusters = kmeans.fit_predict(X)
|
| 135 |
|
| 136 |
-
# Create scatter plot
|
| 137 |
fig = px.scatter(x=X[:, 0], y=X[:, 1],
|
| 138 |
color=clusters.astype(str),
|
| 139 |
title="K-Means Clustering Visualization",
|
| 140 |
-
labels={'x': 'Feature 1', 'y': 'Feature 2'}
|
|
|
|
| 141 |
|
| 142 |
# Add cluster centers
|
| 143 |
fig.add_trace(go.Scatter(x=kmeans.cluster_centers_[:, 0],
|
| 144 |
y=kmeans.cluster_centers_[:, 1],
|
| 145 |
mode='markers',
|
| 146 |
-
marker=dict(size=12, symbol='star', color='
|
| 147 |
name='Cluster Centers'))
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
st.plotly_chart(fig, use_container_width=True)
|
| 150 |
|
| 151 |
# Display clustering information
|
|
@@ -161,4 +190,82 @@ def show():
|
|
| 161 |
- Linear Regression: Fits a line to predict continuous values
|
| 162 |
- Logistic Regression: Creates a decision boundary for classification
|
| 163 |
- K-Means Clustering: Groups similar data points into clusters
|
| 164 |
-
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from sklearn.preprocessing import StandardScaler
|
| 9 |
from sklearn.datasets import make_blobs
|
| 10 |
|
| 11 |
+
# Set page config
|
| 12 |
+
st.set_page_config(
|
| 13 |
+
page_title="Machine Learning Visualizations",
|
| 14 |
+
layout="wide",
|
| 15 |
+
initial_sidebar_state="expanded"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
def generate_regression_data(n_samples=100, noise=10):
|
| 19 |
"""Generate data for linear regression visualization."""
|
| 20 |
np.random.seed(42)
|
|
|
|
| 35 |
X, _ = make_blobs(n_samples=n_samples, centers=3, cluster_std=1.5)
|
| 36 |
return X
|
| 37 |
|
| 38 |
+
def show_student_view():
|
| 39 |
+
"""Display the student view of the module."""
|
| 40 |
st.title("Interactive Machine Learning Visualizations")
|
| 41 |
|
| 42 |
# Introduction
|
|
|
|
| 63 |
# Generate and plot data
|
| 64 |
X, y = generate_regression_data(n_samples, noise)
|
| 65 |
|
| 66 |
+
# Create scatter plot with dark theme
|
| 67 |
fig = px.scatter(x=X.flatten(), y=y,
|
| 68 |
title="Linear Regression Visualization",
|
| 69 |
+
labels={'x': 'Feature (X)', 'y': 'Target (y)'},
|
| 70 |
+
template="plotly_dark")
|
| 71 |
|
| 72 |
# Add regression line
|
| 73 |
model = LinearRegression()
|
|
|
|
| 79 |
name='Regression Line',
|
| 80 |
line=dict(color='red')))
|
| 81 |
|
| 82 |
+
fig.update_layout(
|
| 83 |
+
plot_bgcolor='#1E1E1E',
|
| 84 |
+
paper_bgcolor='#1E1E1E',
|
| 85 |
+
font=dict(color='white')
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
st.plotly_chart(fig, use_container_width=True)
|
| 89 |
|
| 90 |
# Display model information
|
|
|
|
| 101 |
# Generate data
|
| 102 |
X, y = generate_classification_data()
|
| 103 |
|
| 104 |
+
# Create scatter plot with dark theme
|
| 105 |
fig = px.scatter(x=X[:, 0], y=X[:, 1],
|
| 106 |
color=y.astype(str),
|
| 107 |
title="Logistic Regression Visualization",
|
| 108 |
+
labels={'x': 'Feature 1', 'y': 'Feature 2'},
|
| 109 |
+
template="plotly_dark")
|
| 110 |
|
| 111 |
# Add decision boundary
|
| 112 |
model = LogisticRegression()
|
|
|
|
| 126 |
opacity=0.3,
|
| 127 |
colorscale='RdBu'))
|
| 128 |
|
| 129 |
+
fig.update_layout(
|
| 130 |
+
plot_bgcolor='#1E1E1E',
|
| 131 |
+
paper_bgcolor='#1E1E1E',
|
| 132 |
+
font=dict(color='white')
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
st.plotly_chart(fig, use_container_width=True)
|
| 136 |
|
| 137 |
# Display model information
|
|
|
|
| 155 |
kmeans = KMeans(n_clusters=n_clusters, random_state=42)
|
| 156 |
clusters = kmeans.fit_predict(X)
|
| 157 |
|
| 158 |
+
# Create scatter plot with dark theme
|
| 159 |
fig = px.scatter(x=X[:, 0], y=X[:, 1],
|
| 160 |
color=clusters.astype(str),
|
| 161 |
title="K-Means Clustering Visualization",
|
| 162 |
+
labels={'x': 'Feature 1', 'y': 'Feature 2'},
|
| 163 |
+
template="plotly_dark")
|
| 164 |
|
| 165 |
# Add cluster centers
|
| 166 |
fig.add_trace(go.Scatter(x=kmeans.cluster_centers_[:, 0],
|
| 167 |
y=kmeans.cluster_centers_[:, 1],
|
| 168 |
mode='markers',
|
| 169 |
+
marker=dict(size=12, symbol='star', color='white'),
|
| 170 |
name='Cluster Centers'))
|
| 171 |
|
| 172 |
+
fig.update_layout(
|
| 173 |
+
plot_bgcolor='#1E1E1E',
|
| 174 |
+
paper_bgcolor='#1E1E1E',
|
| 175 |
+
font=dict(color='white')
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
st.plotly_chart(fig, use_container_width=True)
|
| 179 |
|
| 180 |
# Display clustering information
|
|
|
|
| 190 |
- Linear Regression: Fits a line to predict continuous values
|
| 191 |
- Logistic Regression: Creates a decision boundary for classification
|
| 192 |
- K-Means Clustering: Groups similar data points into clusters
|
| 193 |
+
""")
|
| 194 |
+
|
| 195 |
+
def show_instructor_view():
|
| 196 |
+
"""Display the instructor view of the module."""
|
| 197 |
+
st.title("Instructor View: Machine Learning Module")
|
| 198 |
+
|
| 199 |
+
# Overview section
|
| 200 |
+
st.info("""
|
| 201 |
+
**Module Overview**
|
| 202 |
+
This module covers three fundamental machine learning concepts with interactive visualizations.
|
| 203 |
+
Students can experiment with different parameters and see real-time results.
|
| 204 |
+
""")
|
| 205 |
+
|
| 206 |
+
# Learning objectives
|
| 207 |
+
st.subheader("Learning Objectives")
|
| 208 |
+
st.markdown("""
|
| 209 |
+
1. Understand the basic principles of linear regression
|
| 210 |
+
2. Comprehend binary classification using logistic regression
|
| 211 |
+
3. Learn about unsupervised learning through k-means clustering
|
| 212 |
+
4. Develop intuition for model parameters and their effects
|
| 213 |
+
""")
|
| 214 |
+
|
| 215 |
+
# Student progress tracking
|
| 216 |
+
st.subheader("Student Progress Tracking")
|
| 217 |
+
progress_data = pd.DataFrame({
|
| 218 |
+
'Student': ['Student 1', 'Student 2', 'Student 3'],
|
| 219 |
+
'Linear Regression': [85, 90, 75],
|
| 220 |
+
'Logistic Regression': [80, 85, 70],
|
| 221 |
+
'Clustering': [90, 80, 85]
|
| 222 |
+
})
|
| 223 |
+
st.dataframe(progress_data)
|
| 224 |
+
|
| 225 |
+
# Common misconceptions
|
| 226 |
+
st.subheader("Common Misconceptions")
|
| 227 |
+
st.markdown("""
|
| 228 |
+
- Linear regression can only model linear relationships
|
| 229 |
+
- Logistic regression is only for binary classification
|
| 230 |
+
- K-means clustering always finds the optimal number of clusters
|
| 231 |
+
""")
|
| 232 |
+
|
| 233 |
+
# Teaching tips
|
| 234 |
+
st.subheader("Teaching Tips")
|
| 235 |
+
st.markdown("""
|
| 236 |
+
1. Start with simple examples and gradually increase complexity
|
| 237 |
+
2. Encourage students to experiment with different parameters
|
| 238 |
+
3. Use the visualizations to explain key concepts
|
| 239 |
+
4. Relate the concepts to real-world applications
|
| 240 |
+
""")
|
| 241 |
+
|
| 242 |
+
# Assessment guidelines
|
| 243 |
+
st.subheader("Assessment Guidelines")
|
| 244 |
+
st.markdown("""
|
| 245 |
+
- Evaluate understanding through interactive exercises
|
| 246 |
+
- Check comprehension of model parameters
|
| 247 |
+
- Assess ability to interpret results
|
| 248 |
+
- Review practical applications of each concept
|
| 249 |
+
""")
|
| 250 |
+
|
| 251 |
+
def show():
|
| 252 |
+
"""Main function to display the appropriate view based on user role."""
|
| 253 |
+
# Check if user role is set in session state
|
| 254 |
+
if 'user_role' not in st.session_state:
|
| 255 |
+
# If not set, show role selection
|
| 256 |
+
st.title("Welcome to the Machine Learning Module")
|
| 257 |
+
role = st.radio("Select your role:", ["Student", "Instructor"])
|
| 258 |
+
if st.button("Continue"):
|
| 259 |
+
st.session_state.user_role = role
|
| 260 |
+
st.experimental_rerun()
|
| 261 |
+
else:
|
| 262 |
+
# Display appropriate view based on role
|
| 263 |
+
if st.session_state.user_role == "Student":
|
| 264 |
+
show_student_view()
|
| 265 |
+
else:
|
| 266 |
+
show_instructor_view()
|
| 267 |
+
|
| 268 |
+
# Add option to switch roles
|
| 269 |
+
if st.sidebar.button("Switch Role"):
|
| 270 |
+
del st.session_state.user_role
|
| 271 |
+
st.experimental_rerun()
|