pgurazada1 commited on
Commit
db46b2b
·
verified ·
1 Parent(s): 480e756

Converted numeric label to string

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -23,7 +23,7 @@ log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
23
  log_folder = log_file.parent
24
 
25
  scheduler = CommitScheduler(
26
- repo_id="machine-failure-logs",
27
  repo_type="dataset",
28
  folder_path=log_folder,
29
  path_in_repo="data",
@@ -42,7 +42,7 @@ type_input = gr.Dropdown(
42
  label='Type'
43
  )
44
 
45
- model_output = gr.Label(label="Machine failure")
46
 
47
  # Define the predict function that runs when 'Submit' is clicked or when a API request is made
48
  def predict_machine_failure(air_temperature, process_temperature, rotational_speed, torque, tool_wear, type):
@@ -55,7 +55,12 @@ def predict_machine_failure(air_temperature, process_temperature, rotational_spe
55
  'Type': type
56
  }
57
  data_point = pd.DataFrame([sample])
58
- prediction = machine_failure_predictor.predict(data_point).tolist()
 
 
 
 
 
59
 
60
  with scheduler.lock:
61
  with log_file.open("a") as f:
@@ -67,7 +72,7 @@ def predict_machine_failure(air_temperature, process_temperature, rotational_spe
67
  'Torque [Nm]': torque,
68
  'Tool wear [min]': tool_wear,
69
  'Type': type,
70
- 'prediction': prediction[0]
71
  }
72
  ))
73
  f.write("\n")
 
23
  log_folder = log_file.parent
24
 
25
  scheduler = CommitScheduler(
26
+ repo_id="machine-failure-mlops-logs",
27
  repo_type="dataset",
28
  folder_path=log_folder,
29
  path_in_repo="data",
 
42
  label='Type'
43
  )
44
 
45
+ model_output = gr.Label(label="Machine Failure Expected?")
46
 
47
  # Define the predict function that runs when 'Submit' is clicked or when a API request is made
48
  def predict_machine_failure(air_temperature, process_temperature, rotational_speed, torque, tool_wear, type):
 
55
  'Type': type
56
  }
57
  data_point = pd.DataFrame([sample])
58
+ prediction = machine_failure_predictor.predict(data_point).tolist()[0]
59
+
60
+ if prediction == 1:
61
+ prediction_label = 'yes'
62
+ else:
63
+ prediction_label = 'no'
64
 
65
  with scheduler.lock:
66
  with log_file.open("a") as f:
 
72
  'Torque [Nm]': torque,
73
  'Tool wear [min]': tool_wear,
74
  'Type': type,
75
+ 'prediction': prediction_label
76
  }
77
  ))
78
  f.write("\n")