Fralet commited on
Commit
d605d91
1 Parent(s): 6297210

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -15,9 +15,11 @@ classifier = pipeline("zero-shot-classification", model="Fralet/personality")
15
 
16
  # Streamlit interface setup
17
  st.title("Resume-based Personality Prediction by Serikov Ayanbek")
 
18
 
19
  # Load data from Excel
20
  data = pd.read_excel("ResponseTest.xlsx") # Replace 'ResponseTest.xlsx' with your actual file name
 
21
 
22
  # Preprocess text function
23
  def preprocess_text(text):
@@ -34,17 +36,18 @@ def preprocess_text(text):
34
 
35
  # Combine relevant text columns for processing
36
  question_columns = [f'Q{i}' for i in range(1, 37)] # Adjust range if needed
37
- data['combined_text'] = data[['CV/Resume'] + question_columns].agg(' '.join, axis=1)
38
- data['processed_text'] = data['combined_text'].apply(preprocess_text)
 
39
  labels = ["Peacemaker", "Loyalist", "Achiever", "Reformer", "Individualist", "Helper", "Challenger", "Investigator", "Enthusiast"]
40
 
41
  # Prediction confidence threshold
42
  confidence_threshold = st.slider("Confidence Threshold", 0.0, 1.0, 0.5)
43
 
44
- if st.button("Predict Personality"):
45
  # Function to apply predictions using dynamic labels from MAX1, MAX2, MAX3 and only return the highest scored label
46
  def get_predictions(row):
47
- custom_labels = [row['MAX1'], row['MAX2'], row['MAX3']] # Get labels from each row
48
  processed_text = row['processed_text']
49
  result = classifier(processed_text, labels)
50
  highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
@@ -53,3 +56,14 @@ if st.button("Predict Personality"):
53
  # Apply predictions across all rows
54
  data['Predicted'] = data.apply(get_predictions, axis=1)
55
  st.dataframe(data[['True_label','MAX1','MAX2','MAX3', 'Predicted']])
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  # Streamlit interface setup
17
  st.title("Resume-based Personality Prediction by Serikov Ayanbek")
18
+ resume_text = st.text_area("Enter Resume Text Here", height=300)
19
 
20
  # Load data from Excel
21
  data = pd.read_excel("ResponseTest.xlsx") # Replace 'ResponseTest.xlsx' with your actual file name
22
+ data_open = pd.read_excel("ResponseOpen.xlsx") # Replace 'ResponseTest.xlsx' with your actual file name
23
 
24
  # Preprocess text function
25
  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 range if needed
39
+ data['processed_text'] = data[['CV/Resume'] + question_columns].agg(' '.join, axis=1)
40
+ data_open['processed_text_open'] = data_open[['CV/Resume'] + ['Question']]
41
+
42
  labels = ["Peacemaker", "Loyalist", "Achiever", "Reformer", "Individualist", "Helper", "Challenger", "Investigator", "Enthusiast"]
43
 
44
  # Prediction confidence threshold
45
  confidence_threshold = st.slider("Confidence Threshold", 0.0, 1.0, 0.5)
46
 
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
 
56
  # Apply predictions across all rows
57
  data['Predicted'] = data.apply(get_predictions, axis=1)
58
  st.dataframe(data[['True_label','MAX1','MAX2','MAX3', 'Predicted']])
59
+
60
+ if st.button("Predict Personality by Open Question"):
61
+ def get_predictions(row):
62
+ processed_text = row['processed_text_open']
63
+ result = classifier(processed_text, labels)
64
+ highest_score_label = result['labels'][0] # Assumes the labels are sorted by score, highest first
65
+ return highest_score_label
66
+
67
+ # Apply predictions across all rows
68
+ data_open['Predicted'] = data_open.apply(get_predictions, axis=1)
69
+ st.dataframe(data_open[['True_label', 'Predicted']])