How to convert data into images without data loss

Viewed 181

I have seen alot of papers where they convert network data into images, i am trying to do the same i got the 87 apps network data from kaggle. The data has three columns 'Source.IP', 'Destination.IP' and 'Payload' it looks like this

enter image description here

and when I convert this into an image (heatmap) it looks like this enter image description here

On x-axis is source.ips and on y-axis is dest ip, i want to learn CNN for pay-load based traffic matrix classification. I tried generating heatmaps, since i am using pandas and matplotlib/seaborn to generate the graph i had to pivot the table because of repeated source/destination ips.

g1 = true_ele.groupby(["Destination.IP","Source.IP"], as_index=False)['Payload'].mean()
table = g1.pivot(index='Destination.IP',columns='Source.IP',values='Payload')

and to remove duplicate i decided to groupby the source/dest ips by payload which is not nice since i am loosing the data.

what i want to ask, is there a better way to generate images based on the data above so that i wont loose data and will be able to generate meanigfull images to learn CNN.

1 Answers

I think the Sankey Diagram is a good way to do this as a quantitative visualization between A-B. But I'm not sure if this will lead to deep learning. The data in the graph consists of a unique label between A-B and the source and target is an index of labels.

import plotly.graph_objects as go

fig = go.Figure(data=[go.Sankey(
    node = dict(
      pad = 15,
      thickness = 20,
      line = dict(color = "black", width = 0.5),
      label = (['172.19.1.46-s','10.200.7.7-d','10.200.7.7-s','172.19.1.46-d','50.31.185,39-s','10,200.7.217-d',
                '50.31.185,39-s','10.200.7.217-d','192.168.72.43-s','10.200.7.6-s','172.19.1.56-d','192.168.72.47-s',
                '10.200.7.6-d','68.67.178.197-s','10.200.7.4-s','192.168.180.51-d']),
      color = "blue"
    ),
    link = dict(
      source = [0,2,4,4,8,9,8,11,13,9,14.14,14], 
      target = [1,3,5,5,1,10,1,12,5,1,15,15,15],
      value = [22,2,3,1,5,136,5,3,10,7,32,5,3]
  ))])

fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()

enter image description here

Related