Skip to content

Commit a8f978d

Browse files
Merge pull request #97 from ContextLab/revision-1
complete revision
2 parents aed9bfe + f106cc2 commit a8f978d

File tree

77 files changed

+9446
-1256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+9446
-1256
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ paper/**/*.out
4343
paper/**/*.synctex.gz
4444
paper/**/*.blg
4545
paper/**/*.bbl
46+
texput.log

code/khan_helpers/khan_helpers/functions.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def corr_mean(rs, axis=None, fix_inf=False, **kwargs):
170170
Axis or axes along which the means are computed. If `None`
171171
(default), the mean of the flattened array is computed.
172172
fix_inf : bool, optional
173-
See `z2r()` docstring for details. Default: False.
173+
See `r2z()` docstring for details. Default: False.
174174
**kwargs : various types, optional
175175
Additional keyword arguments passed to `numpy.nanmean` (see
176176
https://numpy.org/doc/stable/reference/generated/numpy.nanmean.html
@@ -622,7 +622,7 @@ def preprocess_text(textlist, correction_counter=None):
622622
POS tagging, and lemmatization.
623623
624624
Occasionally, the Treebank POS tagger mis-tags a word, which causes
625-
WordNet's "Morphy" to apply the morphologocal transformations and
625+
WordNet's "Morphy" to apply the morphological transformations and
626626
detachment rules for the wrong syntactic category, and fail to
627627
lemmatize the word. The function attempts to handle these
628628
instances and can optionally record corrections made this way for
@@ -683,7 +683,7 @@ def preprocess_text(textlist, correction_counter=None):
683683
# to original chunk
684684
chunk_delimiter = 'chunkdelimiter'
685685
processed_chunks = [[] for _ in textlist]
686-
# clean spacing, normalize case, strip puncutation
686+
# clean spacing, normalize case, strip punctuation
687687
# (temporarily leave punctuation useful for POS tagging)
688688
full_text = f' {chunk_delimiter} '.join(textlist).lower()
689689
punc_stripped = re.sub("[^a-zA-Z\s']+", '', full_text.replace('-', ' '))
@@ -783,7 +783,7 @@ def rbf_sum(obs_coords, pred_coords, width, metric='euclidean'):
783783
width : scalar
784784
The Width of the Gaussian kernel.
785785
metric : str or callable, optional
786-
The metric used to compute the pairwise distance between
786+
The metric used to compute the pairwise distances between
787787
coordinates (default: `'euclidean'`, Euclidean distance). May be
788788
any named metric accepted by `scipy.spatial.distance.cdist` or a
789789
callable that takes two `array_like` arguments.
@@ -806,14 +806,14 @@ def reconstruct_trace(lecture, questions, accuracy):
806806
807807
Parameters
808808
----------
809-
lecture: numpy.ndarray
809+
lecture : numpy.ndarray
810810
`(n_coordinates, n_features)` matrix of coordinates for which to
811811
estimate knowledge.
812-
questions: numpy.ndarray
812+
questions : numpy.ndarray
813813
`(n_observations, n_features)` matrix of coordinates for the
814814
quiz questions used to estimate knowledge for each of the
815815
`n_coordinates` locations.
816-
accuracy: array_like
816+
accuracy : array_like
817817
`(n_observations,)` binary array denoting whether each question
818818
was answered correctly (`True`|`1`) or incorrectly
819819
(`False`/`0`).
@@ -963,3 +963,5 @@ def z2r(z):
963963
Correlation value(s).
964964
"""
965965
return (np.exp(2 * z) - 1) / (np.exp(2 * z) + 1)
966+
967+

code/khan_helpers/khan_helpers/participant.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,16 @@ def get_data(self, lecture=None, quiz=None):
137137
def get_kmap(self, kmap_key):
138138
"""
139139
dict.get()-like access to self.knowledge_maps
140-
:param trace_key: str
141-
The key for the trace to be returned
142-
:return: trace: np.ndarray
143-
The trace stored under the given `trace_key`
140+
141+
Parameters
142+
----------
143+
kmap_key : str
144+
The key for the knowledge map to be returned
145+
146+
Returns
147+
-------
148+
kmap : numpy.ndarray
149+
The knowledge map stored under the given `kmap_key`
144150
"""
145151
try:
146152
return self.knowledge_maps[kmap_key]
@@ -154,10 +160,16 @@ def get_kmap(self, kmap_key):
154160
def get_trace(self, trace_key):
155161
"""
156162
dict.get()-like access to self.traces
157-
:param trace_key: str
158-
The key for the trace to be returned
159-
:return: trace: np.ndarray
160-
The trace stored under the given `trace_key`
163+
164+
Parameters
165+
----------
166+
trace_key : str
167+
The key for the trace to be returned
168+
169+
Returns
170+
-------
171+
trace : numpy.ndarray
172+
The trace stored under the given `trace_key`
161173
"""
162174
try:
163175
return self.traces[trace_key]

code/notebooks/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
This folder contains notebooks to replicate analyses and figures from the
2-
[paper](../../per/main.pdf). Notebooks are generally ordered according to when
2+
[paper](../../paper/main.pdf). Notebooks are generally ordered according to when
33
analyses are described or figures appear in the paper.
44

55
### `main/`
66
**code to reproduce analyses and figures from the main text**
7-
- `1_model-course-content.ipynb` – code to fit the topic model, transform lectures & quizzes, and generate Figure 2C
7+
- `1_model-course-content.ipynb` – code to fit the topic model, transform lectures & quiz questions, and generate Figure 2C
88
- `2_topic-variability-fig.ipynb` – code to generate Figure 3 and compute related stats
99
- `3_lecture-question-timeseries-fig.ipynb` – code to generate Figure 4
1010
- `4_reconstructing-knowledge.ipynb` – code to estimate dynamic knowledge traces, generate Figure 5, and compute related stats
1111
- `5_predictive-analyses.ipynb` – code to generate Figure 6
12-
- `6_knowledge-maps.ipynb` – code to construct knowledge maps and generate Figure 7
13-
- `7_parse_demographics.ipynb` – code to compile demographic data described in _Methods_
14-
- `8_get-transcripts.ipynb` – code to fetch automated transcripts from the YouTube API as described in _Methods_
12+
- `6_knowledge-smoothness.ipynb` – code to generate Figure 7
13+
- `7_knowledge-maps.ipynb` – code to construct knowledge maps and generate Figure 8
14+
- `8_parse_demographics.ipynb` – code to compile demographic data described in _Methods_
15+
- `9_get-transcripts.ipynb` – code to fetch automated transcripts from the YouTube API as described in _Methods_
1516

1617
### `supp/`
1718
**code to reproduce tables and figures from the Supplementary Materials document**
18-
- `1_tables.ipynb` – code to generate Supplementary Tables 1 & 2
19+
- `1_tables.ipynb` – code to generate Supplementary Tables 1, 2, and 3, and compute the correlation timeseries peaks shown in Supplementary Figures 3 & 4
1920
- `2_topic-word-distributions-fig.ipynb` – code to generate Supplementary Figure 1
20-
- `2_topic-weight-fig.ipynb` – code to generate Supplementary Figure 2 and compute related stats
21-
- `3_individual-maps.ipynb` – code to generate Supplementary Figures 2–6
21+
- `3_topic-weight-fig.ipynb` – code to generate Supplementary Figure 2 and compute related stats
22+
- `4_lecture-question-correlation-peaks.ipynb` – code to generate Supplementary Figures 3 & 4
23+
- `5_model-comparison-BERT.ipynb` – code to generate Supplementary Figure 5
24+
- `6_individual-maps.ipynb` – code to generate Supplementary Figures 2–6

code/notebooks/main/5_predictive-analyses.ipynb

Lines changed: 416 additions & 102 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)