SilverDragon9 commited on
Commit
b336ffe
·
1 Parent(s): ff52d50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -17,15 +17,16 @@ numeric_features = [
17
  "door_state", "sphone_signal"
18
  ]
19
 
 
20
  class_labels = {
21
- 0: "normal",
22
- 1: "backdoor",
23
- 2: "ddos",
24
- 3: "injection",
25
- 4: "password",
26
- 5: "ransomware",
27
- 6: "scanning",
28
- 7: "xss",
29
  }
30
 
31
  def convert_datetime_features(log_data):
@@ -65,8 +66,8 @@ def detect_intrusion(file):
65
  except Exception as e:
66
  return f"Error during prediction: {str(e)}"
67
 
68
- # Only output whether it's an attack or normal
69
- log_data['Prediction'] = ['Attack' if class_labels.get(pred, 'Unknown') != "normal" else "Normal" for pred in predictions]
70
 
71
  # Format date for output
72
  log_data['date'] = log_data['date'].dt.strftime('%Y-%m-%d')
 
17
  "door_state", "sphone_signal"
18
  ]
19
 
20
+ # Class labels for attack types
21
  class_labels = {
22
+ 0: "Normal",
23
+ 1: "Backdoor",
24
+ 2: "DDoS",
25
+ 3: "Injection",
26
+ 4: "Password Attack",
27
+ 5: "Ransomware",
28
+ 6: "Scanning",
29
+ 7: "XSS",
30
  }
31
 
32
  def convert_datetime_features(log_data):
 
66
  except Exception as e:
67
  return f"Error during prediction: {str(e)}"
68
 
69
+ # Map predictions to specific attack types
70
+ log_data['Prediction'] = [class_labels.get(pred, 'Unknown Attack') for pred in predictions]
71
 
72
  # Format date for output
73
  log_data['date'] = log_data['date'].dt.strftime('%Y-%m-%d')