{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# granite.materials.smi-TED - INFERENCE (Classification)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Install extra packages for notebook\n", "%pip install seaborn xgboost" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append('../inference')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# materials.smi-ted\n", "from smi_ted_light.load import load_smi_ted\n", "\n", "# Data\n", "import torch\n", "import pandas as pd\n", "\n", "# Chemistry\n", "from rdkit import Chem\n", "from rdkit.Chem import PandasTools\n", "from rdkit.Chem import Descriptors\n", "PandasTools.RenderImagesInAllDataFrames(True)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# function to canonicalize SMILES\n", "def normalize_smiles(smi, canonical=True, isomeric=False):\n", " try:\n", " normalized = Chem.MolToSmiles(\n", " Chem.MolFromSmiles(smi), canonical=canonical, isomericSmiles=isomeric\n", " )\n", " except:\n", " normalized = None\n", " return normalized" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import smi-ted" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Random Seed: 12345\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Using Rotation Embedding\n", "Vocab size: 2393\n", "[INFERENCE MODE - smi-ted-Light]\n" ] } ], "source": [ "model_smi_ted = load_smi_ted(\n", " folder='../inference/smi_ted_light',\n", " ckpt_filename='smi-ted-Light_40.pt'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## BBBP Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Experiments - Data Load" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df_train = pd.read_csv(\"../finetune/moleculenet/bbbp/train.csv\")\n", "df_test = pd.read_csv(\"../finetune/moleculenet/bbbp/test.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### SMILES canonization" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1634, 5)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[22:56:14] Explicit valence for atom # 1 N, 4, is greater than permitted\n", "[22:56:14] Explicit valence for atom # 6 N, 4, is greater than permitted\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] Explicit valence for atom # 6 N, 4, is greater than permitted\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] Explicit valence for atom # 11 N, 4, is greater than permitted\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] Explicit valence for atom # 5 N, 4, is greater than permitted\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:14] WARNING: not removing hydrogen atom without neighbors\n" ] }, { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>num</th>\n", " <th>name</th>\n", " <th>p_np</th>\n", " <th>smiles</th>\n", " <th>norm_smiles</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1</td>\n", " <td>Propanolol</td>\n", " <td>1</td>\n", " <td>[Cl].CC(C)NCC(O)COc1cccc2ccccc12</td>\n", " <td>CC(C)NCC(O)COc1cccc2ccccc12.[Cl]</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>2</td>\n", " <td>Terbutylchlorambucil</td>\n", " <td>1</td>\n", " <td>C(=O)(OC(C)(C)C)CCCc1ccc(cc1)N(CCCl)CCCl</td>\n", " <td>CC(C)(C)OC(=O)CCCc1ccc(N(CCCl)CCCl)cc1</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>3</td>\n", " <td>40730</td>\n", " <td>1</td>\n", " <td>c12c3c(N4CCN(C)CC4)c(F)cc1c(c(C(O)=O)cn2C(C)CO...</td>\n", " <td>CC1COc2c(N3CCN(C)CC3)c(F)cc3c(=O)c(C(=O)O)cn1c23</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>4</td>\n", " <td>24</td>\n", " <td>1</td>\n", " <td>C1CCN(CC1)Cc1cccc(c1)OCCCNC(=O)C</td>\n", " <td>CC(=O)NCCCOc1cccc(CN2CCCCC2)c1</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>6</td>\n", " <td>cefoperazone</td>\n", " <td>1</td>\n", " <td>CCN1CCN(C(=O)N[C@@H](C(=O)N[C@H]2[C@H]3SCC(=C(...</td>\n", " <td>CCN1CCN(C(=O)NC(C(=O)NC2C(=O)N3C(C(=O)O)=C(CSc...</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " num name p_np \\\n", "0 1 Propanolol 1 \n", "1 2 Terbutylchlorambucil 1 \n", "2 3 40730 1 \n", "3 4 24 1 \n", "4 6 cefoperazone 1 \n", "\n", " smiles \\\n", "0 [Cl].CC(C)NCC(O)COc1cccc2ccccc12 \n", "1 C(=O)(OC(C)(C)C)CCCc1ccc(cc1)N(CCCl)CCCl \n", "2 c12c3c(N4CCN(C)CC4)c(F)cc1c(c(C(O)=O)cn2C(C)CO... \n", "3 C1CCN(CC1)Cc1cccc(c1)OCCCNC(=O)C \n", "4 CCN1CCN(C(=O)N[C@@H](C(=O)N[C@H]2[C@H]3SCC(=C(... \n", "\n", " norm_smiles \n", "0 CC(C)NCC(O)COc1cccc2ccccc12.[Cl] \n", "1 CC(C)(C)OC(=O)CCCc1ccc(N(CCCl)CCCl)cc1 \n", "2 CC1COc2c(N3CCN(C)CC3)c(F)cc3c(=O)c(C(=O)O)cn1c23 \n", "3 CC(=O)NCCCOc1cccc(CN2CCCCC2)c1 \n", "4 CCN1CCN(C(=O)NC(C(=O)NC2C(=O)N3C(C(=O)O)=C(CSc... " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_train['norm_smiles'] = df_train['smiles'].apply(normalize_smiles)\n", "df_train_normalized = df_train.dropna()\n", "print(df_train_normalized.shape)\n", "df_train_normalized.head()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(192, 5)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[22:56:17] Explicit valence for atom # 12 N, 4, is greater than permitted\n", "[22:56:17] Explicit valence for atom # 5 N, 4, is greater than permitted\n", "[22:56:17] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:17] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:17] WARNING: not removing hydrogen atom without neighbors\n", "[22:56:17] WARNING: not removing hydrogen atom without neighbors\n" ] }, { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>num</th>\n", " <th>name</th>\n", " <th>p_np</th>\n", " <th>smiles</th>\n", " <th>norm_smiles</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>13</td>\n", " <td>18</td>\n", " <td>1</td>\n", " <td>C(Cl)Cl</td>\n", " <td>ClCCl</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>23</td>\n", " <td>SKF-93619</td>\n", " <td>0</td>\n", " <td>c1cc2c(cc(CC3=CNC(=NC3=O)NCCSCc3oc(cc3)CN(C)C)...</td>\n", " <td>CN(C)Cc1ccc(CSCCNc2nc(=O)c(Cc3ccc4ccccc4c3)c[n...</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>36</td>\n", " <td>etomidate</td>\n", " <td>1</td>\n", " <td>CCOC(=O)c1cncn1C(C)c2ccccc2</td>\n", " <td>CCOC(=O)c1cncn1C(C)c1ccccc1</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>37</td>\n", " <td>11a</td>\n", " <td>0</td>\n", " <td>CN(C)c1cc(C2=NC(N)=NN2)ccn1</td>\n", " <td>CN(C)c1cc(-c2nc(N)n[nH]2)ccn1</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>79</td>\n", " <td>compound 45</td>\n", " <td>1</td>\n", " <td>N1(Cc2cc(OCCCNc3oc4ccccc4n3)ccc2)CCCCC1</td>\n", " <td>c1cc(CN2CCCCC2)cc(OCCCNc2nc3ccccc3o2)c1</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " num name p_np smiles \\\n", "0 13 18 1 C(Cl)Cl \n", "1 23 SKF-93619 0 c1cc2c(cc(CC3=CNC(=NC3=O)NCCSCc3oc(cc3)CN(C)C)... \n", "2 36 etomidate 1 CCOC(=O)c1cncn1C(C)c2ccccc2 \n", "3 37 11a 0 CN(C)c1cc(C2=NC(N)=NN2)ccn1 \n", "4 79 compound 45 1 N1(Cc2cc(OCCCNc3oc4ccccc4n3)ccc2)CCCCC1 \n", "\n", " norm_smiles \n", "0 ClCCl \n", "1 CN(C)Cc1ccc(CSCCNc2nc(=O)c(Cc3ccc4ccccc4c3)c[n... \n", "2 CCOC(=O)c1cncn1C(C)c1ccccc1 \n", "3 CN(C)c1cc(-c2nc(N)n[nH]2)ccn1 \n", "4 c1cc(CN2CCCCC2)cc(OCCCNc2nc3ccccc3o2)c1 " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_test['norm_smiles'] = df_test['smiles'].apply(normalize_smiles)\n", "df_test_normalized = df_test.dropna()\n", "print(df_test_normalized.shape)\n", "df_test_normalized.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Embeddings extraction " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### smi-ted embeddings extraction" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 16/16 [00:21<00:00, 1.35s/it]\n" ] }, { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>0</th>\n", " <th>1</th>\n", " <th>2</th>\n", " <th>3</th>\n", " <th>4</th>\n", " <th>5</th>\n", " <th>6</th>\n", " <th>7</th>\n", " <th>8</th>\n", " <th>9</th>\n", " <th>...</th>\n", " <th>758</th>\n", " <th>759</th>\n", " <th>760</th>\n", " <th>761</th>\n", " <th>762</th>\n", " <th>763</th>\n", " <th>764</th>\n", " <th>765</th>\n", " <th>766</th>\n", " <th>767</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>0.437218</td>\n", " <td>-0.591727</td>\n", " <td>0.064328</td>\n", " <td>0.374019</td>\n", " <td>0.530676</td>\n", " <td>-0.644067</td>\n", " <td>1.308136</td>\n", " <td>0.089772</td>\n", " <td>0.790524</td>\n", " <td>0.208749</td>\n", " <td>...</td>\n", " <td>-1.325162</td>\n", " <td>-0.083578</td>\n", " <td>0.169544</td>\n", " <td>0.359247</td>\n", " <td>-0.652742</td>\n", " <td>0.720496</td>\n", " <td>-0.674184</td>\n", " <td>0.693000</td>\n", " <td>0.586143</td>\n", " <td>-0.159641</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>0.344508</td>\n", " <td>-0.417009</td>\n", " <td>0.095745</td>\n", " <td>0.355959</td>\n", " <td>0.573049</td>\n", " <td>-0.590279</td>\n", " <td>1.069699</td>\n", " <td>0.067724</td>\n", " <td>0.788815</td>\n", " <td>0.159197</td>\n", " <td>...</td>\n", " <td>-1.312421</td>\n", " <td>-0.108732</td>\n", " <td>0.217020</td>\n", " <td>0.303697</td>\n", " <td>-0.598966</td>\n", " <td>0.647903</td>\n", " <td>-0.665967</td>\n", " <td>0.791804</td>\n", " <td>0.620691</td>\n", " <td>-0.107859</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>0.429205</td>\n", " <td>-0.463542</td>\n", " <td>0.056441</td>\n", " <td>0.449925</td>\n", " <td>0.536788</td>\n", " <td>-0.749906</td>\n", " <td>1.193816</td>\n", " <td>0.082596</td>\n", " <td>0.860276</td>\n", " <td>0.162548</td>\n", " <td>...</td>\n", " <td>-1.304979</td>\n", " <td>-0.148620</td>\n", " <td>0.242045</td>\n", " <td>0.344730</td>\n", " <td>-0.704636</td>\n", " <td>0.644773</td>\n", " <td>-0.781017</td>\n", " <td>0.737207</td>\n", " <td>0.585380</td>\n", " <td>-0.101722</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>0.433097</td>\n", " <td>-0.523078</td>\n", " <td>0.089728</td>\n", " <td>0.410127</td>\n", " <td>0.543400</td>\n", " <td>-0.643014</td>\n", " <td>1.203858</td>\n", " <td>0.034177</td>\n", " <td>0.769413</td>\n", " <td>0.202445</td>\n", " <td>...</td>\n", " <td>-1.358915</td>\n", " <td>-0.077463</td>\n", " <td>0.228710</td>\n", " <td>0.317884</td>\n", " <td>-0.680220</td>\n", " <td>0.531601</td>\n", " <td>-0.709799</td>\n", " <td>0.731386</td>\n", " <td>0.567806</td>\n", " <td>-0.087713</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>0.388423</td>\n", " <td>-0.505908</td>\n", " <td>0.072539</td>\n", " <td>0.366502</td>\n", " <td>0.533689</td>\n", " <td>-0.701559</td>\n", " <td>1.035554</td>\n", " <td>0.038419</td>\n", " <td>0.822917</td>\n", " <td>0.163062</td>\n", " <td>...</td>\n", " <td>-1.271012</td>\n", " <td>-0.176412</td>\n", " <td>0.119734</td>\n", " <td>0.294143</td>\n", " <td>-0.677721</td>\n", " <td>0.647655</td>\n", " <td>-0.844419</td>\n", " <td>0.756321</td>\n", " <td>0.570513</td>\n", " <td>-0.240003</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>5 rows × 768 columns</p>\n", "</div>" ], "text/plain": [ " 0 1 2 3 4 5 6 \\\n", "0 0.437218 -0.591727 0.064328 0.374019 0.530676 -0.644067 1.308136 \n", "1 0.344508 -0.417009 0.095745 0.355959 0.573049 -0.590279 1.069699 \n", "2 0.429205 -0.463542 0.056441 0.449925 0.536788 -0.749906 1.193816 \n", "3 0.433097 -0.523078 0.089728 0.410127 0.543400 -0.643014 1.203858 \n", "4 0.388423 -0.505908 0.072539 0.366502 0.533689 -0.701559 1.035554 \n", "\n", " 7 8 9 ... 758 759 760 761 \\\n", "0 0.089772 0.790524 0.208749 ... -1.325162 -0.083578 0.169544 0.359247 \n", "1 0.067724 0.788815 0.159197 ... -1.312421 -0.108732 0.217020 0.303697 \n", "2 0.082596 0.860276 0.162548 ... -1.304979 -0.148620 0.242045 0.344730 \n", "3 0.034177 0.769413 0.202445 ... -1.358915 -0.077463 0.228710 0.317884 \n", "4 0.038419 0.822917 0.163062 ... -1.271012 -0.176412 0.119734 0.294143 \n", "\n", " 762 763 764 765 766 767 \n", "0 -0.652742 0.720496 -0.674184 0.693000 0.586143 -0.159641 \n", "1 -0.598966 0.647903 -0.665967 0.791804 0.620691 -0.107859 \n", "2 -0.704636 0.644773 -0.781017 0.737207 0.585380 -0.101722 \n", "3 -0.680220 0.531601 -0.709799 0.731386 0.567806 -0.087713 \n", "4 -0.677721 0.647655 -0.844419 0.756321 0.570513 -0.240003 \n", "\n", "[5 rows x 768 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with torch.no_grad():\n", " df_embeddings_train = model_smi_ted.encode(df_train_normalized['norm_smiles'])\n", "df_embeddings_train.head()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 1/1 [00:04<00:00, 4.23s/it]\n" ] }, { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>0</th>\n", " <th>1</th>\n", " <th>2</th>\n", " <th>3</th>\n", " <th>4</th>\n", " <th>5</th>\n", " <th>6</th>\n", " <th>7</th>\n", " <th>8</th>\n", " <th>9</th>\n", " <th>...</th>\n", " <th>758</th>\n", " <th>759</th>\n", " <th>760</th>\n", " <th>761</th>\n", " <th>762</th>\n", " <th>763</th>\n", " <th>764</th>\n", " <th>765</th>\n", " <th>766</th>\n", " <th>767</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>0.374249</td>\n", " <td>-0.319257</td>\n", " <td>-0.007041</td>\n", " <td>0.444741</td>\n", " <td>0.326734</td>\n", " <td>-0.791476</td>\n", " <td>1.121707</td>\n", " <td>-0.082401</td>\n", " <td>0.611457</td>\n", " <td>0.289225</td>\n", " <td>...</td>\n", " <td>-1.462539</td>\n", " <td>-0.302055</td>\n", " <td>0.295551</td>\n", " <td>-0.058293</td>\n", " <td>-0.830319</td>\n", " <td>0.545099</td>\n", " <td>-0.460271</td>\n", " <td>1.121117</td>\n", " <td>0.685016</td>\n", " <td>-0.452698</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>0.429158</td>\n", " <td>-0.568104</td>\n", " <td>0.112739</td>\n", " <td>0.352429</td>\n", " <td>0.512565</td>\n", " <td>-0.604153</td>\n", " <td>1.181846</td>\n", " <td>0.067963</td>\n", " <td>0.786978</td>\n", " <td>0.128077</td>\n", " <td>...</td>\n", " <td>-1.226941</td>\n", " <td>-0.078927</td>\n", " <td>0.209468</td>\n", " <td>0.266113</td>\n", " <td>-0.762261</td>\n", " <td>0.610685</td>\n", " <td>-0.755705</td>\n", " <td>0.734550</td>\n", " <td>0.592976</td>\n", " <td>-0.148252</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>0.411906</td>\n", " <td>-0.510477</td>\n", " <td>0.073015</td>\n", " <td>0.346871</td>\n", " <td>0.512772</td>\n", " <td>-0.617252</td>\n", " <td>1.191621</td>\n", " <td>0.040103</td>\n", " <td>0.722577</td>\n", " <td>0.188638</td>\n", " <td>...</td>\n", " <td>-1.300554</td>\n", " <td>-0.150735</td>\n", " <td>0.148252</td>\n", " <td>0.282791</td>\n", " <td>-0.694712</td>\n", " <td>0.556029</td>\n", " <td>-0.660645</td>\n", " <td>0.771226</td>\n", " <td>0.558996</td>\n", " <td>-0.000660</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>0.356793</td>\n", " <td>-0.530959</td>\n", " <td>0.050350</td>\n", " <td>0.433593</td>\n", " <td>0.592601</td>\n", " <td>-0.573508</td>\n", " <td>1.221865</td>\n", " <td>0.025491</td>\n", " <td>0.833164</td>\n", " <td>0.214604</td>\n", " <td>...</td>\n", " <td>-1.406141</td>\n", " <td>-0.107165</td>\n", " <td>0.200131</td>\n", " <td>0.289469</td>\n", " <td>-0.770149</td>\n", " <td>0.572746</td>\n", " <td>-0.776739</td>\n", " <td>0.855064</td>\n", " <td>0.662797</td>\n", " <td>-0.194417</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>0.422133</td>\n", " <td>-0.490610</td>\n", " <td>0.044333</td>\n", " <td>0.367861</td>\n", " <td>0.579025</td>\n", " <td>-0.629409</td>\n", " <td>1.139824</td>\n", " <td>0.039823</td>\n", " <td>0.728825</td>\n", " <td>0.145327</td>\n", " <td>...</td>\n", " <td>-1.312777</td>\n", " <td>-0.105049</td>\n", " <td>0.175286</td>\n", " <td>0.336176</td>\n", " <td>-0.738813</td>\n", " <td>0.530226</td>\n", " <td>-0.763357</td>\n", " <td>0.764998</td>\n", " <td>0.583681</td>\n", " <td>-0.109683</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>5 rows × 768 columns</p>\n", "</div>" ], "text/plain": [ " 0 1 2 3 4 5 6 \\\n", "0 0.374249 -0.319257 -0.007041 0.444741 0.326734 -0.791476 1.121707 \n", "1 0.429158 -0.568104 0.112739 0.352429 0.512565 -0.604153 1.181846 \n", "2 0.411906 -0.510477 0.073015 0.346871 0.512772 -0.617252 1.191621 \n", "3 0.356793 -0.530959 0.050350 0.433593 0.592601 -0.573508 1.221865 \n", "4 0.422133 -0.490610 0.044333 0.367861 0.579025 -0.629409 1.139824 \n", "\n", " 7 8 9 ... 758 759 760 761 \\\n", "0 -0.082401 0.611457 0.289225 ... -1.462539 -0.302055 0.295551 -0.058293 \n", "1 0.067963 0.786978 0.128077 ... -1.226941 -0.078927 0.209468 0.266113 \n", "2 0.040103 0.722577 0.188638 ... -1.300554 -0.150735 0.148252 0.282791 \n", "3 0.025491 0.833164 0.214604 ... -1.406141 -0.107165 0.200131 0.289469 \n", "4 0.039823 0.728825 0.145327 ... -1.312777 -0.105049 0.175286 0.336176 \n", "\n", " 762 763 764 765 766 767 \n", "0 -0.830319 0.545099 -0.460271 1.121117 0.685016 -0.452698 \n", "1 -0.762261 0.610685 -0.755705 0.734550 0.592976 -0.148252 \n", "2 -0.694712 0.556029 -0.660645 0.771226 0.558996 -0.000660 \n", "3 -0.770149 0.572746 -0.776739 0.855064 0.662797 -0.194417 \n", "4 -0.738813 0.530226 -0.763357 0.764998 0.583681 -0.109683 \n", "\n", "[5 rows x 768 columns]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with torch.no_grad():\n", " df_embeddings_test = model_smi_ted.encode(df_test_normalized['norm_smiles'])\n", "df_embeddings_test.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Experiments - BBBP prediction using smi-ted latent spaces" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### XGBoost prediction using the whole Latent Space" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "from xgboost import XGBClassifier\n", "from sklearn.metrics import roc_auc_score" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<style>#sk-container-id-1 {\n", " /* Definition of color scheme common for light and dark mode */\n", " --sklearn-color-text: black;\n", " --sklearn-color-line: gray;\n", " /* Definition of color scheme for unfitted estimators */\n", " --sklearn-color-unfitted-level-0: #fff5e6;\n", " --sklearn-color-unfitted-level-1: #f6e4d2;\n", " --sklearn-color-unfitted-level-2: #ffe0b3;\n", " --sklearn-color-unfitted-level-3: chocolate;\n", " /* Definition of color scheme for fitted estimators */\n", " --sklearn-color-fitted-level-0: #f0f8ff;\n", " --sklearn-color-fitted-level-1: #d4ebff;\n", " --sklearn-color-fitted-level-2: #b3dbfd;\n", " --sklearn-color-fitted-level-3: cornflowerblue;\n", "\n", " /* Specific color for light theme */\n", " --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n", " --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n", " --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n", " --sklearn-color-icon: #696969;\n", "\n", " @media (prefers-color-scheme: dark) {\n", " /* Redefinition of color scheme for dark theme */\n", " --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n", " --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n", " --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n", " --sklearn-color-icon: #878787;\n", " }\n", "}\n", "\n", "#sk-container-id-1 {\n", " color: var(--sklearn-color-text);\n", "}\n", "\n", "#sk-container-id-1 pre {\n", " padding: 0;\n", "}\n", "\n", "#sk-container-id-1 input.sk-hidden--visually {\n", " border: 0;\n", " clip: rect(1px 1px 1px 1px);\n", " clip: rect(1px, 1px, 1px, 1px);\n", " height: 1px;\n", " margin: -1px;\n", " overflow: hidden;\n", " padding: 0;\n", " position: absolute;\n", " width: 1px;\n", "}\n", "\n", "#sk-container-id-1 div.sk-dashed-wrapped {\n", " border: 1px dashed var(--sklearn-color-line);\n", " margin: 0 0.4em 0.5em 0.4em;\n", " box-sizing: border-box;\n", " padding-bottom: 0.4em;\n", " background-color: var(--sklearn-color-background);\n", "}\n", "\n", "#sk-container-id-1 div.sk-container {\n", " /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n", " but bootstrap.min.css set `[hidden] { display: none !important; }`\n", " so we also need the `!important` here to be able to override the\n", " default hidden behavior on the sphinx rendered scikit-learn.org.\n", " See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n", " display: inline-block !important;\n", " position: relative;\n", "}\n", "\n", "#sk-container-id-1 div.sk-text-repr-fallback {\n", " display: none;\n", "}\n", "\n", "div.sk-parallel-item,\n", "div.sk-serial,\n", "div.sk-item {\n", " /* draw centered vertical line to link estimators */\n", " background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n", " background-size: 2px 100%;\n", " background-repeat: no-repeat;\n", " background-position: center center;\n", "}\n", "\n", "/* Parallel-specific style estimator block */\n", "\n", "#sk-container-id-1 div.sk-parallel-item::after {\n", " content: \"\";\n", " width: 100%;\n", " border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n", " flex-grow: 1;\n", "}\n", "\n", "#sk-container-id-1 div.sk-parallel {\n", " display: flex;\n", " align-items: stretch;\n", " justify-content: center;\n", " background-color: var(--sklearn-color-background);\n", " position: relative;\n", "}\n", "\n", "#sk-container-id-1 div.sk-parallel-item {\n", " display: flex;\n", " flex-direction: column;\n", "}\n", "\n", "#sk-container-id-1 div.sk-parallel-item:first-child::after {\n", " align-self: flex-end;\n", " width: 50%;\n", "}\n", "\n", "#sk-container-id-1 div.sk-parallel-item:last-child::after {\n", " align-self: flex-start;\n", " width: 50%;\n", "}\n", "\n", "#sk-container-id-1 div.sk-parallel-item:only-child::after {\n", " width: 0;\n", "}\n", "\n", "/* Serial-specific style estimator block */\n", "\n", "#sk-container-id-1 div.sk-serial {\n", " display: flex;\n", " flex-direction: column;\n", " align-items: center;\n", " background-color: var(--sklearn-color-background);\n", " padding-right: 1em;\n", " padding-left: 1em;\n", "}\n", "\n", "\n", "/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n", "clickable and can be expanded/collapsed.\n", "- Pipeline and ColumnTransformer use this feature and define the default style\n", "- Estimators will overwrite some part of the style using the `sk-estimator` class\n", "*/\n", "\n", "/* Pipeline and ColumnTransformer style (default) */\n", "\n", "#sk-container-id-1 div.sk-toggleable {\n", " /* Default theme specific background. It is overwritten whether we have a\n", " specific estimator or a Pipeline/ColumnTransformer */\n", " background-color: var(--sklearn-color-background);\n", "}\n", "\n", "/* Toggleable label */\n", "#sk-container-id-1 label.sk-toggleable__label {\n", " cursor: pointer;\n", " display: block;\n", " width: 100%;\n", " margin-bottom: 0;\n", " padding: 0.5em;\n", " box-sizing: border-box;\n", " text-align: center;\n", "}\n", "\n", "#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n", " /* Arrow on the left of the label */\n", " content: \"▸\";\n", " float: left;\n", " margin-right: 0.25em;\n", " color: var(--sklearn-color-icon);\n", "}\n", "\n", "#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n", " color: var(--sklearn-color-text);\n", "}\n", "\n", "/* Toggleable content - dropdown */\n", "\n", "#sk-container-id-1 div.sk-toggleable__content {\n", " max-height: 0;\n", " max-width: 0;\n", " overflow: hidden;\n", " text-align: left;\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-0);\n", "}\n", "\n", "#sk-container-id-1 div.sk-toggleable__content.fitted {\n", " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-0);\n", "}\n", "\n", "#sk-container-id-1 div.sk-toggleable__content pre {\n", " margin: 0.2em;\n", " border-radius: 0.25em;\n", " color: var(--sklearn-color-text);\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-0);\n", "}\n", "\n", "#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n", " /* unfitted */\n", " background-color: var(--sklearn-color-fitted-level-0);\n", "}\n", "\n", "#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n", " /* Expand drop-down */\n", " max-height: 200px;\n", " max-width: 100%;\n", " overflow: auto;\n", "}\n", "\n", "#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n", " content: \"▾\";\n", "}\n", "\n", "/* Pipeline/ColumnTransformer-specific style */\n", "\n", "#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n", " color: var(--sklearn-color-text);\n", " background-color: var(--sklearn-color-unfitted-level-2);\n", "}\n", "\n", "#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n", " background-color: var(--sklearn-color-fitted-level-2);\n", "}\n", "\n", "/* Estimator-specific style */\n", "\n", "/* Colorize estimator box */\n", "#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-2);\n", "}\n", "\n", "#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n", " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-2);\n", "}\n", "\n", "#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n", "#sk-container-id-1 div.sk-label label {\n", " /* The background is the default theme color */\n", " color: var(--sklearn-color-text-on-default-background);\n", "}\n", "\n", "/* On hover, darken the color of the background */\n", "#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n", " color: var(--sklearn-color-text);\n", " background-color: var(--sklearn-color-unfitted-level-2);\n", "}\n", "\n", "/* Label box, darken color on hover, fitted */\n", "#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n", " color: var(--sklearn-color-text);\n", " background-color: var(--sklearn-color-fitted-level-2);\n", "}\n", "\n", "/* Estimator label */\n", "\n", "#sk-container-id-1 div.sk-label label {\n", " font-family: monospace;\n", " font-weight: bold;\n", " display: inline-block;\n", " line-height: 1.2em;\n", "}\n", "\n", "#sk-container-id-1 div.sk-label-container {\n", " text-align: center;\n", "}\n", "\n", "/* Estimator-specific */\n", "#sk-container-id-1 div.sk-estimator {\n", " font-family: monospace;\n", " border: 1px dotted var(--sklearn-color-border-box);\n", " border-radius: 0.25em;\n", " box-sizing: border-box;\n", " margin-bottom: 0.5em;\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-0);\n", "}\n", "\n", "#sk-container-id-1 div.sk-estimator.fitted {\n", " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-0);\n", "}\n", "\n", "/* on hover */\n", "#sk-container-id-1 div.sk-estimator:hover {\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-2);\n", "}\n", "\n", "#sk-container-id-1 div.sk-estimator.fitted:hover {\n", " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-2);\n", "}\n", "\n", "/* Specification for estimator info (e.g. \"i\" and \"?\") */\n", "\n", "/* Common style for \"i\" and \"?\" */\n", "\n", ".sk-estimator-doc-link,\n", "a:link.sk-estimator-doc-link,\n", "a:visited.sk-estimator-doc-link {\n", " float: right;\n", " font-size: smaller;\n", " line-height: 1em;\n", " font-family: monospace;\n", " background-color: var(--sklearn-color-background);\n", " border-radius: 1em;\n", " height: 1em;\n", " width: 1em;\n", " text-decoration: none !important;\n", " margin-left: 1ex;\n", " /* unfitted */\n", " border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n", " color: var(--sklearn-color-unfitted-level-1);\n", "}\n", "\n", ".sk-estimator-doc-link.fitted,\n", "a:link.sk-estimator-doc-link.fitted,\n", "a:visited.sk-estimator-doc-link.fitted {\n", " /* fitted */\n", " border: var(--sklearn-color-fitted-level-1) 1pt solid;\n", " color: var(--sklearn-color-fitted-level-1);\n", "}\n", "\n", "/* On hover */\n", "div.sk-estimator:hover .sk-estimator-doc-link:hover,\n", ".sk-estimator-doc-link:hover,\n", "div.sk-label-container:hover .sk-estimator-doc-link:hover,\n", ".sk-estimator-doc-link:hover {\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-3);\n", " color: var(--sklearn-color-background);\n", " text-decoration: none;\n", "}\n", "\n", "div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n", ".sk-estimator-doc-link.fitted:hover,\n", "div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n", ".sk-estimator-doc-link.fitted:hover {\n", " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-3);\n", " color: var(--sklearn-color-background);\n", " text-decoration: none;\n", "}\n", "\n", "/* Span, style for the box shown on hovering the info icon */\n", ".sk-estimator-doc-link span {\n", " display: none;\n", " z-index: 9999;\n", " position: relative;\n", " font-weight: normal;\n", " right: .2ex;\n", " padding: .5ex;\n", " margin: .5ex;\n", " width: min-content;\n", " min-width: 20ex;\n", " max-width: 50ex;\n", " color: var(--sklearn-color-text);\n", " box-shadow: 2pt 2pt 4pt #999;\n", " /* unfitted */\n", " background: var(--sklearn-color-unfitted-level-0);\n", " border: .5pt solid var(--sklearn-color-unfitted-level-3);\n", "}\n", "\n", ".sk-estimator-doc-link.fitted span {\n", " /* fitted */\n", " background: var(--sklearn-color-fitted-level-0);\n", " border: var(--sklearn-color-fitted-level-3);\n", "}\n", "\n", ".sk-estimator-doc-link:hover span {\n", " display: block;\n", "}\n", "\n", "/* \"?\"-specific style due to the `<a>` HTML tag */\n", "\n", "#sk-container-id-1 a.estimator_doc_link {\n", " float: right;\n", " font-size: 1rem;\n", " line-height: 1em;\n", " font-family: monospace;\n", " background-color: var(--sklearn-color-background);\n", " border-radius: 1rem;\n", " height: 1rem;\n", " width: 1rem;\n", " text-decoration: none;\n", " /* unfitted */\n", " color: var(--sklearn-color-unfitted-level-1);\n", " border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n", "}\n", "\n", "#sk-container-id-1 a.estimator_doc_link.fitted {\n", " /* fitted */\n", " border: var(--sklearn-color-fitted-level-1) 1pt solid;\n", " color: var(--sklearn-color-fitted-level-1);\n", "}\n", "\n", "/* On hover */\n", "#sk-container-id-1 a.estimator_doc_link:hover {\n", " /* unfitted */\n", " background-color: var(--sklearn-color-unfitted-level-3);\n", " color: var(--sklearn-color-background);\n", " text-decoration: none;\n", "}\n", "\n", "#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n", " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-3);\n", "}\n", "</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>XGBClassifier(base_score=None, booster=None, callbacks=None,\n", " colsample_bylevel=None, colsample_bynode=None,\n", " colsample_bytree=None, device=None, early_stopping_rounds=None,\n", " enable_categorical=False, eval_metric=None, feature_types=None,\n", " gamma=None, grow_policy=None, importance_type=None,\n", " interaction_constraints=None, learning_rate=0.04, max_bin=None,\n", " max_cat_threshold=None, max_cat_to_onehot=None,\n", " max_delta_step=None, max_depth=8, max_leaves=None,\n", " min_child_weight=None, missing=nan, monotone_constraints=None,\n", " multi_strategy=None, n_estimators=2000, n_jobs=None,\n", " num_parallel_tree=None, random_state=None, ...)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\"> XGBClassifier<span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>XGBClassifier(base_score=None, booster=None, callbacks=None,\n", " colsample_bylevel=None, colsample_bynode=None,\n", " colsample_bytree=None, device=None, early_stopping_rounds=None,\n", " enable_categorical=False, eval_metric=None, feature_types=None,\n", " gamma=None, grow_policy=None, importance_type=None,\n", " interaction_constraints=None, learning_rate=0.04, max_bin=None,\n", " max_cat_threshold=None, max_cat_to_onehot=None,\n", " max_delta_step=None, max_depth=8, max_leaves=None,\n", " min_child_weight=None, missing=nan, monotone_constraints=None,\n", " multi_strategy=None, n_estimators=2000, n_jobs=None,\n", " num_parallel_tree=None, random_state=None, ...)</pre></div> </div></div></div></div>" ], "text/plain": [ "XGBClassifier(base_score=None, booster=None, callbacks=None,\n", " colsample_bylevel=None, colsample_bynode=None,\n", " colsample_bytree=None, device=None, early_stopping_rounds=None,\n", " enable_categorical=False, eval_metric=None, feature_types=None,\n", " gamma=None, grow_policy=None, importance_type=None,\n", " interaction_constraints=None, learning_rate=0.04, max_bin=None,\n", " max_cat_threshold=None, max_cat_to_onehot=None,\n", " max_delta_step=None, max_depth=8, max_leaves=None,\n", " min_child_weight=None, missing=nan, monotone_constraints=None,\n", " multi_strategy=None, n_estimators=2000, n_jobs=None,\n", " num_parallel_tree=None, random_state=None, ...)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "xgb_predict = XGBClassifier(n_estimators=2000, learning_rate=0.04, max_depth=8)\n", "xgb_predict.fit(df_embeddings_train, df_train_normalized['p_np'])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# get XGBoost predictions\n", "y_prob = xgb_predict.predict_proba(df_embeddings_test)[:, 1]" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ROC-AUC Score: 0.9194\n" ] } ], "source": [ "roc_auc = roc_auc_score(df_test_normalized[\"p_np\"], y_prob)\n", "print(f\"ROC-AUC Score: {roc_auc:.4f}\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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 }