run_trust.py 977 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/python3
  2. import csv
  3. def create_trust_file(filename):
  4. with open('sources_carlos_final.txt', mode='r') as infile:
  5. reader = csv.reader(infile)
  6. mysources = dict()
  7. for row in reader:
  8. key = row[0]
  9. mysources[key] = row[1:]
  10. with open(filename, mode='r') as infile:
  11. reader = csv.reader(infile)
  12. allpreds = dict()
  13. for row in reader:
  14. key = row[0]
  15. allpreds[key] = row[1:]
  16. mypreds = dict()
  17. total_preds = 0
  18. total_real = 0
  19. for i in mysources:
  20. if i in allpreds:
  21. mypreds[i] = allpreds[i]
  22. pred = float(allpreds[i][0])
  23. if (pred < 0):
  24. pred = 0.0
  25. real = float(allpreds[i][1])
  26. total_preds += pred
  27. total_real += real
  28. print(mypreds)
  29. print(total_preds, total_real)
  30. if __name__ == '__main__':
  31. create_trust_file('output-Errors6smoothing6neurons10.txt')