| import numpy as np |
| from sklearn.ensemble import IsolationForest |
| import joblib |
| import gradio as gr |
|
|
| |
| |
| |
| class ZewpolAI_EXC1_Core: |
| def __init__(self, contamination=0.04): |
| """ |
| Instantiates the raw mathematical brain for ZewpolAI EXC1. |
| Features tracked: [Vector_0: Request Speed (req/s), Vector_1: Payload Weight (KB)] |
| """ |
| self.model = IsolationForest( |
| contamination=contamination, |
| random_state=42, |
| n_estimators=100 |
| ) |
| self.is_trained = False |
|
|
| def compile_and_train(self): |
| """Generates the multi-variable cluster array and trains the brain.""" |
| |
| np.random.seed(42) |
| normal_speeds = np.random.normal(loc=2.0, scale=0.8, size=(1000, 1)) |
| normal_payloads = np.random.normal(loc=150.0, scale=45.0, size=(1000, 1)) |
| training_matrix = np.hstack((normal_speeds, normal_payloads)) |
| |
| |
| self.model.fit(training_matrix) |
| self.is_trained = True |
| |
| |
| joblib.dump(self.model, "zewpol_exc1.pkl") |
| return "[SUCCESS] ZewpolAI EXC1 Brain compiled. Boundaries mapped successfully." |
|
|
| def evaluate_telemetry(self, speed, payload): |
| """Runs inference to decide if inbound vectors are a Pass or a Block.""" |
| if not self.is_trained: |
| return "UNTRAINED_ENGINE", "Model must be compiled first." |
| |
| |
| test_vector = np.array([[float(speed), float(payload)]]) |
| |
| |
| prediction = self.model.predict(test_vector) |
| |
| if prediction == 1: |
| return "🟢 ALLOW_PASS", "Telemetry matches secure historical baseline clusters." |
| else: |
| return "🚨 BLOCK_DROP", "Statistical anomaly detected! High-velocity or abnormal data exfiltration risk." |
|
|
| |
| |
| |
| |
| zewpol_brain = ZewpolAI_EXC1_Core() |
| startup_log = zewpol_brain.compile_and_train() |
|
|
| |
| |
| |
| |
| def raw_model_inference_pipeline(req_speed, file_size_kb): |
| decision, logs = zewpol_brain.evaluate_telemetry(req_speed, file_size_kb) |
| return { |
| "Model Compilation Status": startup_log, |
| "Firewall Action": decision, |
| "Engine Diagnostics": logs |
| } |
|
|
| |
| demo = gr.Interface( |
| fn=raw_model_inference_pipeline, |
| inputs=[ |
| gr.Number(value=2.5, label="Input Parameter A: Speed (Requests per second)"), |
| gr.Number(value=120.0, label="Input Parameter B: Payload Size (KB)") |
| ], |
| outputs=gr.JSON(label="ZewpolAI EXC1 Real-Time JSON Output Matrix"), |
| title="🛡️ ZewpolAI EXC1 Core Model Pipeline", |
| description="The raw machine learning engine for ZewpolAI EXC1. Enter web metrics to see the model classify traffic vectors in real-time." |
| ) |
|
|
| if __name__ == "__main__": |
| demo.launch() |
|
|