New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MRG: Tracker dealer example #310
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind posting what the plot looks like after it runs?
examples/stimuli/tracker_dealer.py
Outdated
:class:'expyfun.stimuli.TrackerDealer' | ||
|
||
In this case, a modeled human subject generates two curves (one for each trial | ||
type: 1 & w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 and 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops...
examples/stimuli/tracker_dealer.py
Outdated
rng = np.random.RandomState(1) | ||
|
||
while not tr.stopped: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need a blank line after while
, if
, etc.
examples/stimuli/tracker_dealer.py
Outdated
|
||
# Plot the results | ||
for i in [0, 1]: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, no blank line.
Cool, looks like it's working. They're probably better as subplots so only one plot is made, and that can serve as the thumbnail for the documentation. |
I have a real-life use case I need to make -- maybe this can be adapted so I can be lazy and copy-paste more easily. KC wants interleaved adaptive tracking, one from above and one from below. This is a thing, right @rkmaddox? And |
Yes, it could easily do it. You just make two trackers in However, while a fine application, it's not what it was made to do. The reason for making So I think the example should stay as is, but it should be super easy for you to do what you want. I am more than happy to help with that if it isn't clear from the docs and example how to do it. EDIT: it is worth pointing out the only reason this can do it is because of the changes you forced me to make to the way |
FYI @maddycapp27 a better way to get at what @rkmaddox asked about is to look at CircleCI, which builds all examples. You can see the output if you click the link (sign in with GitHub on CircleCI) and then follow the "Artifacts" tab to the HTML output like here: |
Yes please make a PR to add docs and ideally an example if you or @maddycapp27 have time |
On the link @Eric89GXL sent, it looks like ":class:’expyfun.stimuli.TrackerDealer’" isn't rendering properly. |
There are docs for |
The render is my bad--used the wrong ` |
I was concerned that your statement about it not being designed to handle interleaved top-down / bottom-up (or whatever it's called) meant there had to be some special treatment. If no docs are necessary, it would be good from a pedagogical standpoint to have a simple example, at least so that folks like me can get the terminology right :) |
Yeah, happy to make an example. It will be a very small modification of @maddycapp27's. The docs don't have any wording about how it should be used, so I think your use case is just as legit as what it was designed for. But a separate example is the best way to show that I think. |
When this PR gets merged, I'll ask @maddycapp27 to make the modifications and submit another PR based on that successful one. |
Awesome, thanks |
Glad to see that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor tweaks, otherwise LGTM
examples/stimuli/tracker_dealer.py
Outdated
lower=chance, slope=slope)) | ||
|
||
# Plot the results | ||
axes = [plt.subplot(211), plt.subplot(212)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axes = plt.subplots(2, 1)[1]
examples/stimuli/tracker_dealer.py
Outdated
ax.legend(loc='best') | ||
ax.set_title('Adaptive track of model human trial type {} (true threshold ' | ||
'is {})'.format(i + 1, true_thresh[i])) | ||
plt.tight_layout() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid global plt
commands, prefer fig.tight_layout()
here
from expyfun.analyze import sigmoid | ||
import matplotlib.pyplot as plt | ||
|
||
# define parameters of modeled subject (using sigmoid probability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI if you want you can make pretty sections in the output like this:
that render like this:
might be overkill in this example but it's something to consider when writing pedagogical examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll definitely keep that in mind for the future! For this example, I agree that it's not very necessary though.
examples/stimuli/tracker_dealer.py
Outdated
|
||
# parameters for the tracker dealer | ||
max_lag = 2 | ||
rand = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @Eric89GXL usually likes this to be called rng
. And I think in this case it is better to seed it, so rng = np.random.RandomState(0)
. Mess around with the seed value until you get plots that end up with thresholds within 1 or 2 of their true value. Seeding the RNGs will make the plots the same every time, and having the computed thresholds close to the the true ones in the example will be less confusing for people.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, ok, I was confused by that in the other example. Will fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, probably shouldn't have been None
there, either.
examples/stimuli/tracker_dealer.py
Outdated
@@ -52,7 +52,7 @@ def callback(event_type, value=None, timestamp=None): | |||
change_criteria, change_rule, x_min, x_max) for i in [0, 1]] | |||
|
|||
# initialize TrackerDealer object | |||
tr = TrackerDealer(tr_UD, max_lag, rand) | |||
tr = TrackerDealer(tr_UD, max_lag, rng) | |||
|
|||
# Initialize human state | |||
rng = np.random.RandomState(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it stylistically okay that I overwrite rng here? I could see it being confusing to someone just skimming the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to do rng_human
and rng_dealer
or something like that.
@rkmaddox feel free to merge when you and the CIs are happy |
@drammock feel free to look, too, if you want |
examples/stimuli/tracker_dealer.py
Outdated
up = 1 | ||
down = 1 | ||
step_size_up = [9, 3] | ||
step_size_down = [3, 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just so I'm clear... the first element of each of these is "initial step size" and the second element kicks in after change_criteria[1]
reversals have occured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct--do you think there should be a comment to that effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, a comment would be good (since initially I thought they were different values that were going to be fed into the two different TrackerUD
s that were getting created).
@Eric89GXL the appveyor error seems unrelated... I went in and tried to re-start that job but either I wasn't empowered to, or just couldn't figure out how. |
one last comment: when I pull down this branch, the permissions on |
I'm all for uniformity so if someone gets around to changing it, go ahead. But I wouldn't hold up the PR for it, as I don't think it should have much consequence. |
Is the permissions thing something I did? |
cool. if another example is going to get generated for @Eric89GXL's use case, maybe we can change the permissions on |
@maddycapp27 yes (though perhaps not intentionally). The executable bit is in fact the only aspect of file permissions that git keeps track of (it doesn't track user/group permissions). |
Certainly not intentionally (I'm a bit ignorant about such things). I'm not sure how to fix that. |
Something like chmod a-x tracker_dealer.py :) And I'm sure there are some around here who will appreciate your (un?)intentional "bit ignorant" pun... (for those that don't, we're talking about setting the executable bit) |
@Eric89GXL Thank you! Alas not an intentional pun~ I appreciate the explanation :) |
Thanks @maddycapp27, looking forward to the next example :) |
This is just a simple example for the TrackerDealer. It's pretty similar to the tracker staircase example but please let me know if there are any changes that should be made. Thanks much!