DSatishchandra commited on
Commit
71ea7dd
·
verified ·
1 Parent(s): a1eb974

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
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 pre-trained models for Anomaly Detection and Failure Prediction
12
- # Using a public Hugging Face model as an example for anomaly detection
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 (pre-trained model)
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']) # Assuming the Hugging Face model outputs label as result
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