Spaces:
Runtime error
Runtime error
Download src/predict.py from vyasmax9/predictive-maintenance: direct link, hf CLI and curl.
- Browser
- Download file 856 Bytes
-
https://huggingface.co/spaces/vyasmax9/predictive-maintenance/resolve/main/src/predict.py
- Command line
-
hf download hf://spaces/vyasmax9/predictive-maintenance/src/predict.py
-
curl -L -o predict.py https://huggingface.co/spaces/vyasmax9/predictive-maintenance/resolve/main/src/predict.py
856 Bytes
| import joblib | |
| import pandas as pd | |
| # ===================================== | |
| # Load Saved Model | |
| # ===================================== | |
| MODEL_PATH = "models/best_model.pkl" | |
| model = joblib.load( | |
| MODEL_PATH | |
| ) | |
| # ===================================== | |
| # Training Feature Order | |
| # ===================================== | |
| FEATURE_ORDER = [ | |
| "Engine_RPM", | |
| "Lub_Oil_Pressure", | |
| "Fuel_Pressure", | |
| "Coolant_Pressure", | |
| "Lub_Oil_Temperature", | |
| "Coolant_Temperature" | |
| ] | |
| # ===================================== | |
| # Prediction Function | |
| # ===================================== | |
| def predict_engine_condition(input_data): | |
| input_df = pd.DataFrame( | |
| [input_data] | |
| ) | |
| # Ensure same feature order | |
| input_df = input_df[ | |
| FEATURE_ORDER | |
| ] | |
| prediction = model.predict( | |
| input_df | |
| ) | |
| return prediction[0] |