<jupyter_start><jupyter_text>Analysis for FreeRadius (vAAA)<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
#import matplotlib
import numpy as np
#sns.set(font_scale=1.3, style="ticks")
def select_and_rename(df, mapping):
    """
    Helper: Selects columns of df using the keys
    of the mapping dict.
    It renames the columns to the values of the
    mappings dict.
    """
    # select subset of columns
    dff = df[list(mapping.keys())]
    # rename 
    for k, v in mapping.items():
        #print("Renaming: {} -> {}".format(k, v))
        dff.rename(columns={k: v}, inplace=True)
    #print(dff.head())
    return dff<jupyter_output><empty_output><jupyter_text>Read result File<jupyter_code>#df = pd.read_csv("/home/arif/gitRepos/ah-tng-bench-experiments/results-archive/vaaa_results_20191126_second_run/result_ec_metrics.csv")
df = pd.read_csv("/Users/arifhossen/ArifDevelopmentWork/gitRepos/ah-tng-bench-experiments/results-archive/20191205_1000_run_result/result_ec_metrics.csv")
df
df.columns.tolist()
vaaa_map_01 = {
    "param__func__mp.input__cmd_start": "req_size",
    "param__func__de.upb.vAAA.0.1__cpu_bw": "cpu_bw",
    "param__func__de.upb.vAAA.0.1__mem_max": "memory",
    "param__func__mp.input__cpu_bw": "probe_cpu_bw",
    "metric__vnf0.vdu01.0__FreeRADIUS-Total-Auth-Responses": "Radius-Auth-Response",
    "metric__mp.input.vdu01.0__FreeRADIUS-Total-Auth-Responses": "Probe-Radius-Auth-Response",
    #"param__func__mp.input__mem_max": "probe_memory",
    #"metric__mp.input.vdu01.0__ab_total_transfer_byte": "transf_bytes",
    #"metric__mp.input.vdu01.0__ab_transfer_rate_kbyte_per_second": "req_transf_rate",
    "metric__vnf0.vdu01.0__stat__input__rx_bytes": "if_rx_bytes",
    #"metric__vnf0.vdu01.0__stat__input__rx_dropped": "if_in_rx_dropped",
    #"metric__vnf0.vdu01.0__stat__input__rx_errors": "if_in_rx_errors",
    #"metric__vnf0.vdu01.0__stat__input__rx_packets": "if_in_rx_packets",
    "metric__vnf0.vdu01.0__stat__input__tx_bytes": "if_tx_bytes",
    #"metric__vnf0.vdu01.0__stat__input__tx_dropped": "if_in_tx_dropped",
    #"metric__vnf0.vdu01.0__stat__input__tx_errors": "if_in_tx_errors",
    #"metric__vnf0.vdu01.0__stat__input__tx_packets": "if_in_tx_packets",
}

def cleanup(df):
    """
    Cleanup of df data.
    Dataset specific.
    """
    def _replace(df, column, str1, str2):
        if column in df:
            df[column] = df[column].str.replace(str1, str2)
            
    def _to_num(df, column):
        if column in df:
            df[column] = pd.to_numeric(df[column])
        
    #_replace(df, "req_size", "ab -c 1 -t 60 -n 9999 -e /tngbench_share/ab_logs.csv -s 60 -k -i http://192.168.3.11:80/", "-")

df["vnf"] = "vaaa"

dfs_raw = [df]
map_list = [vaaa_map_01]
dfs = list()  # clean data frames

for (df, m) in zip(dfs_raw, map_list):
    tmp = select_and_rename(df.copy(), m)
    #cleanup(tmp)
    dfs.append(tmp)

#dfs[0].head()

df01 = select_and_rename(df, vaaa_map_01)

df01.head()
metrics =  ["Radius-Auth-Response", "Probe-Radius-Auth-Response"]
hue_col = "memory"
x_col = "cpu_bw"

#dff = df01.loc[df01["memory"] == 1024]
#dff = dff.loc[dff["ruleset"] == "big"]
#dff = dff.loc[dff[x_col] >= .5]

for m in metrics:
    sns.catplot(x=x_col, y=m, hue=hue_col, data=df01, kind="strip", height=8, aspect=2, linewidth=1)
metrics =  ["Radius-Auth-Response", "Probe-Radius-Auth-Response"]
hue_col = "memory"
x_col = "cpu_bw"

#dff = df01.loc[df01["memory"] == 1024]
#dff = dff.loc[dff["ruleset"] == "big"]
#dff = dff.loc[dff[x_col] >= .5]

for m in metrics:
    sns.lmplot(x=x_col, y=m, hue=hue_col, data=df01)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15156462585034014, 'fraction_numerical': 0.03564625850340136, 'mean_word_length': 4.470238095238095, 'pattern_counts': {'":': 17, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '549997', 'license': 'OLDAP-2.4', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1530, 'n_words': 238, 'path': 'analysis/vaaa/vaaa-analysis.ipynb', 'repo_name': 'arif332/tng-bench-experiments', 'size': '3673'}