In the read_features() function, you just init a dict, and record the feature names and the first user which get this feature!! Nonsense!! Lost of Data.
I rewrite the code and test on upper file, and clearly you lost many data! Wrong Badly.
def read_features(file): # read a feature file
features = {}
i = len(features)
with open(file) as f:
for line in f:
items = line.strip().split(' ')
for item in items[1:]: # ['51798:1', '2473:1', '37583:1']
if item not in features:
features[item] = i
i = i + 1
else:
print('nfm load code error', i, item)
return features
https://github.com/hexiangnan/neural_factorization_machine/blob/master/LoadData.py#L47
In the
read_features()
function, you just init a dict, and record the feature names and the first user which get this feature!! Nonsense!! Lost of Data.This is a preview of
ml-tag.test.libfm
file:I rewrite the code and test on upper file, and clearly you lost many data! Wrong Badly.