Here is the task:

An experimental drug was tested on individuals from 13 to 100.

The trail had 2100 participants. Half were under 65 years old, half were over

65 years old.

95% of patients 65 or older experianced no side effects.

95% of patients under 65 experianced no side effects.

```
import numpy as np
from random import randint
mport keras
from keras import backend as K
from keras.models import Sequential
from keras.layers import Activation
from keras.layers.core import Dense
from keras.optimizers import Adam
from keras.metrics import categorical_crossentropy
from sklearn.preprocessing import MinMaxScaler
train_labels = []
train_samples = []
for i in range(1000):
random_younger = randint(13,64)
train_samples.append(random_younger)
train_labels.append(0)
random_older = randint(65,100)
train_samples.append(random_older)
train_labels.append(1)
for i in range(50):
random_younger = randint(13,64)
train_samples.append(random_younger)
train_labels.append(1)
random_older = randint(65,100)
train_samples.append(random_older)
train_labels.append(0)
for i in train_labels:
print(i)
for i in train_samples:
print(i)
train_labels = np.array(train_labels)
train_samples = np.array(train_samples)
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_train_samples = scaler.fit_transform((train_samples).reshape(-1, 1))
for i in scaled_train_samples:
print(i)
model = Sequential([
Dense(16, activation="relu", input_shape=(1,)),
Dense(32, activation="relu"),
Dense(2, activation="softmax"),
])
model.summary()
model.compile(Adam(lr=.0001), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(scaled_train_samples, train_labels, batch_size=10, epochs=20, shuffle=True, verbose=2 )
```

What we have in here:

Layer (type) Output Shape Param #

=================================================================

dense_1 (Dense) (None, 16) 32

_________________________________________________________________

dense_2 (Dense) (None, 32) 544

_________________________________________________________________

dense_3 (Dense) (None, 2) 66

=================================================================

Total params: 642

Trainable params: 642

Non-trainable params: 0

```
Epoch 1/20
- 0s - loss: 0.6623 - acc: 0.5557
Epoch 2/20
- 0s - loss: 0.6345 - acc: 0.6590
Epoch 3/20
- 0s - loss: 0.6002 - acc: 0.7438
Epoch 4/20
- 0s - loss: 0.5680 - acc: 0.7862
Epoch 5/20
- 0s - loss: 0.5319 - acc: 0.8138
Epoch 6/20
- 0s - loss: 0.4969 - acc: 0.8462
Epoch 7/20
- 0s - loss: 0.4645 - acc: 0.8586
Epoch 8/20
- 0s - loss: 0.4345 - acc: 0.8714
Epoch 9/20
- 0s - loss: 0.4074 - acc: 0.8833
Epoch 10/20
- 0s - loss: 0.3834 - acc: 0.8929
Epoch 11/20
- 0s - loss: 0.3629 - acc: 0.9033
Epoch 12/20
- 0s - loss: 0.3453 - acc: 0.9048
Epoch 13/20
- 0s - loss: 0.3307 - acc: 0.9110
Epoch 14/20
- 0s - loss: 0.3185 - acc: 0.9129
Epoch 15/20
- 0s - loss: 0.3083 - acc: 0.9171
Epoch 16/20
- 0s - loss: 0.2999 - acc: 0.9167
Epoch 17/20
- 0s - loss: 0.2929 - acc: 0.9219
Epoch 18/20
- 0s - loss: 0.2871 - acc: 0.9262
Epoch 19/20
- 0s - loss: 0.2823 - acc: 0.9257
Epoch 20/20
- 0s - loss: 0.2781 - acc: 0.9238
```

Where if you would like to save the model and parameters this code would work.

```
model_json = model.to_json()
with open("model.json", "w") as json_file:
json_file.write(model_json)
# serialize weights to HDF5
model.save_weights("model.h5")
print("Saved model to disk")
from google.colab import files
files.download('model.json')
```