MolecularAI / aizynthfinder

A tool for retrosynthetic planning
https://molecularai.github.io/aizynthfinder/
MIT License
583 stars 134 forks source link

Confidence Score #165

Closed shreyasvinaya closed 1 month ago

shreyasvinaya commented 1 month ago

Hi, Is there any way we can get the confidence score of each step of the retrosynthesis? Do i have to change something in the config file/ parameters that i'm passing in?

This is the code that i'm currently using:

finder = AiZynthFinder(configfile=config_filename)
finder.stock.select("zinc")
finder.expansion_policy.select("uspto")
finder.filter_policy.select("uspto")
finder.target_smiles = smiles
finder.tree_search()
finder.build_routes()
stats = finder.extract_statistics()
status = stats['is_solved']
result_dict = finder.routes.dict_with_extra(include_metadata=True,
                                            include_scores=True)

This is my config file:

expansion:
  uspto:
    - aizynthfinder/models/uspto_model.onnx
    - aizynthfinder/models/uspto_templates.csv.gz
  ringbreaker:
    - aizynthfinder/models/uspto_ringbreaker_model.onnx
    - aizynthfinder/models/uspto_ringbreaker_templates.csv.gz
filter:
  uspto: aizynthfinder/models/uspto_filter_model.onnx
stock:
  zinc: aizynthfinder/models/zinc_stock.hdf5

Thanks in advance

SGenheden commented 1 month ago

Hello,

Could you be so kind and specify what you mean with confidence score?

I don't believe this is something that comes of out the template-based model. This is a "simple" multiclass classifier that returns a score for each template in the model.

shreyasvinaya commented 1 month ago

Hi @SGenheden Thank you for your reply,

what i mean by confidence score is the probability score of the selected class, as far as my knowledge goes, I am able to obtain a state-score for the entire pathway. It would be great if I could get some help in obtaining the state-score for each step in the pathway

SGenheden commented 1 month ago

Thanks for the clarification.

For each reaction in the route, there is a dictionary with metadata, and this has an item called policy_probability that holds the probability from the multiclass classifier. This should be returned by the dict_with_extra you are using.