Visualizing entire scoring function (Optimization)
Hello,
Is there currently a way to return every score generated by the scoring function (or the function itself) during the optimization stage? From what I've tried, I can only retrieve an object or a number with the final score/best score. I'm currently using Conjugate Gradients. If not, is there a way to do this with MC?
I would like to use a package like matplotlib (or gnuplot, if that's easier, as I see that your Replica Exchange feature uses gnuplot) to generate a plot for all of the scores from the scoring function.
Thank you, Katie
Worcester Polytechnic Institute Korkin Lab kjhughes@wpi.edu
This email address will be deactivated shortly, please use: marco.distefano@cnag.crg.eu
This email address will be deactivated shortly, please use: marco.distefano@cnag.crg.eu
On 8/19/15 8:25 AM, Hughes, Katelyn Jean wrote: > Is there currently a way to return every score generated by the > scoring function (or the function itself) during the optimization > stage?
It would be tricky to record every call to the scoring function (I think the only way to do it would be to subclass ScoringFunction). But if you're only interested in a single score per optimizer step (not quite the same thing, since a step may involve multiple scores) then it's pretty straightforward. Simply make an OptimizerState that records the score. OptimizerStates get called by Optimizers once per accepted step. You can get the score from the Optimizer itself by calling its get_last_score() method. For example,
o = IMP.core.ConjugateGradients(m) o.set_scoring_function(sf)
class ReportOptimizerState(IMP.OptimizerState): def __init__(self, *args, **keys): self.scores = [] IMP.OptimizerState.__init__(self, *args, **keys)
def do_update(self, i): score = self.get_optimizer().get_last_score() self.scores.append(score)
r = ReportOptimizerState(m, "reporter") o.add_optimizer_state(r) o.optimize(50) print(r.scores)
Ben
participants (3)
-
Ben Webb
-
Hughes, Katelyn Jean
-
mdistefano@pcb.ub.es