import tensorflow as tf
import numpy as np

X = [0.3,-0.78,1.26,0.03,1.11,0.24,-0.24,-0.47,-0.77,-0.37,-0.85,-0.41,-0.27,0.02,-0.76,2.66]
Y = [12.27,14.44,11.87,18.75,17.52,16.37,19.78,19.51,12.65,14.74,10.72,21.94,12.83,15.51,17.14,14.42]

model = tf.keras.Sequential([
    tf.keras.layers.Dense(units = 6, activation = 'tanh', input_shape= (1,)),
    tf.keras.layers.Dense(units = 1)
])

model.compile(optimizer = tf.keras.optimizers.SGD(lr=0.1), loss='mse')
model.summary()
model.fit(X,Y, epochs = 10) # 학습하기
model.predict(X)

import matplotlib.pyplot as plt

line_x = np.arange(min(X),max(X), 0.01)
line_y = model.predict(line_x)

plt.plot(line_x, line_y,'r-')
plt.plot(X,Y, 'bo')
plt.xlabel('population growth rate(%)')
plt.ylabel('elderly rate(%)')
plt.show()
