vamshibellala/matching_algorithm
0
1import pandas as pd2import random3import streamlit as st4 5df = pd.read_csv('profiles.csv')6 7 8def match_therapist(new_user_interests, new_user_therapy_goals):9 """10 This function takes a new user's interests and therapy goals and finds a matching therapist from the DataFrame.11 12 Args:13 Take user input of new user's interests (e.g., ['Anxiety', 'Stress']).14 Take user input of new user's therapy goals (e.g., ['Mindfulness', 'Stress management']).15 16 Returns:17 DataFrame: A DataFrame containing the matched therapist's information (including User_ID, Name, etc.).18 """19 20 # Find therapists with matching interests21 matching_interests = df['Interests'].apply(lambda interests: any(interest in new_user_interests for interest in interests.split(',')))22 therapists_by_interests = df[matching_interests]23 24 # Further filter based on matching therapy goals (consider weights for stronger matches)25 matching_goals = therapists_by_interests['Therapy_Goals'].apply(lambda goals: any(goal in new_user_therapy_goals for goal in goals.split(',')))26 matched_therapist = therapists_by_interests[matching_goals].iloc[0] # Select first matched therapist (can be enhanced)27 28 return matched_therapist29 30# Example usage:31# new_user_interests = input('Enter the interest: ')32# new_user_therapy_goals = input('Enter the therapy: ')33 34new_user_interests = st.text_area("Enter the interest: ")35new_user_therapy_goals = st.text_area("Enter the therapy: ")36 37matched_therapist_df = match_therapist(new_user_interests, new_user_therapy_goals)38 39print(f"Matched user information:\n{matched_therapist_df}")40 