Spaces:
Runtime error
Runtime error
Upload the application files
Browse files- app.py +32 -0
- localoutlierfactor.joblib +3 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import dependencies
|
2 |
+
import gradio as gr
|
3 |
+
import numpy as np
|
4 |
+
import joblib
|
5 |
+
|
6 |
+
|
7 |
+
# Predict function
|
8 |
+
def predict(region1, region2, region3, region4, region5, region6):
|
9 |
+
model = joblib.load("./localoutlierfactor.joblib")
|
10 |
+
yhat = model.predict(
|
11 |
+
np.array([[region1, region2, region3, region4, region5, region6]])
|
12 |
+
)
|
13 |
+
return "Weird Traffic" if yhat == -1 else "Normal Traffic"
|
14 |
+
|
15 |
+
|
16 |
+
# Building the Interface
|
17 |
+
app = gr.Interface(
|
18 |
+
title="Traffic Anomaly Detection 🚦",
|
19 |
+
fn=predict,
|
20 |
+
inputs=[
|
21 |
+
gr.Slider(0, 800),
|
22 |
+
gr.Slider(0, 800),
|
23 |
+
gr.Slider(0, 800),
|
24 |
+
gr.Slider(0, 800),
|
25 |
+
gr.Slider(0, 800),
|
26 |
+
gr.Slider(0, 800),
|
27 |
+
],
|
28 |
+
outputs="text",
|
29 |
+
)
|
30 |
+
|
31 |
+
# Launch the app
|
32 |
+
app.launch()
|
localoutlierfactor.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff92a7baf0ba16bafe7db971e0df95aec89b4bf34ba4cf1f3cc1dc02439b16d0
|
3 |
+
size 107521
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
scikit-learn==1.3.2
|