Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

debug

  • Loading branch information...
commit 10224112c40b36ab50514015ce5828119033f130 1 parent 23279c1
@Ykid Ykid authored
View
2  config.py
@@ -44,7 +44,7 @@
################### Select Parts ##################
LAPTOP_TEST = True # uses small data set to run features on laptop
-TRIALS = 2
+TRIALS = 1
PRE_PROCESS = True
DE_EFFECT = False #If De-effect is false, model predictions are correct
SETUP_MODELS = True
View
22 utils/ImplicitFeedbackFunctions.py
@@ -29,22 +29,26 @@ def reIndex_Implicit(fin):#, fout):
iidDic[iid]=newiid
newiid+=1
- # fo.write('%d\t%d\t%d\n' %(uidDic[uid],iidDic[iid],rating))
+ #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()}
+ #uidCorrespondence={value:key for key,value in uidDic.items()}
+ #iidCorrespondence={value:key for key,value in iidDic.items()}
print("finished")
- return(uidCorrespondence,iidCorrespondence,avg)
+ return(uidDic,iidDic,avg)
def translate(fin,fout,Udic,ItemDic):
print("start translation.Tranlating " +fin+" .")
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())
@@ -58,6 +62,12 @@ 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()
print("translation finished.")
@@ -69,7 +79,7 @@ def userfeedback(fname):
attr = line.strip().split('\t')
uid = int(attr[0])-1
iid = int(attr[1])-1
- if feedback.has_key(uid):
+ if uid in feedback:
feedback[uid].append(iid)
else:
feedback[uid] = [iid]
@@ -85,7 +95,7 @@ def usergroup(fname):
for line in fi:
attr = line.strip().split('\t')
uid = int(attr[0])-1
- if groupnum.has_key(uid):
+ if uid in groupnum:
groupnum[uid] += 1
else:
groupnum[uid] = 1
View
37 utils/SVDModel.py
@@ -155,12 +155,15 @@ def reIndex(self):
def dataConvert(self):
import os
- os.system(self.SVDBufferPath + ' ' +
- self.featTrain + ' ' + self.runTrain)
- os.system(self.SVDBufferPath + ' ' +
- self.featCV + ' ' + self.runCV )
- os.system(self.SVDBufferPath + ' ' +
- self.featTest + ' ' + self.runTest )
+ if self.featureSet == 'Basic':
+ os.system(self.SVDBufferPath + ' ' +
+ self.featTrain + ' ' + self.runTrain)
+ os.system(self.SVDBufferPath + ' ' +
+ self.featCV + ' ' + self.runCV )
+ os.system(self.SVDBufferPath + ' ' +
+ self.featTest + ' ' + self.runTest )
+ if self.featureSet == 'ImplicitFeedback':
+
def writeConfig(self):
import os
@@ -188,8 +191,9 @@ def writeConfig(self):
fout.write('model_out_folder = \"' + self.modelOutPath
+ self.tag + '_t' + self.trial + '\"')
if self.featureSet == 'ImplicitFeedback':
- fout.write("format_type = " + self.formatType + '\n')
- fout.write("num_ufeedback = " + self.numUserFeedback + '\n')
+ fout.write('\n')
+ fout.write("format_type = " + str(self.formatType) + '\n')
+ fout.write("num_ufeedback = " + str(self.numUserFeedback) + '\n')
fout.write("wd_ufeedback = " + self.regularizationFeedback + '\n')
os.system('mkdir ' + self.modelOutPath
@@ -246,7 +250,7 @@ def fixRun(self):
def setupImplicitFeatures(self):
import os
#reindex the training files and build two dicts
- Udic,ItemDic,avg=IFF.reIndex_Implicit(self.bootTrain,self.tmpTrain)
+ Udic,ItemDic,avg=IFF.reIndex_Implicit(self.originDataSet)
#reindex the history
IFF.translate(self.userHistoryPath, self.userHistoryReindexPath, Udic, ItemDic)
#reindex CV file
@@ -257,15 +261,16 @@ def setupImplicitFeatures(self):
IFF.translate(self.bootTrain,self.tmpTrain,Udic,ItemDic)
#make group training files
- os.system(self.SVDFeatureLineReorder +' '+ self.tmpTrain + \
- ' '+ self.tmpLineOrder)
- os.system(self.SVDFeatureSVDPPRandOrder + ' ' + self.tmpTrain + \
- ' ' + self.tmpLineOrder + ' ' + self.tmpGpTrain)
+ command=self.SVDFeatureSVDPPRandOrder +' '+ self.tmpTrain + ' ' + self.tmpLineOrder
+ os.system(command)
+
+ anothercommand=self.SVDFeatureLineReorder + ' ' + self.tmpTrain + ' ' + self.tmpLineOrder + ' ' + self.tmpGpTrain
+ os.system(anothercommand)
#make group training files of the CV set
- os.system(self.SVDFeatureLineReorder +' '+ self.tmpCV + \
+ os.system(self.SVDFeatureSVDPPRandOrder +' '+ self.tmpCV + \
' '+ self.tmpLineOrder)
- os.system(self.SVDFeatureSVDPPRandOrder + ' ' + self.tmpCV + \
+ os.system(self.SVDFeatureLineReorder + ' ' + self.tmpCV + \
' ' + self.tmpLineOrder + ' ' + self.tmpGpCV)
#make basic feature files
@@ -283,7 +288,7 @@ def setupImplicitFeatures(self):
self.numMovie=len(ItemDic)
self.avg=avg
self.numGlobal = 0
- self.activeType = 0
+ self.activeType = '0'
self.formatType = 1
self.numUserFeedback = len(ItemDic)
View
3  utils/utils.py
@@ -49,8 +49,9 @@
#### SVD Feature ###
SVDFEATURE_BUFFER_BINARY = './Models/SVDFeature/tools/make_feature_buffer'
+SVDFEATURE_GROUP_BUFFER_BINARY = './Models/SVDFeature/tools/make_ugroup_buffer'
SVDFEATURE_LINE_REORDER = './Models/SVDFeature/tools/line_reorder'
-SVDFEATURE_SVDPP_RANDORDER = './Models/SVDFeature/tools/svdpp_randorder`'
+SVDFEATURE_SVDPP_RANDORDER = './Models/SVDFeature/tools/svdpp_randorder'
SVDFEATURE_BINARY = './Models/SVDFeature/svd_feature'
SVDFEATURE_INFER_BINARY = './Models/SVDFeature/svd_feature_infer'
SVDFEATURE_MODEL_OUT_PATH = 'Data/ModelData/'
Please sign in to comment.
Something went wrong with that request. Please try again.