text_plain_output_2.png text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

plt.rcParams['figure.figsize'] = [12, 5]

train = pd.read_csv('../input/drugsComTrain_raw.csv')
test = pd.read_csv('../input/drugsComTest_raw.csv')

data = pad_sequences(sequences, maxlen=sequence_length)

ratings = train['rating'].values
labels = 1.0 * (ratings >= 8) + 1.0 * (ratings >= 5)

hot_labels = to_categorical(labels)
hot_labels[:3]

VALIDATION_SPLIT = 0.25
N = int(VALIDATION_SPLIT * data.shape[0])
indices = np.arange(data.shape[0])
np.random.shuffle(indices)
data = data[indices]
hot_labels = hot_labels[indices]
train_data = data[:-N]
train_cat = hot_labels[:-N]
val_data = data[-N:]
val_cat = hot_labels[-N:]

acc = history.history['acc']
val_acc = history.history['val_acc']
loss = history.history['loss']
val_loss = history.history['val_loss']
e = np.arange(len(acc)) + 1
plt.plot(e, acc, label='train')
plt.plot(e, val_acc, label='validation')
plt.title('Training and validation accuracy')
plt.xlabel('Epoch')
plt.grid()
plt.legend()
plt.figure()
plt.plot(e, loss, label='train')
plt.plot(e, val_loss, label='validation')
plt.title('Training and validation loss')
plt.xlabel('Epoch')
plt.grid()
plt.legend()
plt.show()