Closed AlexanderJussupow closed 7 years ago
On 03/21/2017 12:32 PM, AlexanderJussupow wrote:
Hello,
I try to use tica with a metadynamics trajectory. Each frame of the trajectory has a different weight which are already precomputed. My problem is, that I do not understand how to use the weights option for pyemma.coordinates.tica ("An object that allows to compute re-weighting factors. It must possess a method"). Is it somehow possible to create a weight object, which just gives out the precomputed weights?
Best
Alex
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/markovmodel/PyEMMA/issues/1060, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKZL9Fo3NmZCGBfP3Bw25WbxiwPgLzjks5rn7VbgaJpZM4Mjq0F.
I guess this has to be class like this:
class GetWeights(object): def init(self, my_weights): self.frame_counter = 0 self.my_weights = my_weights
def weights(ndarray):
result = self.my_weights[self.frame_counter:len(ndarray)]
self.frame_counter += len(ndarray)
return result
This of course assumes that the ordering of my_weights is the same as the one you feed in the trajectories into tica.
Sorry, I've looked into the code and you have to derive the GetWeights class from this one: from pyemma.coordaintes.estimation.koopman import _Weights class GetWeights(_Weights): ...
I think we should change that into a plain signature check [hasattr(weights, "weights") and type(getattr(weights, "weights")) == types.MethodType to make this pythonic, eg. duck typed.
I think this was implemented by @fabian-paul or @fnueske . Guys, what's the intended usecase?
This was primarily written for Koopman re-weighting. Here, the class only holds the re-weighting vector u, and transform an incoming trajectory X by multiplication by u. This assumes that X contains the same features / basis functions that were used to obtain u. It can be used in more general situations, though. All that matters is that the user supplies a class that possesses a method "weights(X)" to assign re-weighting factors to a given trajectory X. It is, of course, the responsibility of the user to make sure that re-weighting factors are assigned correctly. Does that make sense?
I think there is no particular use case. The goal was just to have a flexible interface for the computation of the weights that can accommodate unanticipated future use cases. That's why we introduced this class.
Yes it makes sense. But I agree with @marscher , you shouldn't have to derive from a base class if the base class doesn't provide code that you want to reuse, so just check for hasattr.
fixed by #1061
Hello,
I try to use tica with a metadynamics trajectory. Each frame of the trajectory has a different weight which are already precomputed. My problem is, that I do not understand how to use the weights option for pyemma.coordinates.tica ("An object that allows to compute re-weighting factors. It must possess a method"). Is it somehow possible to create a weight object, which just gives out the precomputed weights?
Best
Alex