Question

Python

Task description: Cyber security attacks can be grouped into 4 categories: DOS attack, PROBE attack, R21 attack, and U2R atta

● DOS R21 PROBE 0 500 1000 1500 2000 2500 Attack number detected

Task description: Cyber security attacks can be grouped into 4 categories: DOS attack, PROBE attack, R21 attack, and U2R attack. There are 11 different kinds of attacks in DOS, 7 kinds of attacks in PROBE, 15 kinds of attacks in R21, and 8 kinds of attacks in U2R. You are given the statistical attack data saved in file 'attack-type-frequency.csv' Attack type apache2 back category number of attack dos dos dos dos u2r 124 432 43 96 482 2625 954 679 Frequency % 0.52 1.8 0.18 0.4 2.01 10.93 3.97 2.83 udpstorm buffer overflow u2r erl rootkit u2r u2r (The above data is for demonstration purposes only. Please download the full version of attack type-frequency.csv.) You are asked to read the file data and visualize the data using matplotlib's scatter plot with the following settings figsize (10,5), dpi-100 scatter size is changed based on the value of "number of attack" . X axis is number of attack data with label: Attack number detected . Y axis is frequency data with label: Attack frequency Scatter displays all the 4 attack categories in one plot: "yellow" for DOS; "green" for U2R; "blue" for R21; and "red" for PROBE. . legend(markerscale-0.3) or any value you think proper Sample output as shown in the following figure is for demonstration purposes only.
● DOS R21 PROBE 0 500 1000 1500 2000 2500 Attack number detected
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello there, please make sure you have pandas, matplotlib and sklearn installed on your system.

----------------------------------------------------------------------------------------------------------------

import pandas as pd
import matplotlib.pyplot as plt

from sklearn.preprocessing import normalize


def freq_scatter_plot(filename):
   df = pd.read_csv(filename)
   columns = list(df.columns)
   ### x, y
   x = list(range(len(df.index)))
   y = df[columns[-1]].values

   ## size
   marker_size = df[columns[2]].values

   ## color
   colors = {'dos':'y', 'u2r':'g', 'r21':'b', 'probe':'r'}
   attack_type = list(df[columns[1]].values)

   ## set plot
   fig = plt.figure(figsize=(10, 5), dpi=100)
   ax = fig.add_subplot(1, 1, 1)
   for i in range(len(df.index)):
       ax.scatter(x[i], y[i], s=marker_size[i], c=colors[attack_type[i]])

   ax.set_xlabel('Attack number detected')
   ax.set_ylabel('Attack frequency')
   plt.legend(markerscale=0.3)
   plt.show()

---------------------------------------------------------------

If you have any doubts please use comment section!

Add a comment
Know the answer?
Add Answer to:
Task description: Cyber security attacks can be grouped into 4 categories: DOS attack, PROBE atta...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT