2019-02-27 11:36:20 +00:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
from utils import *
|
2019-03-05 07:59:30 +00:00
|
|
|
from nn import B, compile_b
|
2019-02-27 11:36:20 +00:00
|
|
|
from draw import draw
|
|
|
|
import time
|
|
|
|
|
|
|
|
def chunker(seq, size):
|
|
|
|
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
|
|
|
|
|
|
|
|
year = MAX_YEAR - 1
|
|
|
|
|
2019-03-05 07:59:30 +00:00
|
|
|
df = pd.read_pickle('data.p')
|
2019-02-27 11:36:20 +00:00
|
|
|
|
2019-02-28 10:04:47 +00:00
|
|
|
compile_b()
|
2019-02-27 11:36:20 +00:00
|
|
|
|
2019-02-28 10:04:47 +00:00
|
|
|
for change in range(0, 1):
|
2019-02-27 11:36:20 +00:00
|
|
|
print('TEMPERATURE MODIFICATION OF {}'.format(change))
|
|
|
|
|
2019-03-05 11:53:29 +00:00
|
|
|
inputs = ['elevation', 'distance_to_water', 'latitude']
|
2019-02-27 11:36:20 +00:00
|
|
|
|
|
|
|
for season in SEASONS:
|
|
|
|
inputs += [
|
|
|
|
'temp_{}_{}'.format(season, year),
|
|
|
|
'precip_{}_{}'.format(season, year)
|
|
|
|
]
|
|
|
|
|
2019-03-05 11:53:29 +00:00
|
|
|
print(inputs)
|
|
|
|
|
2019-03-05 07:59:30 +00:00
|
|
|
# print(inputs)
|
2019-03-05 11:53:29 +00:00
|
|
|
frame = df[inputs + ['longitude']]
|
2019-03-05 07:59:30 +00:00
|
|
|
# print(frame.head())
|
2019-02-27 11:36:20 +00:00
|
|
|
|
2019-02-28 10:04:47 +00:00
|
|
|
for season in SEASONS:
|
|
|
|
frame.loc[:, 'temp_{}_{}'.format(season, year)] += change
|
2019-02-27 11:36:20 +00:00
|
|
|
|
2019-03-05 07:59:30 +00:00
|
|
|
columns = ['latitude', 'longitude', 'biome_num']
|
2019-02-27 11:36:20 +00:00
|
|
|
new_data = pd.DataFrame(columns=columns)
|
2019-03-05 07:59:30 +00:00
|
|
|
|
2019-02-27 11:36:20 +00:00
|
|
|
for i, chunk in enumerate(chunker(frame, B.batch_size)):
|
2019-03-05 07:59:30 +00:00
|
|
|
if chunk.shape[0] < B.batch_size:
|
|
|
|
continue
|
2019-03-05 11:53:29 +00:00
|
|
|
input_data = normalize_ndarray(chunk.loc[:, inputs].values)
|
2019-02-27 11:36:20 +00:00
|
|
|
out = B.predict(input_data)
|
|
|
|
|
2019-03-05 07:59:30 +00:00
|
|
|
f = pd.DataFrame({
|
|
|
|
'longitude': chunk.loc[:, 'longitude'],
|
|
|
|
'latitude': chunk.loc[:, 'latitude'],
|
|
|
|
'biome_num': out
|
|
|
|
}, columns=columns)
|
|
|
|
new_data = new_data.append(f)
|
2019-02-27 11:36:20 +00:00
|
|
|
|
|
|
|
draw(new_data)
|