import numpy as np
np.random.seed(1337)
from keras.models import Sequential
from keras.layers import Dense
import matplotlib.pyplot as plt

model = Sequential()
model.add(Dense(units=50, input_dim=1, activation='relu'))
model.add(Dense(units=50, activation='relu'))
model.add(Dense(units=1, activation='sigmoid'))
model.add(Dense(units=1, activation='linear'))
model.compile(optimizer='adam', loss='mean_squared_error')
model.summary()

import csv

with open('data/france_history.csv', 'r') as csvfile:
    reader = csv.reader(csvfile)
    rows = [row for row in reader]


fr_corn_y = []

for each_y in rows:
    fr_corn_y.append(int(each_y[0]))


dates = len(fr_corn_y)
fr_corn_x = list(range(1, dates + 1))

fr_corn_x = np.array(fr_corn_x)
fr_corn_y = np.array(fr_corn_y)

fr_dates_length = len(fr_corn_x)
fr_absorb = fr_corn_y[fr_dates_length-1]

corn_y_norm = fr_corn_y / fr_absorb

model.fit(fr_corn_x, corn_y_norm, epochs=10000, shuffle=False)
corn_y_predict = model.predict(fr_corn_x)
corn_y_predict = corn_y_predict * fr_absorb
fig_italy = plt.figure(figsize=(7, 5))
plt.scatter(fr_corn_x, fr_corn_y, label='Real Confirmed')
plt.plot(fr_corn_x, corn_y_predict, label='Predict Result')
plt.title('France Confirmed VS Dates')
plt.xlabel('Dates')
plt.ylabel('Amount')
plt.legend()
plt.show()
import numpy as np
np.random.seed(1337)
from keras.models import Sequential
from keras.layers import Dense
import matplotlib.pyplot as plt

model = Sequential()
model.add(Dense(units=50, input_dim=1, activation='relu'))
model.add(Dense(units=50, activation='relu'))
model.add(Dense(units=1, activation='sigmoid'))
model.add(Dense(units=1, activation='linear'))
model.compile(optimizer='adam', loss='mean_squared_error')
model.summary()

import csv

with open('data/france_history.csv', 'r') as csvfile:
    reader = csv.reader(csvfile)
    rows = [row for row in reader]


fr_corn_y = []

for each_y in rows:
    fr_corn_y.append(int(each_y[0]))


dates = len(fr_corn_y)
fr_corn_x = list(range(1, dates + 1))

fr_corn_x = np.array(fr_corn_x)
fr_corn_y = np.array(fr_corn_y)

fr_dates_length = len(fr_corn_x)
fr_absorb = fr_corn_y[fr_dates_length-1]

corn_y_norm = fr_corn_y / fr_absorb

model.fit(fr_corn_x, corn_y_norm, epochs=10000, shuffle=False)
corn_y_predict = model.predict(fr_corn_x)
corn_y_predict = corn_y_predict * fr_absorb
fig_italy = plt.figure(figsize=(7, 5))
plt.scatter(fr_corn_x, fr_corn_y, label='Real Confirmed')
plt.plot(fr_corn_x, corn_y_predict, label='Predict Result')
plt.title('France Confirmed VS Dates')
plt.xlabel('Dates')
plt.ylabel('Amount')
plt.legend()
plt.show()