The relevant part of my code is here *Edit: did not include the outer loop the first time.
for i in range(numAttributes):
for w in range(numFeatures):
if X[i][w]!=0:
print ("Setting nFeat[",y[i],"][",w,"]")
self._Nfeat[y[i]][w]=1
print self._Nfeat[3][numFeatures-1]
if self._Nfeat[3][numFeatures-1]!=0:
print("y[i] is: ", y[i]," and w is: ", w)
sys.exit()
essentially self._Nfeat[3][numFeatures-1]
is being set to 1 when it shouldnt be. The print
statements and final if
statement are all put in for debugging.
The last 4 things output are:
0
setting nFeat[1][265676]
1
y[i] is 1 and w is 26576
I have also placed other if self._Nfeat[3][numFeatures-1]!=0
checks in other places and determined it is definitely happening right before the current placement.
This has left me very confused as self._Nfeat[3][numFeatures-1]
seems to be being changed when it shouldnt.
the list self._Nfeat is initialized in init with:
self._Nfeat=[]
At the start of the method it is then reinitialized with
self._Nfeat=[[0]*numFeatures]*numClasses
There is no where else in the code which deals with this list at all.
I am new to python and would appreciate any help greatly