Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 18th, 2013  |  syntax: None  |  size: 1.53 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # initializing the first layer, a list of dictionaries.
  2.     experiments = []
  3.     for assignment in assignments:
  4.         match_sums = {}
  5.         experiments.append(match_sums)
  6.  
  7.  
  8. for i in xrange(len(classes)):
  9.         for experiment in xrange(len(experiments)):
  10.             # experiments[experiment][classes[i]] should hold a dictionary,
  11.             # where the keys are the things that were matched against classes[i],
  12.             # and the value is the number of times this occurred.
  13.             experiments[experiment][classes[i]] = collections.defaultdict(dict)
  14.  
  15.             # matches[experiment][i] is an integer for what the i'th match was in an experiment.
  16.             # classes[j] for some integer j is the string name of the i'th match. could be "dog" or "cat".
  17.             experiments[experiment][classes[i]][classes[matches[experiment][i]]] += 1
  18.             total_class_sums[classes[i]] = total_class_sums.get(classes[i], 0) + 1
  19.  
  20.     print experiments[0]["cat"]["cat"]
  21.     exit()
  22.        
  23. experiments[experiment][classes[i]][classes[matches[experiment][i]]] += 1
  24.        
  25. experiments = Counter()
  26. ...
  27. experiments[experiment, classes[i], classes[matches[experiment][i]]] += 1
  28.        
  29. for className, classIdx in enumerate(classes):
  30.     experiment = collections.defaultdict(list)
  31.     experiments[className] = experiment
  32.     for assignment,assignmentIdx in enumerate(assignments):
  33.         counterpart = classes[matches[assignmentIdx][classIdx]]
  34.         experiment[counterpart].append((assignment,assignmentIdx))
  35.  
  36. print(len(experiments["cat"]["cat"]), len(experiments["cat"]))
clone this paste RAW Paste Data