application_vnd.jupyter.stderr_output_27.png application_vnd.jupyter.stderr_output_35.png application_vnd.jupyter.stderr_output_24.png application_vnd.jupyter.stderr_output_16.png application_vnd.jupyter.stderr_output_9.png application_vnd.jupyter.stderr_output_32.png application_vnd.jupyter.stderr_output_2.png application_vnd.jupyter.stderr_output_7.png application_vnd.jupyter.stderr_output_11.png application_vnd.jupyter.stderr_output_18.png application_vnd.jupyter.stderr_output_38.png application_vnd.jupyter.stderr_output_4.png application_vnd.jupyter.stderr_output_26.png application_vnd.jupyter.stderr_output_6.png application_vnd.jupyter.stderr_output_31.png application_vnd.jupyter.stderr_output_33.png application_vnd.jupyter.stderr_output_25.png application_vnd.jupyter.stderr_output_12.png application_vnd.jupyter.stderr_output_8.png application_vnd.jupyter.stderr_output_10.png application_vnd.jupyter.stderr_output_23.png application_vnd.jupyter.stderr_output_34.png application_vnd.jupyter.stderr_output_19.png application_vnd.jupyter.stderr_output_13.png application_vnd.jupyter.stderr_output_3.png application_vnd.jupyter.stderr_output_5.png application_vnd.jupyter.stderr_output_30.png application_vnd.jupyter.stderr_output_15.png application_vnd.jupyter.stderr_output_17.png application_vnd.jupyter.stderr_output_28.png application_vnd.jupyter.stderr_output_20.png application_vnd.jupyter.stderr_output_36.png application_vnd.jupyter.stderr_output_22.png application_vnd.jupyter.stderr_output_29.png application_vnd.jupyter.stderr_output_1.png application_vnd.jupyter.stderr_output_14.png application_vnd.jupyter.stderr_output_21.png application_vnd.jupyter.stderr_output_37.png
from rdkit import Chem

from rdkit.Chem import AllChem

import deepchem as dc

import numpy as np

import pandas as pd

df_train = pd.read_csv('/kaggle/input/aqueous-solubility-predictioin/train.csv')
df_test = pd.read_csv('/kaggle/input/aqueous-solubility-predictioin/test.csv')

df_train.shape

smiles_list = df_train['SMILES'][:10]

mol_list = []
for smile in smiles_list:
    mol = Chem.MolFromSmiles(smile)
    mol_list.append(mol)
img = Chem.Draw.MolsToGridImage(mol_list, molsPerRow=5)
img

df_train.columns

X = df_train.drop(columns=['ID', 'Name', 'InChI', 'InChIKey', 'SMILES', 'SD', 'Ocurrences', 'Group', 'comp_id'])

# Define a function to featurize a SMILES string
def featurize_smiles(smiles):
    mol = Chem.MolFromSmiles(smiles)
    fp = AllChem.GetMorganFingerprintAsBitVect(mol, 3, nBits=1024)
    features = np.array(list(fp.ToBitString())).astype(float)
    return features

smiles = ['CCC']
featurizer = dc.feat.Mol2VecFingerprint()
features = featurizer.featurize(smiles)

features = featurizer.featurize(df_train['SMILES'])

features.shape

smiles = ['CC(=O)OC1=CC=CC=C1C(=O)O']
featurizer = dc.feat.RDKitDescriptors()
features = featurizer.featurize(smiles)

features.shape

features = featurizer.featurize(df_train['SMILES'])

smiles = ['CC(=O)OC1=CC=CC=C1C(=O)O']
featurizer = dc.feat.MordredDescriptors()
features = featurizer.featurize(smiles)

features = featurizer.featurize(df_train['SMILES'])

features.shape