MaheshP98 commited on
Commit
77d8c48
·
verified ·
1 Parent(s): 8504229

Delete models​​​/anomaly.py

Browse files
Files changed (1) hide show
  1. models​​​/anomaly.py +0 -25
models​​​/anomaly.py DELETED
@@ -1,25 +0,0 @@
1
- import pandas as pd
2
- from transformers import pipeline
3
- import logging
4
-
5
- logger = logging.getLogger(__name__)
6
-
7
- def detect_anomalies(df):
8
- """Detect anomalies in log data using a Hugging Face model."""
9
- logger.info("Detecting anomalies...")
10
- try:
11
- detector = pipeline(
12
- "text-classification",
13
- model="prajjwal1/bert-tiny",
14
- tokenizer="prajjwal1/bert-tiny",
15
- clean_up_tokenization_spaces=True
16
- )
17
- df["text"] = df["status"] + " Usage:" + df["usage_count"].astype(str)
18
- results = detector(df["text"].tolist())
19
- df["anomaly"] = [r["label"] for r in results]
20
- anomalies = df[df["anomaly"] == "POSITIVE"]
21
- logger.info(f"Detected {len(anomalies)} anomalies.")
22
- return anomalies
23
- except Exception as e:
24
- logger.error(f"Failed to detect anomalies: {e}")
25
- raise