Fralet commited on
Commit
8f9d718
1 Parent(s): 429154d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -36,10 +36,12 @@ 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)
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
 
@@ -57,7 +59,7 @@ if st.button("Predict Personality by Test"):
57
 
58
  # Apply predictions across all rows
59
  data['Predicted'] = data.apply(get_predictions, axis=1)
60
- st.dataframe(data[['True_label','MAX1','MAX2','MAX3','processed_text', 'Predicted']])
61
 
62
  if st.button("Predict Personality by Open Question"):
63
  def get_predictions(row):
@@ -65,7 +67,14 @@ if st.button("Predict Personality by Open Question"):
65
  result = classifier(processed_text, labels)
66
  highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
67
  return highest_score_label
 
 
 
 
 
 
68
 
69
  # Apply predictions across all rows
70
- data_open['Predicted'] = data_open.apply(get_predictions, axis=1)
71
- st.dataframe(data_open[['True_label', 'Predicted']])
 
 
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(lambda x: ', '.join(x), axis=1)
40
+ #data['processed_text'] = data[['CV/Resume'] + question_columns].agg(lambda x: ', '.join(x), 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
+ data_open['processed_text_open'] = data_open[['Demo_F', 'Question']].agg(' '.join, axis=1)
44
+ data_open['processed_text_mopen'] = data_open[['Demo_M', 'Question']].agg(' '.join, axis=1)
45
 
46
  labels = ["Peacemaker", "Loyalist", "Achiever", "Reformer", "Individualist", "Helper", "Challenger", "Investigator", "Enthusiast"]
47
 
 
59
 
60
  # Apply predictions across all rows
61
  data['Predicted'] = data.apply(get_predictions, axis=1)
62
+ st.dataframe(data[['True_label','MAX1','MAX2','MAX3', 'Predicted']])
63
 
64
  if st.button("Predict Personality by Open Question"):
65
  def get_predictions(row):
 
67
  result = classifier(processed_text, labels)
68
  highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
69
  return highest_score_label
70
+
71
+ def get_predictionsM(row):
72
+ processed_text = row['processed_text_mopen']
73
+ result = classifier(processed_text, labels)
74
+ highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
75
+ return highest_score_label
76
 
77
  # Apply predictions across all rows
78
+ data_open['Predicted_M'] = data_open.apply(get_predictions, axis=1)
79
+ data_open['Predicted_F'] = data_open.apply(get_predictionsM, axis=1)
80
+ st.dataframe(data_open[['True_label', 'Predicted_F', 'Predicted_M']])