Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ---
|
2 |
+
# jupyter:
|
3 |
+
# jupytext:
|
4 |
+
# text_representation:
|
5 |
+
# extension: .py
|
6 |
+
# format_name: light
|
7 |
+
# format_version: '1.5'
|
8 |
+
# jupytext_version: 1.16.4
|
9 |
+
# kernelspec:
|
10 |
+
# display_name: Python 3 (ipykernel)
|
11 |
+
# language: python
|
12 |
+
# name: python3
|
13 |
+
# ---
|
14 |
+
|
15 |
+
# +
|
16 |
+
import streamlit as st
|
17 |
+
import pandas as pd
|
18 |
+
import numpy as np
|
19 |
+
import faiss
|
20 |
+
from sentence_transformers import SentenceTransformer
|
21 |
+
import warnings
|
22 |
+
warnings.filterwarnings('ignore')
|
23 |
+
|
24 |
+
# Load SBERT model, FAISS index, and data
|
25 |
+
@st.cache_resource
|
26 |
+
def load_artifacts():
|
27 |
+
model = SentenceTransformer('all-MiniLM-L6-v2')
|
28 |
+
index = faiss.read_index('faiss_index.index')
|
29 |
+
df = pd.read_csv('assessment_data.csv')
|
30 |
+
return model, index, df
|
31 |
+
|
32 |
+
# Recommendation Function
|
33 |
+
def recommend_assessments(profile_text, model, index, df, top_n=10):
|
34 |
+
profile_embedding = model.encode([profile_text]).astype('float32')
|
35 |
+
_, indices = index.search(profile_embedding, top_n)
|
36 |
+
return df.iloc[indices[0]]
|
37 |
+
|
38 |
+
# Streamlit UI
|
39 |
+
st.title("🔍 SHL Assessment Recommender")
|
40 |
+
|
41 |
+
profile = st.text_area("✍️ Enter your job role or career aspiration:",
|
42 |
+
"Looking for a leadership role in financial planning and client management")
|
43 |
+
|
44 |
+
if st.button("Get Recommendations"):
|
45 |
+
model, index, df = load_artifacts()
|
46 |
+
results = recommend_assessments(profile, model, index, df, top_n=10)
|
47 |
+
st.subheader("🧠 Top 10 Matching Assessments")
|
48 |
+
st.dataframe(results[['Assesment Name', 'cleaned_text', 'Duration',
|
49 |
+
'Remote Testing Support', 'URL', 'Adaptive/IRT', 'Job Type']].reset_index(drop=True))
|
50 |
+
# -
|
51 |
+
|
52 |
+
|