Skip to content

Commit

Permalink
clean the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ykid committed Aug 1, 2013
1 parent da7439c commit e4b43fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
17 changes: 1 addition & 16 deletions utils/ImplicitFeedbackFunctions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys
def reIndex_Implicit(fin):#, fout):
def reIndex_Implicit(fin):
print("Reindexing Origin Data Set and Buiding the Correspondence Dics")
fi = open( fin, 'r' ) #training set
#fo = open( fout, 'w') #reindexed training set
#extract from input file
uidDic={}
iidDic={}
Expand All @@ -29,14 +28,9 @@ def reIndex_Implicit(fin):#, fout):
iidDic[iid]=newiid
newiid+=1

#fo.write('%d\t%d\t%d\n' %(uidDic[uid],iidDic[iid],rating))
#fo.close()
fi.close()
#calculate different parameter.
avg=sum/ctr
#switch the key and the value in both dictionaries
#uidCorrespondence={value:key for key,value in uidDic.items()}
#iidCorrespondence={value:key for key,value in iidDic.items()}
print("finished")
return(uidDic,iidDic,avg)

Expand All @@ -45,10 +39,6 @@ def translate(fin,fout,Udic,ItemDic):
fi=open(fin,'r')
fo=open(fout,'w')
#translate the file
#test things
writectr=0
userNotFound=0
ItemNotFound=0
for line in fi:
arr=line.split()
uid=int(arr[0].strip())
Expand All @@ -62,11 +52,6 @@ def translate(fin,fout,Udic,ItemDic):
else:
writeline=str(Udic[uid])+'\t'+str(ItemDic[iid])+'\r\n'
fo.write(writeline)
writectr+=1
else:
ItemNotFound+=1
else:
userNotFound+=1

fi.close()
fo.close()
Expand Down
7 changes: 2 additions & 5 deletions utils/SVDModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,8 @@ def setupImplicitFeatures(self):
IFF.translate(self.bootTrain,self.tmpTrain,Udic,ItemDic)

#make group training files
command=self.SVDFeatureSVDPPRandOrder +' '+ self.tmpTrain + ' ' + self.tmpLineOrder
os.system(command)

anothercommand=self.SVDFeatureLineReorder + ' ' + self.tmpTrain + ' ' + self.tmpLineOrder + ' ' + self.tmpGpTrain
os.system(anothercommand)
os.system(self.SVDFeatureSVDPPRandOrder +' '+ self.tmpTrain + ' ' + self.tmpLineOrder)
os.system(self.SVDFeatureLineReorder + ' ' + self.tmpTrain + ' ' + self.tmpLineOrder + ' ' + self.tmpGpTrain)

#make group training files of the CV set
os.system(self.SVDFeatureSVDPPRandOrder +' '+ self.tmpCV + \
Expand Down

0 comments on commit e4b43fd

Please sign in to comment.