Fralet commited on
Commit
ba8654a
·
verified ·
1 Parent(s): 9745f02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -36,8 +36,10 @@ def preprocess_text(text):
36
 
37
  # Combine relevant text columns for processing
38
  question_columns = [f'Q{i}' for i in range(1, 37)] # Adjust the range based on your data columns
39
- data['processed_text'] = data[['CV/Resume'] + question_columns].agg(' '.join, axis=1).apply(preprocess_text)
40
- data_open['processed_text_open'] = data_open[['CV/Resume', 'Question']].agg(' '.join, axis=1).apply(processed_text_open)
 
 
41
 
42
  labels = ["Peacemaker", "Loyalist", "Achiever", "Reformer", "Individualist", "Helper", "Challenger", "Investigator", "Enthusiast"]
43
 
@@ -47,9 +49,9 @@ confidence_threshold = st.slider("Confidence Threshold", 0.0, 1.0, 0.5)
47
  if st.button("Predict Personality by Test"):
48
  # Function to apply predictions using dynamic labels from MAX1, MAX2, MAX3 and only return the highest scored label
49
  def get_predictions(row):
50
- #custom_labels = [row['MAX1'], row['MAX2'], row['MAX3']] # Get labels from each row
51
  processed_text = row['processed_text']
52
- result = classifier(processed_text, labels)
53
  highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
54
  return highest_score_label
55
 
 
36
 
37
  # Combine relevant text columns for processing
38
  question_columns = [f'Q{i}' for i in range(1, 37)] # Adjust the range based on your data columns
39
+ data['processed_text'] = data[['CV/Resume'] + question_columns].agg(' '.join, axis=1)
40
+ #data['processed_text'] = data[['CV/Resume'] + question_columns].agg(' '.join, axis=1).apply(preprocess_text)
41
+ data_open['processed_text_open'] = data_open[['CV/Resume', 'Question']].agg(' '.join, axis=1)
42
+ #data_open['processed_text_open'] = data_open[['CV/Resume', 'Question']].agg(' '.join, axis=1).apply(preprocess_text)
43
 
44
  labels = ["Peacemaker", "Loyalist", "Achiever", "Reformer", "Individualist", "Helper", "Challenger", "Investigator", "Enthusiast"]
45
 
 
49
  if st.button("Predict Personality by Test"):
50
  # Function to apply predictions using dynamic labels from MAX1, MAX2, MAX3 and only return the highest scored label
51
  def get_predictions(row):
52
+ custom_labels = [row['MAX1'], row['MAX2'], row['MAX3']] # Get labels from each row
53
  processed_text = row['processed_text']
54
+ result = classifier(processed_text, custom_labels)
55
  highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
56
  return highest_score_label
57