Srastog commited on
Commit
1a8c89e
·
verified ·
1 Parent(s): 589298f

Update app/inference.py

Browse files
Files changed (1) hide show
  1. app/inference.py +2 -13
app/inference.py CHANGED
@@ -2,22 +2,11 @@ import os
2
  import joblib
3
  import numpy as np
4
 
5
- def predict(array):
6
  label_value_mapping={"No_Machine_Failure":"No",
7
  "Machine_Failure":"Yes"}
8
- cwd=os.getcwd()
9
-
10
- transform_pth=os.path.join(cwd,"app","transform.pkl")
11
- transform=joblib.load(transform_pth)
12
-
13
- encoder_pth=os.path.join(cwd,"app","encoder.pkl")
14
- encoder=joblib.load(encoder_pth)
15
-
16
  scaled_array=transform.transform(array)
17
-
18
- model_pth=os.path.join(cwd,"app","model.pkl")
19
- trained_model=joblib.load(model_pth)
20
-
21
  idx=trained_model.predict(scaled_array)[0].item()
22
  label=encoder.inverse_transform([idx]).item()
23
  confidence=np.max(trained_model.predict_proba(scaled_array)).item()
 
2
  import joblib
3
  import numpy as np
4
 
5
+ def predict(trained_model,encoder,transform,array):
6
  label_value_mapping={"No_Machine_Failure":"No",
7
  "Machine_Failure":"Yes"}
8
+
 
 
 
 
 
 
 
9
  scaled_array=transform.transform(array)
 
 
 
 
10
  idx=trained_model.predict(scaled_array)[0].item()
11
  label=encoder.inverse_transform([idx]).item()
12
  confidence=np.max(trained_model.predict_proba(scaled_array)).item()