Skip to content

Commit

Permalink
Merge pull request #109 from paxtonfitzpatrick/master
Browse files Browse the repository at this point in the history
updated examples
  • Loading branch information
andrewheusser committed Aug 16, 2018
2 parents f561ac9 + 5f04f69 commit dbb0302
Show file tree
Hide file tree
Showing 15 changed files with 847 additions and 815 deletions.
757 changes: 374 additions & 383 deletions docs/tutorial/.ipynb_checkpoints/naturalistic-analyses-checkpoint.ipynb

Large diffs are not rendered by default.

757 changes: 374 additions & 383 deletions docs/tutorial/naturalistic-analyses.ipynb

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions examples/crack_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@
egg = quail.load('example')

#crack egg
cracked_egg = quail.crack_egg(egg, subjects=[0], lists=[0])
cracked_egg = egg.crack(subjects=[0], lists=[0])

cracked_egg.info()

pres = cracked_egg.get_pres_items().as_matrix()[0]
rec = cracked_egg.get_rec_items().as_matrix()[0]

def distmat(egg, feature, distdict):
f = [xi[feature] for xi in egg.get_pres_features()]
return cdist(f, f, distdict[feature])


for idx in range(len(rec)-1):
ind1 = np.where(pres==rec[idx])[0][0]
ind2 = np.where(pres==rec[idx+1])[0][0]
dists = dist[ind1, :]
cdist = dist[ind1, ind2]
rank = np.mean(np.where(np.sort(dists)[::-1] == cdist))
41 changes: 35 additions & 6 deletions examples/create_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,69 @@


# generate some fake data
next_presented = ['CAT', 'DOG', 'SHOE', 'HORSE']
next_recalled = ['HORSE', 'DOG', 'CAT']

next_features = [{
presented = [{
'item' : 'CAT',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'C',
'length' : 3
},
{
'item' : 'DOG',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'D',
'length' : 3
},
{
'item' : 'SHOE',
'category' : 'object',
'size' : 'smaller',
'starting letter' : 'S',
'length' : 4
},
{
'item' : 'HORSE',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'H',
'length' : 5
}
]

recalled = [{
'item' : 'HORSE',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'H',
'length' : 5
},
{
'item' : 'DOG',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'D',
'length' : 3
},
{
'item' : 'CAT',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'C',
'length' : 3
}
]

# set some custom distance functions
dist_funcs = {
'category' : 'lambda a, b: int(a!=b)',
'size' : 'lambda a, b: int(a!=b)',
'starting letter' : 'lambda a, b: int(a!=b)',
'length' : 'lambda a, b: np.linalg.norm(np.subtract(a,b))'
}
egg = quail.Egg(pres=[next_presented], rec=[next_recalled], features=[next_features], dist_funcs=dist_funcs)

egg.analyze('lagcrp').plot()
egg = quail.Egg(pres=[presented], rec=[recalled], dist_funcs=dist_funcs)

fegg = egg.analyze('lagcrp')

fegg.plot()
4 changes: 3 additions & 1 deletion examples/create_multisubject_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
egg = quail.Egg(pres=presented_words, rec=recalled_words)

# analyze and plot
egg.analyze('accuracy').plot(plot_style='violin', title='Average Recall Accuracy')
fegg = egg.analyze('accuracy')

fegg.plot(plot_style='violin', title='Average Recall Accuracy')
2 changes: 1 addition & 1 deletion examples/decode_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# decode speech
recall_data = quail.decode_speech('../data/sample.wav', save=True,
speech_context=['DONKEY', 'PETUNIA'],
keypath='/Users/andyheusser/Documents/cdl/credentials/efficient-learning-553bf474f805.json')
keypath='path/to/key.json')

# print results
print(recall_data)
41 changes: 36 additions & 5 deletions examples/fingerprint_optimalpresenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,66 @@
from quail import Fingerprint, OptimalPresenter

# generate some fake data
next_presented = ['CAT', 'DOG', 'SHOE', 'BAT']
next_recalled = ['DOG', 'CAT', 'BAT', 'SHOE']

next_features = [{
next_presented = [{
'item' : 'CAT',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'C',
'length' : 3
},
{
'item' : 'DOG',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'D',
'length' : 3
},
{
'item' : 'SHOE',
'category' : 'object',
'size' : 'smaller',
'starting letter' : 'S',
'length' : 4
},
{
'item' : 'BAT',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'B',
'length' : 3
}]

egg = quail.Egg(pres=[next_presented], rec=[next_recalled], features=[next_features])
next_recalled = [{
'item' : 'DOG',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'D',
'length' : 3
},
{
'item' : 'CAT',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'C',
'length' : 3
},
{
'item' : 'BAT',
'category' : 'animal',
'size' : 'bigger',
'starting letter' : 'B',
'length' : 3
},
{
'item' : 'SHOE',
'category' : 'object',
'size' : 'smaller',
'starting letter' : 'S',
'length' : 4
}
]

egg = quail.Egg(pres=[next_presented], rec=[next_recalled])

# initialize fingerprint
fingerprint = Fingerprint(init=egg)
Expand Down
4 changes: 3 additions & 1 deletion examples/plot_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
egg = quail.load('example')

# analyze and plot
egg.analyze('fingerprint', listgroup=['average']*8, features=['temporal']).plot(title='Memory Fingerprint')
fegg = egg.analyze('fingerprint', listgroup=['average']*8, features=['temporal'])

fegg.plot(title='Memory Fingerprint')
4 changes: 3 additions & 1 deletion examples/plot_lagcrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
egg = quail.load('example')

# analyze and plot
egg.analyze('lagcrp', listgroup=['average']*8).plot(title='Lag-CRP')
fegg = egg.analyze('lagcrp', listgroup=['average']*8)

fegg.plot(title='Lag-CRP')
9 changes: 4 additions & 5 deletions examples/plot_pfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import quail

#load data
egg = quail.load_example_data()
egg = quail.load('example')

# analysis
analyzed_data = quail.analyze(egg, analysis='pfr', listgroup=['average']*8)
# analyze and plot
fegg = egg.analyze('pfr', listgroup=['average']*8)

# plot
quail.plot(analyzed_data, title='Probability of First Recall')
fegg.plot(title='Probability of First Recall')
9 changes: 4 additions & 5 deletions examples/plot_pnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
import quail

#load data
egg = quail.load_example_data()
egg = quail.load('example')

# analysis
analyzed_data = quail.analyze(egg, analysis='pnr', listgroup=['average']*8,
# analyze and plot
fegg = egg.analyze('pnr', listgroup=['average']*8,
position=5)

# plot
quail.plot(analyzed_data, title='Probability of Recall')
fegg.plot(title='Probability of Recall')
6 changes: 4 additions & 2 deletions examples/plot_spc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import quail

#load data
egg = quail.load_example_data()
egg = quail.load('example')

# analyze and plot
egg.analyze('spc', listgroup=['average']*8).plot(title='Serial Position Curve')
fegg = egg.analyze('spc', listgroup=['average']*8)

fegg.plot(title='Serial Position Curve')
9 changes: 4 additions & 5 deletions examples/plot_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import quail

#load data
egg = quail.load_example_data()
egg = quail.load('example')

#analysis
analyzed_data = quail.analyze(egg, analysis='temporal', listgroup=['early']*4+['late']*4)
#analyze and plot
fegg = egg.analyze('temporal', listgroup=['early']*4+['late']*4)

#plot
quail.plot(analyzed_data, title='Temporal Clustering')
fegg.plot(title='Temporal Clustering')
Binary file modified quail/data/naturalistic.egg
Binary file not shown.
2 changes: 1 addition & 1 deletion quail/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def update(self, egg, permute=False, nperms=1000,
pass_features=True,
permute=permute,
n_perms=nperms,
parallel=parallel).as_matrix(), 0)
parallel=parallel).values, 0)

if self.state is not None:

Expand Down

0 comments on commit dbb0302

Please sign in to comment.