Skip to content
Snippets Groups Projects
Commit fdf447cb authored by Maël Madon's avatar Maël Madon
Browse files

adding an notebook for example distances

parent 5e6bb738
No related branches found
No related tags found
No related merge requests found
......@@ -57,13 +57,13 @@ def euclidean_distance(s1, s2):
"""Returns the Euclidean distance between two series s1 and s2"""
dist = np.sqrt(np.sum([(x-y) * (x-y) for x, y in zip(s1, s2)]))
return dist
return float(dist)
def lateness_distance(s1, s2):
"""Returns the 'lateness' of s2 compared to s1"""
return np.sum([y-x for x, y in zip(s1, s2)])
return float(np.sum([y-x for x, y in zip(s1, s2)]))
def normalized_euclidian_distance(s1, s2):
"""Return the euclidien distance normalized by the l2 norm of the vectors,
......@@ -73,12 +73,12 @@ def normalized_euclidian_distance(s1, s2):
if n1==0 or n2==0:
return None
eucl_dist = euclidean_distance(s1, s2)
return eucl_dist**2 / (n1 * n2)
return float( eucl_dist**2 / (n1 * n2) )
def l2_norm(s):
"""Return the l2 norm of the series s"""
return np.sqrt(np.sum([x * x for x in s]))
return float( np.sqrt(np.sum([x * x for x in s])) )
def distances(file1, file2, euclidean=True, lateness=False, norm_eucl=False,
......@@ -111,7 +111,7 @@ def distances(file1, file2, euclidean=True, lateness=False, norm_eucl=False,
def pretty_print(dist):
"""Nice printing of the dictionnary dist"""
if type(dist) is dict:
if isinstance(dist, dict):
pretty = json.dumps(dist, indent=4)
print(pretty)
else:
......
job_id,workload_name,profile,submission_time,requested_number_of_resources,requested_time,success,final_state,starting_time,execution_time,finish_time,waiting_time,turnaround_time,stretch,allocated_resources,consumed_energy,metadata
1216,user11,362,30,1,86400.000000,1,COMPLETED_SUCCESSFULLY,30,362.000000,80,0.000000,362.000000,1.000000,2,62671.250000,
247,user5,57102,0,8,432000.000000,1,COMPLETED_SUCCESSFULLY,0,57102.000000,0,0.000000,57102.000000,1.000000,0,12391134.000000,
1242,user11,9620,40,1,86400.000000,1,COMPLETED_SUCCESSFULLY,40,9620.000000,60,0.000000,9620.000000,1.000000,2,1665462.500000,
\ No newline at end of file
1216,user11,362,30,1,86400.000000,1,COMPLETED_SUCCESSFULLY,30,50,80,0.000000,362.000000,1.000000,2,62671.250000,
247,user5,57102,0,8,432000.000000,1,COMPLETED_SUCCESSFULLY,0,0,0,0.000000,57102.000000,1.000000,0,12391134.000000,
1242,user11,9620,40,1,86400.000000,1,COMPLETED_SUCCESSFULLY,40,20,60,0.000000,9620.000000,1.000000,1,1665462.500000,
\ No newline at end of file
job_id,workload_name,profile,submission_time,requested_number_of_resources,requested_time,success,final_state,starting_time,execution_time,finish_time,waiting_time,turnaround_time,stretch,allocated_resources,consumed_energy,metadata
1216:s1,user11,362,30,1,86400.000000,1,COMPLETED_SUCCESSFULLY,30,362.000000,60,0.000000,362.000000,1.000000,2,62671.250000,
247:s1,user5,57102,0,8,432000.000000,1,COMPLETED_SUCCESSFULLY,0,57102.000000,0,0.000000,57102.000000,1.000000,0,12391134.000000,
1242:s1,user11,9620,40,1,86400.000000,1,COMPLETED_SUCCESSFULLY,40,9620.000000,80,0.000000,9620.000000,1.000000,2,1665462.500000,
\ No newline at end of file
1216:s1,user11,362,30,1,86400.000000,1,COMPLETED_SUCCESSFULLY,30,30,60,0.000000,362.000000,1.000000,2,62671.250000,
247:s1,user5,57102,0,8,432000.000000,1,COMPLETED_SUCCESSFULLY,0,0,0,0.000000,57102.000000,1.000000,0,12391134.000000,
1242:s1,user11,9620,40,1,86400.000000,1,COMPLETED_SUCCESSFULLY,40,40,80,0.000000,9620.000000,1.000000,1,1665462.500000,
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment