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/a169e77e4e1c4724b019a20cfa2d36f39e4a92d3/src/security/anomalyEngine.js
- Command line
-
hf download hf://spaces/TwanAPI/trsstapi@a169e77e4e1c4724b019a20cfa2d36f39e4a92d3/src/security/anomalyEngine.js
-
curl -L -o anomalyEngine.js https://huggingface.co/spaces/TwanAPI/trsstapi/resolve/a169e77e4e1c4724b019a20cfa2d36f39e4a92d3/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; | |
| } | |