Spaces:
Sleeping
Sleeping
Download networksecurity/utils/ml_utils/model/estimator.py from Divb30/network-intrusion-detection: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/Divb30/network-intrusion-detection/resolve/main/networksecurity/utils/ml_utils/model/estimator.py
- Command line
-
hf download hf://spaces/Divb30/network-intrusion-detection/networksecurity/utils/ml_utils/model/estimator.py
-
curl -L -o estimator.py https://huggingface.co/spaces/Divb30/network-intrusion-detection/resolve/main/networksecurity/utils/ml_utils/model/estimator.py
725 Bytes
| from networksecurity.constant.training_pipeline import SAVED_MODEL_DIR,MODEL_FILE_NAME | |
| import os | |
| import sys | |
| from networksecurity.exception.exception import NetworkSecurityException | |
| from networksecurity.logging.logger import logging | |
| class NetworkModel: | |
| def __init__(self,preprocessor,model): | |
| try: | |
| self.preprocessor = preprocessor | |
| self.model = model | |
| except Exception as e: | |
| raise NetworkSecurityException(e,sys) | |
| def predict(self,x): | |
| try: | |
| x_transform = self.preprocessor.transform(x) | |
| y_hat = self.model.predict(x_transform) | |
| return y_hat | |
| except Exception as e: | |
| raise NetworkSecurityException(e,sys) |