generated from AC-BO-Hackathon/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Import filtered data set" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"df_AA2024 = pd.read_excel('data/filtered_AA2024.xlsx')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
" SMILES Time_h pH Inhib_Concentrat_M \\\n", | ||
"0 COCCOC(=O)OCSc1nc2c(s1)cccc2 24.0 4.0 0.001 \n", | ||
"1 COCCOC(=O)OCSc1nc2c(s1)cccc2 24.0 10.0 0.001 \n", | ||
"2 Cc1ccc(c(c1)n1nc2c(n1)cccc2)O 24.0 4.0 0.001 \n", | ||
"3 Cc1ccc(c(c1)n1nc2c(n1)cccc2)O 24.0 10.0 0.001 \n", | ||
"4 Clc1ccc(cc1)CC[C@](C(C)(C)C)(Cn1cncn1)O 24.0 4.0 0.001 \n", | ||
"\n", | ||
" Efficiency \n", | ||
"0 0.0 \n", | ||
"1 0.0 \n", | ||
"2 30.0 \n", | ||
"3 30.0 \n", | ||
"4 30.0 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(df_AA2024.head())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Set objectives and parameters in BayBE" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from baybe.targets import NumericalTarget\n", | ||
"from baybe.objective import Objective\n", | ||
"\n", | ||
"target = NumericalTarget(\n", | ||
" name=\"Efficiency\",\n", | ||
" mode=\"MAX\",\n", | ||
")\n", | ||
"objective = Objective(mode=\"SINGLE\", targets=[target])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "OptionalImportError", | ||
"evalue": "The requested functionality requires the installation of optional chemistry dependencies. Please run \"pip install 'baybe[chem]'\".", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", | ||
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/baybe/utils/chemistry.py:17\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mmordred\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Calculator, descriptors\n\u001b[1;32m 18\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Chem, RDLogger\n", | ||
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'mordred'", | ||
"\nDuring handling of the above exception, another exception occurred:\n", | ||
"\u001b[0;31mOptionalImportError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[18], line 18\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mbaybe\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mparameters\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m (\n\u001b[1;32m 2\u001b[0m CategoricalParameter,\n\u001b[1;32m 3\u001b[0m NumericalDiscreteParameter,\n\u001b[1;32m 4\u001b[0m SubstanceParameter,\n\u001b[1;32m 5\u001b[0m )\n\u001b[1;32m 7\u001b[0m parameters \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 8\u001b[0m CategoricalParameter(\n\u001b[1;32m 9\u001b[0m name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGranularity\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 10\u001b[0m values\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcoarse\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmedium\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfine\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 11\u001b[0m encoding\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mOHE\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;66;03m# one-hot encoding of categories\u001b[39;00m\n\u001b[1;32m 12\u001b[0m ),\n\u001b[1;32m 13\u001b[0m NumericalDiscreteParameter(\n\u001b[1;32m 14\u001b[0m name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPressure[bar]\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 15\u001b[0m values\u001b[38;5;241m=\u001b[39m[\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m5\u001b[39m, \u001b[38;5;241m10\u001b[39m],\n\u001b[1;32m 16\u001b[0m tolerance\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0.2\u001b[39m, \u001b[38;5;66;03m# allows experimental inaccuracies up to 0.2 when reading values\u001b[39;00m\n\u001b[1;32m 17\u001b[0m ),\n\u001b[0;32m---> 18\u001b[0m \u001b[43mSubstanceParameter\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 19\u001b[0m \u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSolvent\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 20\u001b[0m \u001b[43m \u001b[49m\u001b[43mdata\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\n\u001b[1;32m 21\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSolvent A\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCOC\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 22\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSolvent B\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCCC\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# label-SMILES pairs\u001b[39;49;00m\n\u001b[1;32m 23\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSolvent C\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mO\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 24\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSolvent D\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCS(=O)C\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 25\u001b[0m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 26\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mMORDRED\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# chemical encoding via mordred package\u001b[39;49;00m\n\u001b[1;32m 27\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m,\n\u001b[1;32m 28\u001b[0m ]\n", | ||
"File \u001b[0;32m<attrs generated init baybe.parameters.substance.SubstanceParameter>:10\u001b[0m, in \u001b[0;36m__init__\u001b[0;34m(self, name, data, decorrelate, encoding)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m _config\u001b[38;5;241m.\u001b[39m_run_validators \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m 9\u001b[0m __attr_validator_name(\u001b[38;5;28mself\u001b[39m, __attr_name, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mname)\n\u001b[0;32m---> 10\u001b[0m \u001b[43m__attr_validator_data\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m__attr_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 11\u001b[0m __attr_validator_decorrelate(\u001b[38;5;28mself\u001b[39m, __attr_decorrelate, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecorrelate)\n", | ||
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/attr/_make.py:3059\u001b[0m, in \u001b[0;36m_AndValidator.__call__\u001b[0;34m(self, inst, attr, value)\u001b[0m\n\u001b[1;32m 3057\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, inst, attr, value):\n\u001b[1;32m 3058\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m v \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_validators:\n\u001b[0;32m-> 3059\u001b[0m \u001b[43mv\u001b[49m\u001b[43m(\u001b[49m\u001b[43minst\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mattr\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m)\u001b[49m\n", | ||
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/baybe/parameters/substance.py:77\u001b[0m, in \u001b[0;36mSubstanceParameter._validate_substance_data\u001b[0;34m(self, _, data)\u001b[0m\n\u001b[1;32m 67\u001b[0m \u001b[38;5;129m@data\u001b[39m\u001b[38;5;241m.\u001b[39mvalidator\n\u001b[1;32m 68\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_validate_substance_data\u001b[39m( \u001b[38;5;66;03m# noqa: DOC101, DOC103\u001b[39;00m\n\u001b[1;32m 69\u001b[0m \u001b[38;5;28mself\u001b[39m, _: Any, data: \u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mstr\u001b[39m, Smiles]\n\u001b[1;32m 70\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 71\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Validate that the substance data, provided as SMILES, is valid.\u001b[39;00m\n\u001b[1;32m 72\u001b[0m \n\u001b[1;32m 73\u001b[0m \u001b[38;5;124;03m Raises:\u001b[39;00m\n\u001b[1;32m 74\u001b[0m \u001b[38;5;124;03m ValueError: If one or more of the SMILES are invalid.\u001b[39;00m\n\u001b[1;32m 75\u001b[0m \u001b[38;5;124;03m ValueError: If the several entries represent the same substance.\u001b[39;00m\n\u001b[1;32m 76\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m---> 77\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mbaybe\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mutils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m chemistry\n\u001b[1;32m 79\u001b[0m \u001b[38;5;66;03m# Check for invalid SMILES\u001b[39;00m\n\u001b[1;32m 80\u001b[0m canonical_smiles \u001b[38;5;241m=\u001b[39m {}\n", | ||
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/baybe/utils/chemistry.py:21\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrdMolDescriptors\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m GetMorganFingerprintAsBitVect\n\u001b[1;32m 20\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m:\n\u001b[0;32m---> 21\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m OptionalImportError(\n\u001b[1;32m 22\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"The requested functionality requires the installation of optional \"\"\"\u001b[39;00m\n\u001b[1;32m 23\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"chemistry dependencies. Please run \"pip install 'baybe[chem]'\".\"\"\"\u001b[39;00m\n\u001b[1;32m 24\u001b[0m )\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mbaybe\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mutils\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mnumerical\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m DTypeFloatNumpy\n\u001b[1;32m 28\u001b[0m _mordred_calculator \u001b[38;5;241m=\u001b[39m Calculator(descriptors)\n", | ||
"\u001b[0;31mOptionalImportError\u001b[0m: The requested functionality requires the installation of optional chemistry dependencies. Please run \"pip install 'baybe[chem]'\"." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from baybe.parameters import (\n", | ||
" CategoricalParameter,\n", | ||
" NumericalDiscreteParameter,\n", | ||
" SubstanceParameter,\n", | ||
")\n", | ||
"\n", | ||
"parameters = [\n", | ||
" NumericalDiscreteParameter(\n", | ||
" name=\"Time[h]\",\n", | ||
" ),\n", | ||
"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from baybe.searchspace import SearchSpace\n", | ||
"\n", | ||
"searchspace = SearchSpace.from_product(parameters)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |