From d52238e55d0499ceff3c9c3ca50a0437564bf10d Mon Sep 17 00:00:00 2001 From: Fernando Guadalupe Mendez Espinoza <189765318+Afeter8@users.noreply.github.com> Date: Thu, 2 Oct 2025 07:17:46 -0600 Subject: [PATCH] =?UTF-8?q?Create=20Anomal=C3=ADa.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Anomal\303\255a.html" | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "Anomal\303\255a.html" diff --git "a/Anomal\303\255a.html" "b/Anomal\303\255a.html" new file mode 100644 index 0000000..75d1c38 --- /dev/null +++ "b/Anomal\303\255a.html" @@ -0,0 +1,27 @@ +# fgme_ai_security.py +import json +import numpy as np +from sklearn.ensemble import IsolationForest +import joblib + +class FGME_AI_Security: + def __init__(self, model_path="fgme_ai_model.pkl"): + try: + self.model = joblib.load(model_path) + except: + self.model = IsolationForest(n_estimators=100, contamination=0.05) + self.model.fit(np.random.rand(100, 5)) # Entrenamiento inicial con datos simulados + joblib.dump(self.model, model_path) + + def analizar_evento(self, evento: dict): + vector = np.array([[evento["cpu"], evento["mem"], evento["net"], evento["disk"], evento["proc"]]]) + score = self.model.decision_function(vector)[0] + riesgo = self.model.predict(vector)[0] # -1 = sospechoso + return {"riesgo": "ALTO" if riesgo == -1 else "BAJO", "score": score} + +# Ejemplo de uso +if __name__ == "__main__": + ai = FGME_AI_Security() + evento = {"cpu": 0.9, "mem": 0.8, "net": 0.95, "disk": 0.7, "proc": 0.85} + resultado = ai.analizar_evento(evento) + print(json.dumps(resultado, indent=2))