Try out R-W learning of various number marking systems using data from Ramscar, et al. (2011).
In [1]:
import pandas as pd
import pandas.rpy.common as com
import numpy as np
from sklearn.feature_extraction import DictVectorizer
import ndl
%load_ext autoreload
%autoreload 2
%load_ext rmagic
%matplotlib inline
%precision 2
pd.set_option('display.precision', 2)
In [2]:
%%R
library(ndl)
In [3]:
data = com.load_data('numbers')
data['Cues'] = [x.split('_') for x in data['Cues']]
data['Number'] = data['Outcomes']
data
Out[3]:
In [4]:
data['Outcomes'] = 'plural'
data['Outcomes'][1] = 'singular'
data
Out[4]:
In [7]:
W = ndl.rw(data,M=100)
W
Out[7]:
In [8]:
def activation(W):
return pd.DataFrame([ndl.activation(c,W) for c in data.Cues],index=data.index)
In [9]:
activation(W)
Out[9]:
In [10]:
data['Outcomes'] = 'plural'
data['Outcomes'][1] = 'singular'
data['Outcomes'][2] = 'dual'
W = ndl.rw(data,M=100)
activation(W)
Out[10]:
In [12]:
data['Outcomes'] = 'plural'
data['Outcomes'][1] = 'singular'
data['Outcomes'][2] = 'dual'
data['Outcomes'][3] = 'trial'
W = ndl.rw(data,M=100)
activation(W)
Out[12]:
In [13]:
data['Outcomes'] = 'plural'
data['Outcomes'][1] = 'singular'
data['Outcomes'][2] = 'dual'
data['Outcomes'][3] = 'trial'
data['Outcomes'][4] = '4ial'
W = ndl.rw(data,M=100)
activation(W)
Out[13]:
In [16]:
data['Outcomes'] = 'notdual'
data['Outcomes'][1] = 'notdual'
data['Outcomes'][2] = 'dual'
W = ndl.rw(data,M=100)
activation(W)
Out[16]:
In [ ]: