<jupyter_start><jupyter_text>Time samples analysisRead from file the samples:<jupyter_code>file="time_optimized_0_1000"
f = open(file+".txt")
l=[]
for line in f:
    l.append([w for w in line.replace("\t", " ").replace("\n", "").split(" ") if w != ''])
f.close()
# l[:3]
l[0][0]<jupyter_output><empty_output><jupyter_text>Convert the data to CSV (easier to pass them to pandas):<jupyter_code>ll = []
i=0
while i<len(l):
    if "__" in l[i][0]:
        print(l[i])
        i+=1
    else:
        v, p, e = l[i][0][:-4].split("_")
        ll.append([int(v), float(p), int(e), 
                       float(l[i+2][1][:-1]), float(l[i+3][1][:-1]), float(l[i+4][1][:-1]), float(l[i+5][1][:-1]),
                       int(l[i+6][1]), int(l[i+7][1])])
        i+=8
ll[1000]
import csv
f = open(file+".csv", "w")
f.write("vertices,percentage,edges,tarjan,nuutila,pearce,pearceNR,components,correct\n")
w = csv.writer(f)
w.writerows(ll)
f.close()<jupyter_output><empty_output><jupyter_text>Load samples with pandas:<jupyter_code>import pandas as pd
t = pd.read_csv(file+".csv")
print ("Number of samples : ",t.count())
print("Incorrect results : ", t.correct[t.correct==0].count())
t.describe()<jupyter_output><empty_output><jupyter_text>Remove outliers above the 99-th percentile for all the algorithms:<jupyter_code>for alg in ["tarjan","nuutila","pearce", "pearceNR"]:
    qt1=t[alg].quantile(0.99)
    print(alg, qt1)
    t = t[t[alg]<qt1]<jupyter_output>tarjan 7.099999999999999e-05
nuutila 5.1e-05
pearce 4.1e-05
pearceNR 0.00010002000000000044<jupyter_text>Average samples with same number of vertices and edges:<jupyter_code>t= t[["vertices","edges","tarjan","nuutila", "pearce", "pearceNR"]].groupby(by=["vertices","edges"], as_index=False).mean()
t["v+e"]=t["vertices"]+t["edges"]
t.describe()<jupyter_output><empty_output><jupyter_text>Plots In (V+E,t) space averaging 10 samples:<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
t = t.sort_values(by=["v+e","edges","vertices"])
t.groupby(np.arange(len(t))//10).mean().plot(x="v+e", y=["tarjan","nuutila","pearce", "pearceNR"],figsize=(20,20), subplots=True)<jupyter_output><empty_output><jupyter_text>In (V+E,t) space averaging 100 samples:<jupyter_code>t.groupby(np.arange(len(t))//10).max().groupby(np.arange(len(t)/10)//10).mean().plot(x="v+e", y=["tarjan","nuutila","pearce", "pearceNR"],figsize=(20,20), subplots=True)
t.groupby(np.arange(len(t))//10).max().groupby(np.arange(len(t)/10)//10).mean().plot(x="v+e", y=["tarjan","nuutila","pearce", "pearceNR"],figsize=(20,20), subplots=False)
import plotly.plotly as py
import plotly.graph_objs as go
import plotly

import pandas as pd
df = t
plotly.tools.set_credentials_file(username='pscorso93', api_key='<KEY>')<jupyter_output><empty_output><jupyter_text>Plots in (V,E,t) space: Tarjan:<jupyter_code>import plotly.plotly as py
import plotly
import plotly.graph_objs as go
from scipy.interpolate import griddata
x1 = np.linspace(t['vertices'].min(), t['vertices'].max(), len(t['vertices'].unique()))
y1 = np.linspace(t['edges'].min(), t['edges'].max(), len(t['edges'].unique()))

x2, y2 = np.meshgrid(x1, y1)
z2 = griddata((df['vertices'], df['edges']), df['tarjan'], (x2, y2), method='cubic')

data = [
    go.Surface(
        x=x2,
        y=y2,
        z=z2
    )
]

layout = go.Layout(
    title='Tarjan',
    autosize=False,
    width=1000,
    height=1000,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    )
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(data, filename='tarjan.html')
py.iplot(fig, filename='elevations-3d-surface')<jupyter_output><empty_output><jupyter_text>Nuutila:<jupyter_code>x1 = np.linspace(t['vertices'].min(), t['vertices'].max(), len(t['vertices'].unique()))
y1 = np.linspace(t['edges'].min(), t['edges'].max(), len(t['edges'].unique()))

x2, y2 = np.meshgrid(x1, y1)
z2 = griddata((df['vertices'], df['edges']), df['nuutila'], (x2, y2), method='cubic')

data = [
    go.Surface(
        x=x2,
        y=y2,
        z=z2
    )
]

layout = go.Layout(
    title='Nuutila',
    autosize=False,
    width=1000,
    height=1000,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    )
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(data, filename='nuutila.html')
py.iplot(fig, filename='elevations-3d-surface')<jupyter_output><empty_output><jupyter_text>Pearce:<jupyter_code>x1 = np.linspace(t['vertices'].min(), t['vertices'].max(), len(t['vertices'].unique()))
y1 = np.linspace(t['edges'].min(), t['edges'].max(), len(t['edges'].unique()))

x2, y2 = np.meshgrid(x1, y1)
z2 = griddata((df['vertices'], df['edges']), df['pearce'], (x2, y2), method='cubic')

data = [
    go.Surface(
        x=x2,
        y=y2,
        z=z2
    )
]

layout = go.Layout(
    title='Pearce',
    autosize=False,
    width=1000,
    height=1000,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    )
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(data, filename='pearce.html')

py.iplot(fig, filename='elevations-3d-surface')


x1 = np.linspace(t['vertices'].min(), t['vertices'].max(), len(t['vertices'].unique()))
y1 = np.linspace(t['edges'].min(), t['edges'].max(), len(t['edges'].unique()))

x2, y2 = np.meshgrid(x1, y1)
z2 = griddata((df['vertices'], df['edges']), df['pearceNR'], (x2, y2), method='cubic')

data = [
    go.Surface(
        x=x2,
        y=y2,
        z=z2
    )
]

layout = go.Layout(
    title='PearceNR',
    autosize=False,
    width=1000,
    height=1000,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    )
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(data, filename='pearceNR.html')

py.iplot(fig, filename='elevations-3d-surface')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21266039349871685, 'fraction_numerical': 0.04088964927288281, 'mean_word_length': 4.489201877934272, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '314232', 'license': 'MIT', 'n_tokens_mistral': 2526, 'n_tokens_neox': 2408, 'n_words': 361, 'path': 'time_analysis.ipynb', 'repo_name': 'phisco/advance_algorithms_project', 'size': '5860'}