2019-02-27 11:36:20 +00:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
from utils import *
|
|
|
|
from nn import B
|
|
|
|
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
|
|
|
|
|
|
|
|
df = pd.read_pickle('data_final.p')
|
|
|
|
latitude = np.array(df.index.get_level_values(1))
|
|
|
|
df.loc[:, 'latitude'] = pd.Series(latitude, index=df.index)
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
inputs = ['elevation', 'distance_to_water']
|
|
|
|
|
|
|
|
for season in SEASONS:
|
|
|
|
inputs += [
|
|
|
|
'temp_{}_{}'.format(season, year),
|
|
|
|
'precip_{}_{}'.format(season, year)
|
|
|
|
]
|
|
|
|
|
|
|
|
inputs += ['latitude']
|
|
|
|
|
|
|
|
frame = df[inputs]
|
|
|
|
print(frame.head())
|
|
|
|
|
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
|
|
|
|
|
|
|
columns = ['biome_num']
|
|
|
|
new_data = pd.DataFrame(columns=columns)
|
|
|
|
for i, chunk in enumerate(chunker(frame, B.batch_size)):
|
|
|
|
input_data = normalize_ndarray(chunk.values)
|
|
|
|
out = B.predict(input_data)
|
|
|
|
new_index = np.concatenate((chunk.index.values, new_data.index.values))
|
|
|
|
|
|
|
|
new_data = new_data.reindex(new_index)
|
|
|
|
new_data.loc[chunk.index.values, 'biome_num'] = out
|
|
|
|
|
|
|
|
draw(new_data)
|