Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Substance Encodings #474

Merged
merged 10 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .lockfiles/py310-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ cyclonedx-python-lib==7.5.1
# via pip-audit
dask==2024.7.1
# via xyzpy
datasketch==1.6.5
# via scikit-fingerprints
debugpy==1.8.2
# via ipykernel
decorator==5.1.1
Expand Down Expand Up @@ -374,7 +372,7 @@ markupsafe==2.1.5
# via
# jinja2
# nbconvert
matplotlib==3.9.1
matplotlib==3.10.0
# via
# baybe (pyproject.toml)
# lifelines
Expand Down Expand Up @@ -456,7 +454,6 @@ numpy==1.26.4
# autograd
# botorch
# contourpy
# datasketch
# descriptastorus
# e3fp
# formulaic
Expand Down Expand Up @@ -805,7 +802,7 @@ ruff==0.5.2
# via baybe (pyproject.toml)
s3transfer==0.10.4
# via boto3
scikit-fingerprints==1.9.0
scikit-fingerprints==1.13.1
# via baybe (pyproject.toml)
scikit-image==0.25.0
# via lime
Expand All @@ -826,7 +823,6 @@ scipy==1.14.0
# baybe (pyproject.toml)
# autograd-gamma
# botorch
# datasketch
# descriptastorus
# e3fp
# formulaic
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- `BCUT2D` encoding for `SubstanceParameter`

## [0.12.2] - 2025-01-31
### Changed
- More robust settings for the GP fitting
Expand Down
2 changes: 1 addition & 1 deletion baybe/constraints/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def to_botorch(
"""Cast the constraint in a format required by botorch.

Used in calling ``optimize_acqf_*`` functions, for details see
https://botorch.org/api/optim.html#botorch.optim.optimize.optimize_acqf
:func:`botorch.optim.optimize.optimize_acqf`

Args:
parameters: The parameter objects of the continuous space.
Expand Down
3 changes: 3 additions & 0 deletions baybe/parameters/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class SubstanceEncoding(ParameterEncoding):
AVALON = "AVALON"
""":class:`skfp.fingerprints.AvalonFingerprint`"""

BCUT2D = "BCUT2D"
""":class:`skfp.fingerprints.BCUT2DFingerprint`"""

E3FP = "E3FP"
""":class:`skfp.fingerprints.E3FPFingerprint`"""

Expand Down
2 changes: 1 addition & 1 deletion baybe/utils/chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def smiles_to_fingerprint_features(
feature_names_out = fingerprint_encoder.get_feature_names_out()
no_descriptor_names = all("fingerprint" in f for f in feature_names_out)
suffixes = [
f.split("fingerprint")[1] if no_descriptor_names else f
f.split("fingerprint")[1] if no_descriptor_names else f.replace(" ", "_")
AdrianSosic marked this conversation as resolved.
Show resolved Hide resolved
for f in feature_names_out
]
col_names = [prefix + name + suffix for suffix in suffixes]
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@

# Mappings to all external packages that we want to have clickable links to
intersphinx_mapping = {
"botorch": ("https://botorch.readthedocs.io/en/latest", None),
"python": ("https://docs.python.org/3", None),
"pandas": ("https://pandas.pydata.org/docs/", None),
"polars": ("https://docs.pola.rs/api/python/stable/", None),
Expand All @@ -256,7 +257,7 @@
"numpy": ("https://numpy.org/doc/stable/", None),
"torch": ("https://pytorch.org/docs/main/", None),
"rdkit": ("https://rdkit.org/docs/", None),
"shap": ("https://shap.readthedocs.io/en/latest/", None),
"shap": ("https://shap.readthedocs.io/en/stable/", None),
}

# --- Options for autodoc typehints and autodoc -------------------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/Transfer_Learning/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

### Creating the Search Space

# This example uses the [Hartmann Function](https://botorch.org/api/test_functions.html#botorch.test_functions.synthetic.Hartmann)
# This example uses the [Hartmann Function](botorch.test_functions.synthetic.Hartmann)
# as implemented by `botorch`.
# The bounds of the search space are dictated by the test function and can be extracted
# from the function itself.
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Issues = "https://github.com/emdgroup/baybe/issues/"

[project.optional-dependencies]
chem = [
"scikit-fingerprints>=1.7.0",
"scikit-fingerprints>=1.13.1",
]

onnx = [
Expand Down Expand Up @@ -116,7 +116,7 @@ examples = [
"baybe[chem]", # Required for some of the examples
"baybe[onnx]", # Required for some of the examples
"baybe[simulation]", # Required for some of the examples
"matplotlib>=3.7.3",
"matplotlib>=3.7.3,!=3.9.1",
"openpyxl>=3.0.9",
"pillow>=10.0.1", # Necessary due to vulnerability
"plotly>=5.10.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def fixture_parameters(
],
*[
SubstanceParameter(
name=f"Substance_1_{encoding}",
name=f"Substance_1_{encoding.name}",
data=mock_substances,
encoding=encoding,
)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_substance_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
)
@pytest.mark.parametrize(
"parameter_names",
[["Categorical_1", f"Substance_1_{enc}"] for enc in SubstanceEncoding],
[["Categorical_1", f"Substance_1_{enc.name}"] for enc in SubstanceEncoding],
ids=[enc.name for enc in SubstanceEncoding],
)
@pytest.mark.parametrize("n_grid_points", [8], ids=["g8"])
@pytest.mark.parametrize("batch_size", [1], ids=["b3"])
def test_run_iterations(campaign, batch_size, n_iterations):
"""Test running some iterations with fake results and a substance parameter."""
run_iterations(campaign, n_iterations, batch_size)
Expand Down
Loading