Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,11 @@ import numpy as np
|
|
6 |
from transformers import pipeline
|
7 |
from sklearn.ensemble import RandomForestClassifier
|
8 |
import joblib
|
9 |
-
import torch # Import PyTorch for using the Hugging Face model
|
10 |
|
11 |
-
# Load
|
12 |
-
|
13 |
-
# Replace 'distilbert-base-uncased' with your model path
|
14 |
-
anomaly_detection = pipeline("text-classification", model="distilbert-base-uncased")
|
15 |
|
16 |
-
# Load the Random Forest model for failure prediction
|
17 |
failure_prediction_model = joblib.load('failure_prediction_model.pkl')
|
18 |
|
19 |
# Function to preprocess logs for anomaly detection
|
@@ -28,7 +25,7 @@ def detect_anomaly(logs):
|
|
28 |
results = []
|
29 |
for log in preprocessed_logs['log_message']:
|
30 |
anomaly_result = anomaly_detection(log)
|
31 |
-
results.append(anomaly_result[0]['label'])
|
32 |
return results
|
33 |
|
34 |
# Function to predict failures based on historical data and metrics
|
|
|
6 |
from transformers import pipeline
|
7 |
from sklearn.ensemble import RandomForestClassifier
|
8 |
import joblib
|
|
|
9 |
|
10 |
+
# Load fine-tuned Hugging Face model for anomaly detection
|
11 |
+
anomaly_detection = pipeline("text-classification", model="./fine_tuned_anomaly_model")
|
|
|
|
|
12 |
|
13 |
+
# Load the Random Forest model for failure prediction
|
14 |
failure_prediction_model = joblib.load('failure_prediction_model.pkl')
|
15 |
|
16 |
# Function to preprocess logs for anomaly detection
|
|
|
25 |
results = []
|
26 |
for log in preprocessed_logs['log_message']:
|
27 |
anomaly_result = anomaly_detection(log)
|
28 |
+
results.append(anomaly_result[0]['label'])
|
29 |
return results
|
30 |
|
31 |
# Function to predict failures based on historical data and metrics
|