Class: AiRootShield::AiBehavioralAnalyzer
- Inherits:
-
Object
- Object
- AiRootShield::AiBehavioralAnalyzer
- Defined in:
- lib/ai_root_shield/ai_behavioral_analyzer.rb
Overview
AI-powered behavioral analysis using ONNX models
Constant Summary collapse
- DEFAULT_MODEL_PATH =
File.join(__dir__, "..", "..", "models", "behavioral_model.onnx")
- FEATURE_INDICES =
Feature indices for the ML model
{ file_access_entropy: 0, sensor_consistency_score: 1, hardware_fingerprint_score: 2, process_behavior_score: 3, network_pattern_score: 4, timing_analysis_score: 5, system_call_entropy: 6, memory_access_pattern: 7 }.freeze
Instance Method Summary collapse
-
#analyze(device_data) ⇒ Hash
Perform AI behavioral analysis on device data.
-
#initialize(model_path: nil) ⇒ AiBehavioralAnalyzer
constructor
A new instance of AiBehavioralAnalyzer.
Constructor Details
#initialize(model_path: nil) ⇒ AiBehavioralAnalyzer
Returns a new instance of AiBehavioralAnalyzer.
23 24 25 26 27 28 |
# File 'lib/ai_root_shield/ai_behavioral_analyzer.rb', line 23 def initialize(model_path: nil) @model_path = model_path || DEFAULT_MODEL_PATH @model = nil @confidence_threshold = 0.7 load_model if File.exist?(@model_path) end |
Instance Method Details
#analyze(device_data) ⇒ Hash
Perform AI behavioral analysis on device data
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ai_root_shield/ai_behavioral_analyzer.rb', line 33 def analyze(device_data) return fallback_analysis(device_data) unless @model features = extract_behavioral_features(device_data) prediction = run_inference(features) { ai_confidence: prediction[:confidence], behavioral_risk_score: prediction[:risk_score], behavioral_factors: prediction[:factors], anomaly_indicators: detect_anomalies(device_data, features), ml_emulator_score: calculate_ml_emulator_score(features) } end |