File size: 512 Bytes
9248464 1a8c89e 9248464 1a8c89e 9248464 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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}
|