AtthalaricNero commited on
Commit ·
cea3342
1
Parent(s): 496e850
feat(model): add anomaly detection models and scalers
Browse files- model.py +28 -0
- model/model_binary_smote.pkl +3 -0
- model/model_multi.pkl +3 -0
- model/scaler_anomaly.pkl +3 -0
model.py
CHANGED
|
@@ -6,9 +6,19 @@ from keras.models import load_model
|
|
| 6 |
|
| 7 |
class Model:
|
| 8 |
def __init__(self) -> None:
|
|
|
|
| 9 |
self.__model_lstm = os.path.join("model", "model_lstm_regression_cyclical.h5")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
self.__scaler_y = os.path.join("model", "scaler_y.pkl")
|
| 11 |
self.__scaler_X = os.path.join("model", "scaler_X.pkl")
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
self._load_model_and_scalers()
|
| 14 |
|
|
@@ -19,6 +29,24 @@ class Model:
|
|
| 19 |
print("LSTM model loaded successfully")
|
| 20 |
else:
|
| 21 |
print(f"⚠ Model not found at {self.__model_lstm}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
if os.path.exists(self.__scaler_X):
|
| 24 |
self.scaler_x = joblib.load(self.__scaler_X)
|
|
|
|
| 6 |
|
| 7 |
class Model:
|
| 8 |
def __init__(self) -> None:
|
| 9 |
+
# Time-Series
|
| 10 |
self.__model_lstm = os.path.join("model", "model_lstm_regression_cyclical.h5")
|
| 11 |
+
|
| 12 |
+
# Anomaly Detection
|
| 13 |
+
self.__model_binary = os.path.join("model", "model_binary_smote.pkl")
|
| 14 |
+
self.__model_multiclass = os.path.join("model", "model_multi.pkl")
|
| 15 |
+
|
| 16 |
+
# Scaler Time-Series
|
| 17 |
self.__scaler_y = os.path.join("model", "scaler_y.pkl")
|
| 18 |
self.__scaler_X = os.path.join("model", "scaler_X.pkl")
|
| 19 |
+
|
| 20 |
+
# Scaler Anomaly
|
| 21 |
+
self.__preprocessor_anomaly = os.path.join("model", "scaler_anomaly.pkl")
|
| 22 |
|
| 23 |
self._load_model_and_scalers()
|
| 24 |
|
|
|
|
| 29 |
print("LSTM model loaded successfully")
|
| 30 |
else:
|
| 31 |
print(f"⚠ Model not found at {self.__model_lstm}")
|
| 32 |
+
|
| 33 |
+
if os.path.exists(self.__model_binary):
|
| 34 |
+
self.model_binary = joblib.load(self.__model_binary)
|
| 35 |
+
print("Binary model loaded successfully")
|
| 36 |
+
else:
|
| 37 |
+
print(f"⚠ Model not found at {self.__model_binary}")
|
| 38 |
+
|
| 39 |
+
if os.path.exists(self.__model_multiclass):
|
| 40 |
+
self.model_multiclass = joblib.load(self.__model_multiclass)
|
| 41 |
+
print("Multiclass model loaded successfully")
|
| 42 |
+
else:
|
| 43 |
+
print(f"⚠ Model not found at {self.__model_multiclass}")
|
| 44 |
+
|
| 45 |
+
if os.path.exists(self.__preprocessor_anomaly):
|
| 46 |
+
self.preprocessor_anomaly = joblib.load(self.__preprocessor_anomaly)
|
| 47 |
+
print("Scaler anomaly model loaded successfully")
|
| 48 |
+
else:
|
| 49 |
+
print(f"⚠ preprocessor_anomaly not found at {self.__preprocessor_anomaly}")
|
| 50 |
|
| 51 |
if os.path.exists(self.__scaler_X):
|
| 52 |
self.scaler_x = joblib.load(self.__scaler_X)
|
model/model_binary_smote.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:818fa48a3660f066e6e40b74d77c47096d74c288dfc421de228d96590f6e42d4
|
| 3 |
+
size 263896
|
model/model_multi.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:736b7836fbbcca843368a6f893bf004deffdbcf77a0490e5b3d78b5ffa7f371f
|
| 3 |
+
size 442688
|
model/scaler_anomaly.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e26cad52db9751443f07d64d300c069afe040b4ca7f4a84d22989be7c2e0e52
|
| 3 |
+
size 1071
|