Discriminative learning


In [1]:
import pandas as pd
import matplotlib.pyplot as plt

import ndl

%matplotlib inline

%precision 3
pd.set_option('display.precision', 3)

In [2]:
data = pd.DataFrame()
data['Cues'] = [('A','X'),('B','X')]
data['Outcomes'] = ['yes', 'no']
data['Frequency'] = [1,1]
data


Out[2]:
Cues Outcomes Frequency
0 (A, X) yes 1
1 (B, X) no 1

In [3]:
W = [w['yes'] for w in ndl.rw(data, M=500, trajectory=True)]
W = pd.DataFrame(W)

In [19]:
for c, s in zip(W.columns, ['-','--','-.']):
    plt.plot(W[c], label=c, linestyle=s)
plt.legend(loc='upper left', bbox_to_anchor=(0.025, 0.975), ncol=3, fontsize='small')
plt.xlabel('Trial')
plt.ylabel('Weight')
fig = plt.gcf()
fig.set_size_inches(4,2.67)
plt.savefig('discrim1.pdf')



In [20]:
plt.plot(W['A']+W['X'], label='AX', linestyle='-')
plt.plot(W['B']+W['X'], label='BX', linestyle='--')

plt.legend(loc='upper left', bbox_to_anchor=(0.025, 0.975), ncol=3, fontsize='small')
plt.xlabel('Trial')
plt.ylabel('Activation')
fig = plt.gcf()
fig.set_size_inches(4,2.67)
plt.savefig('discrim2.pdf')



In [ ]: