So instead of keeping a list of Interaction objects, keep just the interaction_matrix. This will save space.
When you want the best interactions in a form of an Interaction object, get the indices of the maximum values in the interaction_matrix and compute the Interaction object by using attribute_interactions method.
So instead of keeping a list of Interaction objects, keep just the interaction_matrix. This will save space. When you want the best interactions in a form of an Interaction object, get the indices of the maximum values in the interaction_matrix and compute the Interaction object by using attribute_interactions method.
http://stackoverflow.com/questions/10337533/a-fast-way-to-find-the-largest-n-elements-in-an-numpy-array http://stackoverflow.com/questions/9482550/argmax-of-numpy-array-returning-non-flat-indices http://stackoverflow.com/questions/5807047/pythonnumpy-efficient-way-to-take-the-min-max-n-values-and-indices-from-a-matr