Learn practical skills, build real-world projects, and advance your career
!pip install jovian -q
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras.layers import *
from sklearn.metrics import *
from sklearn.model_selection import train_test_split
import jovian
from tqdm import tqdm_notebook
import warnings
warnings.simplefilter("ignore")
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available. You should consider upgrading via the '/opt/conda/bin/python3.7 -m pip install --upgrade pip' command.
chem_df = pd.read_csv("../input/drug-drug-similarity-dataset/chem_Jacarrd_sim.csv",index_col=0)
indication_df = pd.read_csv("../input/drug-drug-similarity-dataset/enzyme_Jacarrd_sim.csv",index_col=0)
target_df = pd.read_csv("../input/drug-drug-similarity-dataset/target_Jacarrd_sim.csv",index_col=0)
transporter_df = pd.read_csv("../input/drug-drug-similarity-dataset/transporter_Jacarrd_sim.csv",index_col=0)
#------------------ Using only 4 datassets for the model--------------------

drug_drug_matrix = pd.read_csv("../input/drug-drug-similarity-dataset/drug_drug_matrix.csv",index_col=0) #--> Labels
#---------------------------------------------------------------------------

enzyme_df = pd.read_csv("../input/drug-drug-similarity-dataset/enzyme_Jacarrd_sim.csv",index_col=0)
pathway_df = pd.read_csv("../input/drug-drug-similarity-dataset/pathway_Jacarrd_sim.csv",index_col=0)
offsideeffect_df = pd.read_csv("../input/drug-drug-similarity-dataset/offsideeffect_Jacarrd_sim.csv",index_col=0)
sideeffect_df = pd.read_csv("../input/drug-drug-similarity-dataset/sideeffect_Jacarrd_sim.csv",index_col=0)


complete_df = chem_df+indication_df+target_df+transporter_df+enzyme_df+pathway_df+offsideeffect_df+sideeffect_df
integrated_df = pd.DataFrame(np.zeros((149878, 1096)))
integrated_target = pd.DataFrame(np.zeros((149878,1)))
ind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = complete_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = complete_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            integrated_df.iloc[ind] = a+b
            integrated_target.iloc[ind] = drug_drug_matrix.iloc[i,j]
            ind+=1
        except:
            flag=1
            break
    if flag:
        break
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
chem_df1 = pd.DataFrame(np.zeros((149878, 1096)))
indication_df1 = pd.DataFrame(np.zeros((149878, 1096)))
target_df1 = pd.DataFrame(np.zeros((149878, 1096)))
transporter_df1 = pd.DataFrame(np.zeros((149878, 1096)))
enzyme_df1 = pd.DataFrame(np.zeros((149878, 1096)))
pathway_df1 = pd.DataFrame(np.zeros((149878, 1096)))
offsideeffect_df1 = pd.DataFrame(np.zeros((149878, 1096)))
sideeffect_df1 = pd.DataFrame(np.zeros((149878, 1096)))
ind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = chem_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = chem_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            chem_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        break
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = indication_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = indication_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            indication_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        breakind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = target_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = target_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            target_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        breakind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = transporter_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = transporter_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            transporter_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        breakind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = enzyme_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = enzyme_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            enzyme_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        breakind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = pathway_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = pathway_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            pathway_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        breakind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = offsideeffect_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = offsideeffect_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            offsideeffect_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        breakind=0
flag=0
for i in tqdm_notebook(range(515)):
    for j in range(i,548):
        a = sideeffect_df.iloc[i].to_numpy().reshape(1,-1).tolist()[0]
        b = sideeffect_df.iloc[j].to_numpy().reshape(1,-1).tolist()[0]
        try:
            sideeffect_df1.iloc[ind] = a+b
            ind+=1
        except:
            flag=1
            break
    if flag:
        break
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))
HBox(children=(FloatProgress(value=0.0, max=515.0), HTML(value='')))