<jupyter_start><jupyter_text>NormalizaçãoComparison between training with normalized states and non-normalized states.___<jupyter_code>import pickle
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from sys_simulator.general import load_with_pickle, sns_confidence_interval_plot
from copy import deepcopy
import os
EXP_NAME = 'normalizacao'

# ddpg
ALGO_NAME = 'ddpg'
norm_path = "/home/lucas/dev/sys-simulator-2/data/ddpg/script7/20210506-100648/log.pickle"
raw_path = "/home/lucas/dev/sys-simulator-2/data/ddpg/script7/20210516-134443/log.pickle"
# dql
# ALGO_NAME = 'dql'
# norm_path = "/home/lucas/dev/sys-simulator-2/data/dql/script52/20210508-144816/log.pickle"
# raw_path = "/home/lucas/dev/sys-simulator-2/data/dql/script52/20210514-080734/log.pickle"
# a2c
# ALGO_NAME = 'a2c'
# filepath = "D:\\Dev\\sys-simulator-2\\data\\a2c\\script16\\20210509-134816\\log.pickle"
# output path
# OUTPUT_PATH = f'D:\\Dev\\sys-simulator-2\\figs\\{EXP_NAME}\\{ALGO_NAME}'
OUTPUT_PATH = f'/home/lucas/dev/sys-simulator-2/figs/{EXP_NAME}/{ALGO_NAME}'

norm_data = load_with_pickle(norm_path)
raw_data = load_with_pickle(raw_path)
EVAL_EVERY = norm_data['eval_every']
print(EVAL_EVERY)
print(raw_data['eval_every'])
norm_train = norm_data['train_bags']
norm_test = norm_data['test_bags']
raw_train = raw_data['train_bags']
raw_test = raw_data['test_bags']
xx = norm_test['mue_sinrs']
xx = np.array(xx)
xx.shape
xx = norm_train['mue_sinrs']
xx = np.array(xx)
xx.shape
norm_mue_sinrs = deepcopy(norm_train['mue_sinrs'])
norm_mue_sinrs.append(norm_test['mue_sinrs'])
norm_mue_sinrs = np.array(norm_mue_sinrs)
raw_mue_sinrs = deepcopy(raw_train['mue_sinrs'])
raw_mue_sinrs.append(raw_test['mue_sinrs'])
raw_mue_sinrs = np.array(raw_mue_sinrs)
norm_d2d_sinrs = deepcopy(norm_train['d2d_sinrs'])
norm_d2d_sinrs.append(norm_test['d2d_sinrs'])
norm_d2d_sinrs = np.array(norm_d2d_sinrs)
raw_d2d_sinrs = deepcopy(raw_train['d2d_sinrs'])
raw_d2d_sinrs.append(raw_test['d2d_sinrs'])
raw_d2d_sinrs = np.array(raw_d2d_sinrs)
sinr_threshold = norm_data['mue_sinr_threshold']
norm_mue_avail = deepcopy(norm_mue_sinrs >= sinr_threshold)
raw_mue_avail = deepcopy(raw_mue_sinrs >= sinr_threshold)
norm_rewards = deepcopy(norm_train['rewards'])
norm_rewards.append(norm_test['rewards'])
norm_rewards = np.array(norm_rewards)
raw_rewards = deepcopy(raw_train['rewards'])
raw_rewards.append(raw_test['rewards'])
raw_rewards = np.array(raw_rewards)<jupyter_output><empty_output><jupyter_text>Fonts configs<jupyter_code>x_font = {
    'family': 'serif',
    'color':  'black',
    'weight': 'normal',
    'size': 16,
}
y_font = {
    'family': 'serif',
    'color':  'black',
    'weight': 'normal',
    'size': 16,
}
ticks_font = {
    'fontfamily': 'serif',
    'fontsize': 13
}
legends_font = {
    'size': 13,
    'family': 'serif'
}<jupyter_output><empty_output><jupyter_text>Ticks<jupyter_code>x_ticks = [i*EVAL_EVERY*(norm_mue_sinrs.shape[0]-1)/5 for i in range(6)]<jupyter_output><empty_output><jupyter_text>MUE SINR<jupyter_code>x = np.ones(norm_mue_sinrs.shape)
for i in range(norm_mue_sinrs.shape[0]):
    x[i, :] = i
x = x.reshape(-1)
x *= EVAL_EVERY
plt.figure(figsize=(10,7))
sns.lineplot(x=x, y=norm_mue_sinrs.reshape(-1), label='Normalized')
sns.lineplot(x=x, y=raw_mue_sinrs.reshape(-1), label='Raw')
plt.xlabel('Steps', fontdict=x_font)
plt.ylabel('Average MUE SINR [dB]', fontdict=y_font)
plt.xticks(x_ticks, **ticks_font)
plt.yticks(**ticks_font)
plt.legend(prop=legends_font)
fig_name = 'mue-sinr'
svg_path = f'{OUTPUT_PATH}/{fig_name}.svg'
eps_path = f'{OUTPUT_PATH}/{fig_name}.eps'
print(svg_path)
# save fig
plt.savefig(svg_path)
os.system(f'magick convert {svg_path} {eps_path}')
plt.show()
## D2D SINR
plt.figure(figsize=(10,7))
sns.lineplot(x=x, y=norm_d2d_sinrs[:,:,0].reshape(-1), label='Normalized')
sns.lineplot(x=x, y=raw_d2d_sinrs[:,:,0].reshape(-1), label='Raw')
plt.xlabel('Steps', fontdict=x_font)
plt.ylabel('Average D2D SINR [dB]', fontdict=y_font)
plt.xticks(x_ticks, **ticks_font)
plt.yticks(**ticks_font)
plt.legend(prop=legends_font)
fig_name = 'd2d-sinr'
svg_path = f'{OUTPUT_PATH}/{fig_name}.svg'
eps_path = f'{OUTPUT_PATH}/{fig_name}.eps'
print(svg_path)
# save fig
plt.savefig(svg_path)
os.system(f'magick convert {svg_path} {eps_path}')
plt.show()<jupyter_output>/home/lucas/dev/sys-simulator-2/figs/normalizacao/ddpg/d2d-sinr.svg<jupyter_text>MUE availability<jupyter_code>plt.figure(figsize=(10,7))
sns.lineplot(x=x, y=norm_mue_avail.reshape(-1), label='Normalized')
sns.lineplot(x=x, y=raw_mue_avail.reshape(-1), label='Raw')
plt.xlabel('Steps', fontdict=x_font)
plt.ylabel('Average MUE availability', fontdict=y_font)
plt.xticks(x_ticks, **ticks_font)
plt.yticks([0., .2, .4, .6, .8, .9, .95, 1.], **ticks_font)
plt.legend(prop=legends_font)
fig_name = 'mue-availability'
svg_path = f'{OUTPUT_PATH}/{fig_name}.svg'
eps_path = f'{OUTPUT_PATH}/{fig_name}.eps'
print(svg_path)
# save fig
plt.savefig(svg_path)
os.system(f'magick convert {svg_path} {eps_path}')
plt.show()<jupyter_output>/home/lucas/dev/sys-simulator-2/figs/normalizacao/ddpg/mue-availability.svg<jupyter_text>Rewards<jupyter_code>plt.figure(figsize=(10,7))
if ALGO_NAME != 'ddpg':
    sns.lineplot(x=x, y=norm_rewards[:,:,0].reshape(-1), label='Normalized')
    sns.lineplot(x=x, y=raw_rewards[:,:,0].reshape(-1), label='Raw')
    # sns.lineplot(x=x, y=rewards[:,:,1].reshape(-1), label='Device 2')
else:
    sns.lineplot(x=x, y=norm_rewards.reshape(-1), label='Normalized')
    sns.lineplot(x=x, y=raw_rewards.reshape(-1), label='Raw')
plt.xlabel('Steps', fontdict=x_font)
plt.ylabel('Average Rewards', fontdict=y_font)
plt.xticks(x_ticks, **ticks_font)
plt.yticks(**ticks_font)
plt.legend(prop=legends_font)
fig_name = 'rewards'
svg_path = f'{OUTPUT_PATH}/{fig_name}.svg'
eps_path = f'{OUTPUT_PATH}/{fig_name}.eps'
print(svg_path)
# save fig
plt.savefig(svg_path)
os.system(f'magick convert {svg_path} {eps_path}')
plt.show()<jupyter_output>/home/lucas/dev/sys-simulator-2/figs/normalizacao/ddpg/rewards.svg
{'fraction_non_alphanumeric': 0.1721909181305933, 'fraction_numerical': 0.02668213457076566, 'mean_word_length': 7.188602442333786, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '215220', 'license': 'MIT', 'n_tokens_mistral': 2773, 'n_tokens_neox': 2645, 'n_words': 326, 'path': 'notebooks/figs-notebooks/.ipynb_checkpoints/normalizacao-checkpoint.ipynb', 'repo_name': 'lbaiao/sys-simulator-2', 'size': '6034'}