import os | |
import joblib | |
import numpy as np | |
def predict(trained_model,encoder,transform,array): | |
label_value_mapping={"No_Machine_Failure":"No", | |
"Machine_Failure":"Yes"} | |
scaled_array=transform.transform(array) | |
idx=trained_model.predict(scaled_array)[0].item() | |
label=encoder.inverse_transform([idx]).item() | |
confidence=np.max(trained_model.predict_proba(scaled_array)).item() | |
return {"Downtime":label_value_mapping[label], | |
"Confidence":confidence} | |