Machine learning analysis of network traffic

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Machine learning analysis of network traffic

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Machine learning analysis can detect traffic patterns that don't match fixed, predefined rules.
A False
B True
2. A machine learning model must be trained before it can classify network traffic accurately.
A False
B True
3. Which classifies traffic in ML-based analysis: a trained model, or a fixed list of rules?
A A trained model
B A fixed list of rules
4. ML-based analysis can only flag threats identical to ones it has seen before.
A False
B True
5. Which needs prior training on data: a machine learning model, or a fixed rule-based system?
A A machine learning model
B A fixed rule-based system

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1pred = classify(model, traffic) ALoading a previously trained model for use
2model = load_model() Bif pred == "anomaly": alert()
3ML models learn patterns from training data rather than fixed rules Cmodel = train_model(data)
4Classifying traffic flags it as normal or anomalous based on learned patterns DThe mistake: swapping the argument order for classify()
5pred = "normal" EThe mistake: hardcoding the prediction instead of using the model
6pred = classify(t, model) FClassifying traffic using a trained model

Definitions

Machine learning traffic analysis

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
_____ = load_model()
2.
traffic = ___________()
3.
prediction = ________(model, traffic)
4.
if prediction __ "anomaly":
5.
def ______________(model, traffic):

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A model = None
B t = get_traffic()
C pred = classify(model, t)
Question 2
A skip_model = True
B model = load_model()
C pred = classify(model, t)
Question 3
A model = load_model()
B t = None
C pred = classify(model, t)
Question 4
A model = load_model()
B use_fixed_rules = True
C t = get_traffic()
Question 5
A model = load_model()
B t = get_traffic()
C pred = "normal"

Answer Key

Machine learning analysis of network traffic
Section A: Quick Questions
Q1
B — True
Q2
B — True
Q3
A — A trained model
Q4
A — False
Q5
A — A machine learning model
Section B: Match the Pairs
Q1
pred = classify(model, traffic) → Classifying traffic using a trained model
Q2
model = load_model() → Loading a previously trained model for use
Q3
ML models learn patterns from training data rather than fixed rules → model = train_model(data)
Q4
Classifying traffic flags it as normal or anomalous based on learned patterns → if pred == "anomaly": alert()
Q5
pred = "normal" → The mistake: hardcoding the prediction instead of using the model
Q6
pred = classify(t, model) → The mistake: swapping the argument order for classify()
Section C: Definitions
Q1
Machine learning traffic analysis — Using a trained model to classify network traffic as normal or anomalous, based on learned patterns rather than fixed rules.
Section D: Fill in the Blanks
Q1
model = load_model()
Q2
traffic = get_traffic()
Q3
prediction = classify(model, traffic)
Q4
if prediction == "anomaly":
Q5
def classify_batch(model, traffic):
Section E: Spot the Error
Q1
A — Line 1 sets model to None instead of a trained model, so there's nothing for classify() to use.
Q2
A — Line 1 sets a flag to skip loading the model, but classify() still needs a trained model to run.
Q3
B — Line 2 sets t to None instead of real traffic data, so there's nothing for the model to classify.
Q4
B — Line 2 switches to fixed rules instead of the trained model, defeating the point of ML-based analysis.
Q5
C — Line 3 hardcodes the prediction as normal instead of calling classify() to analyse the traffic.