Futrell2018 SPRT benchmark using GAMs + control predictors#107
Open
Futrell2018 SPRT benchmark using GAMs + control predictors#107
Conversation
mschrimpf
reviewed
Dec 31, 2022
| data_mask = ~data.isna().any(axis=1) | ||
| data = data[data_mask] | ||
|
|
||
| # TODO check that columns match formula variable names |
| data["prev_surp"] = data["surprisal"].shift(1) | ||
| data["len"] = self.data[data_mask].word_core.str.len() | ||
| data["prev_len"] = data["len"].shift(1) | ||
| data["freq"] = surprisals # HACK need to look this up. |
| r_mgcv = importr("mgcv") | ||
| model = r_mgcv.gam(formula, data=data) | ||
|
|
||
| # TODO held out data |
Comment on lines
+81
to
+89
| surprisals = candidate.digest_text(stimuli)['behavior'] | ||
| attach_presentation_meta(surprisals, self.data['presentation']) | ||
|
|
||
| # exclude first words | ||
| surprisals = surprisals[surprisals['word_within_sentence_id'] != 1] | ||
| data_mask = self.data['word_within_sentence_id'] != 1 | ||
|
|
||
| # Fit and evaluate GAM model | ||
| model, predictions, targets = self.fit(surprisals, data_mask) |
Member
There was a problem hiding this comment.
Suggested change
| surprisals = candidate.digest_text(stimuli)['behavior'] | |
| attach_presentation_meta(surprisals, self.data['presentation']) | |
| # exclude first words | |
| surprisals = surprisals[surprisals['word_within_sentence_id'] != 1] | |
| data_mask = self.data['word_within_sentence_id'] != 1 | |
| # Fit and evaluate GAM model | |
| model, predictions, targets = self.fit(surprisals, data_mask) | |
| model_reading_times = candidate.digest_text(stimuli)['behavior'] | |
| attach_presentation_meta(surprisals, self.data['presentation']) | |
| # exclude first words | |
| model_reading_times = model_reading_times[model_reading_times['word_within_sentence_id'] != 1] | |
| data_mask = self.data['word_within_sentence_id'] != 1 | |
| # Fit and evaluate GAM model | |
| model, predictions, targets = self.fit(model_reading_times, data_mask) |
| return score | ||
|
|
||
|
|
||
| class SplitHalvesConsistency: |
Member
There was a problem hiding this comment.
could from ../futrell2018.benchmark import SplitHalvesConsistency (
benchmarks/futrell2018 plugin? I'm fine with either, slightly leaning towards adding this to the futrell2018 plugin
Member
|
Hi @hans just checking in on this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm starting a benchmark implementation for reading time evaluation that uses control predictors (word length and frequency; spillover effects from previous word(s)) as well as a more advanced statistical model (GAMs).
FWIW this PR is also a fun test case of a benchmark with Conda dependencies (needs R and an R package, which obviously can't be installed via pip).
Still to-do (& happy to accept help if anyone is interested):
mgcv.