Download src/security/anomalyEngine.js from TwanAPI/trsstapi: direct link, hf CLI and curl.
- Browser
- Download file 288 Bytes
-
https://huggingface.co/spaces/TwanAPI/trsstapi/resolve/de2e0fefcfcbbc7b9f08d2b8c25aeab664668cd4/src/security/anomalyEngine.js
- Command line
-
hf download hf://spaces/TwanAPI/trsstapi@de2e0fefcfcbbc7b9f08d2b8c25aeab664668cd4/src/security/anomalyEngine.js
-
curl -L -o anomalyEngine.js https://huggingface.co/spaces/TwanAPI/trsstapi/resolve/de2e0fefcfcbbc7b9f08d2b8c25aeab664668cd4/src/security/anomalyEngine.js
288 Bytes
| import IsolationForest from "ml-isolation-forest"; | |
| let model = null; | |
| export function trainModel(data) { | |
| model = new IsolationForest({ contamination: 0.02 }); | |
| model.fit(data); | |
| } | |
| export function isAnomaly(vec) { | |
| if (!model) return false; | |
| return model.predict([vec])[0] === -1; | |
| } | |