jedick commited on
Commit
103ea6f
·
1 Parent(s): a4966c6

Use train/test split for feedback

Browse files
Files changed (2) hide show
  1. app_functions.py +2 -1
  2. feedback.py +4 -1
app_functions.py CHANGED
@@ -325,7 +325,8 @@ def find_interesting_example(number_behind: int, units_behind: str):
325
  if confidence_score and confidence_score != "High":
326
  # Found an interesting example
327
  gr.Success(
328
- f"Interesting example (page {attempt + 1}) - ready for your feedback", duration=None
 
329
  )
330
  return (
331
  page_title,
 
325
  if confidence_score and confidence_score != "High":
326
  # Found an interesting example
327
  gr.Success(
328
+ f"Interesting example (page {attempt + 1}) - ready for your feedback",
329
+ duration=None,
330
  )
331
  return (
332
  page_title,
feedback.py CHANGED
@@ -7,6 +7,7 @@ import logfire
7
  import json
8
  import os
9
  import re
 
10
 
11
  # Load API keys
12
  load_dotenv()
@@ -122,8 +123,10 @@ def save_feedback(*args, feedback_value: str) -> None:
122
  feedback_action = "Updated"
123
 
124
  if do_save:
 
 
125
  # Save feedback to file
126
- feedback_file = f"train-{datetime.now().isoformat()}.json"
127
  feedback_path = USER_FEEDBACK_DIR / feedback_file
128
  with feedback_path.open("a") as f:
129
  f.write(json.dumps(feedback_dict))
 
7
  import json
8
  import os
9
  import re
10
+ import random
11
 
12
  # Load API keys
13
  load_dotenv()
 
123
  feedback_action = "Updated"
124
 
125
  if do_save:
126
+ # Randomly assign to train or test split (40% probability for test)
127
+ split = "test" if random.random() < 0.4 else "train"
128
  # Save feedback to file
129
+ feedback_file = f"{split}-{datetime.now().isoformat()}.json"
130
  feedback_path = USER_FEEDBACK_DIR / feedback_file
131
  with feedback_path.open("a") as f:
132
  f.write(json.dumps(feedback_dict))