AceVen57 commited on
Commit
c67d4ff
1 Parent(s): 3237b39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -27
app.py CHANGED
@@ -1,5 +1,3 @@
1
- # Import the libraries
2
-
3
  import os
4
  import uuid
5
  import joblib
@@ -17,22 +15,22 @@ from pathlib import Path
17
 
18
  os.system("python train.py")
19
 
20
- # Load the freshly trained model from disk
21
 
22
  insurance_charge_predictor = joblib.load('model.joblib')
23
 
24
- # Prepare the logging functionality
25
 
26
- log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
27
- log_folder = log_file.parent
28
 
29
- scheduler = CommitScheduler(
30
- repo_id="insurance-charge-logs",
31
- repo_type="dataset",
32
- folder_path=log_folder,
33
- path_in_repo="data",
34
- every=2
35
- )
36
 
37
  # Define the predict function that runs when 'Submit' is clicked or when a API request is made
38
  def predict_insurance_charge(age, bmi, children,sex, smoker, region):
@@ -52,20 +50,20 @@ def predict_insurance_charge(age, bmi, children,sex, smoker, region):
52
  # While writing to the log file, ensure that the commit scheduler is locked to avoid parallel
53
  # access
54
 
55
- with scheduler.lock:
56
- with log_file.open("a") as f:
57
- f.write(json.dumps(
58
- {
59
- 'age': age,
60
- 'bmi': bmi,
61
- 'children': children,
62
- 'sex': sex,
63
- 'smoker': smoker,
64
- 'region': region,
65
- 'prediction': prediction[0]
66
- }
67
- ))
68
- f.write("\n")
69
 
70
  return round(prediction[0],2)
71
 
 
 
 
1
  import os
2
  import uuid
3
  import joblib
 
15
 
16
  os.system("python train.py")
17
 
18
+ # # Load the freshly trained model from disk
19
 
20
  insurance_charge_predictor = joblib.load('model.joblib')
21
 
22
+ # # Prepare the logging functionality
23
 
24
+ # log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
25
+ # log_folder = log_file.parent
26
 
27
+ # scheduler = CommitScheduler(
28
+ # repo_id="insurance-charge-logs",
29
+ # repo_type="dataset",
30
+ # folder_path=log_folder,
31
+ # path_in_repo="data",
32
+ # every=2
33
+ # )
34
 
35
  # Define the predict function that runs when 'Submit' is clicked or when a API request is made
36
  def predict_insurance_charge(age, bmi, children,sex, smoker, region):
 
50
  # While writing to the log file, ensure that the commit scheduler is locked to avoid parallel
51
  # access
52
 
53
+ # with scheduler.lock:
54
+ # with log_file.open("a") as f:
55
+ # f.write(json.dumps(
56
+ # {
57
+ # 'age': age,
58
+ # 'bmi': bmi,
59
+ # 'children': children,
60
+ # 'sex': sex,
61
+ # 'smoker': smoker,
62
+ # 'region': region,
63
+ # 'prediction': prediction[0]
64
+ # }
65
+ # ))
66
+ # f.write("\n")
67
 
68
  return round(prediction[0],2)
69