Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
91 lines (60 sloc) 1.52 KB

Example: XOR

The exclusive or (XOR) is a logical operation that outputs true when inputs differ.

import numpy as np
import pandas as pd
from lapart import train,test
xtrain = pd.read_csv('xor_train.csv').as_matrix()
xAtest = pd.read_csv('xor_test.csv').as_matrix()
xAtrain,xBtrain = xtrain[:,0:2],xtrain[:,2:3]
xAtrain
array([[ 0. ,  0. ],
       [ 1. ,  0. ],
       [ 0. ,  1. ],
       [ 1. ,  1. ],
       [ 1. ,  1. ],
       [ 0.9,  0.9],
       [ 0.1,  0.8],
       [ 0.2,  0.2],
       [ 1. ,  1. ]])
xBtrain
array([[ 0. ],
       [ 1. ],
       [ 1. ],
       [ 0. ],
       [ 0. ],
       [ 0.1],
       [ 0.8],
       [ 0. ],
       [ 0. ]])
xAtest
array([[ 0.1 ,  0.9 ],
       [ 1.  ,  0.  ],
       [ 0.  ,  0.  ],
       [ 1.  ,  1.  ],
       [ 0.  ,  1.  ],
       [ 0.15,  0.1 ]])
rA,rB = 0.8,0.8
TA,TB,L,t = train.lapArt_train(xAtrain,xBtrain,rhoA=rA,rhoB=rB,memory_folder='templates',update_templates=False)
C,T,Tn,df,t = test.lapArt_test(xAtest,rhoA=rA,rhoB=rB,memory_folder='templates')
C
array([[ 1.],
       [ 1.],
       [ 0.],
       [ 0.],
       [ 1.],
       [ 0.]])