<jupyter_start><jupyter_text>Schematic Plots<jupyter_code>from rdkit.Chem import MolFromSmiles as smi2mol
from rdkit.Chem import MolToSmiles as mol2smi
from rdkit.Chem.Draw import MolToImage as mol2img

dos = rdkit.Chem.Draw.MolDrawOptions()
dos.useBWAtomPalette()
# dos.minFontSize = fontsize
img = mol2img(smi2mol(exps[0].smiles), options=dos)
# img.save("rf-schem-1.png")
fkw = {"figsize": (8, 4)}
font = {"family": "normal", "weight": "normal", "size": 22, "dpi": 300}
exmol.plot_space(
    space, exps[:2], figure_kwargs=fkw, mol_size=(300, 200), offset=0, cartoon=True
)
plt.scatter([], [], label="Counterfactual", s=150, color=plt.get_cmap("viridis")(1.0))
plt.scatter([], [], label="Same Class", s=150, color=plt.get_cmap("viridis")(0.0))
plt.legend(fontsize=22)
plt.tight_layout()
# plt.savefig("rf-schem-3.png", bbox_inches="tight", dpi=180)
# svg = exmol.insert_svg(exps[:2], mol_fontsize=10)
# with open("rf-scheme.svg", "w") as f:
#    f.write(svg)
# skunk.display(svg)<jupyter_output><empty_output><jupyter_text>Chemed<jupyter_code>cspace = exmol.sample_space(
    "Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)NC(=O)c4ccc(cc4)CN5CCN(CC5)C",
    model_eval,
    preset="medium",
)
kws = {"num_samples": 1500}
zspace = exmol.sample_space(
    "Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)NC(=O)c4ccc(cc4)CN5CCN(CC5)C",
    model_eval,
    preset="chemed",
    method_kwargs=kws,
)
### Gleevac molecule
exps = exmol.cf_explain(zspace)
fkw = {"figsize": (8, 6)}
mpl.rc("axes", titlesize=12)
exmol.plot_cf(exps, figure_kwargs=fkw, mol_size=(450, 400), nrows=1)
fkw = {"figsize": (8, 6)}
mpl.rc("axes", titlesize=12)
cfs = exmol.cf_explain(cspace, nmols=4)
exmol.plot_cf(cfs, figure_kwargs=fkw, mol_fontsize=26, mol_size=(400, 400), nrows=1)
# svg = exmol.insert_svg(cfs)
# with open("svg_figs/gleevac-cs.svg", "w") as f:
#    f.write(svg)

# plt.savefig('gleevac-cs.png', bbox_inches='tight', dpi=180)
fkw = {"figsize": (8, 6)}
mpl.rc("axes", titlesize=12)
exmol.plot_cf(exps, figure_kwargs=fkw, mol_size=(450, 400), nrows=1)

# plt.savefig('rf-simple.png', dpi=180)
# svg = exmol.insert_svg(exps, mol_fontsize=14)
# with open("svg_figs/gleevac-simple.svg", "w") as f:
#    f.write(svg)
fkw = {"figsize": (10, 6)}
mpl.rc("axes", titlesize=12)
exmol.plot_cf(exps, figure_kwargs=fkw, mol_size=(450, 400), nrows=1)

zexps = exmol.cf_explain(zspace, nmols=5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19281183932346724, 'fraction_numerical': 0.051585623678646934, 'mean_word_length': 6.681818181818182, 'pattern_counts': {'":': 10, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '235269', 'license': 'MIT', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1055, 'n_words': 163, 'path': 'paper/RF.ipynb', 'repo_name': 'varnerjwpu/exmol', 'size': '2365'}