import pandas as pd
# Load the uploaded CSV file
file_path = 'C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/Raw - analytics-uncoded-15-04-2024 - edited.csv'
df = pd.read_csv(file_path)
# Display basic info and first few rows
df.info(), df.head()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 76 entries, 0 to 75 Data columns (total 37 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Response ID 76 non-null object 1 1. Would you like to continue? 76 non-null object 2 2. How old are you? 76 non-null object 3 3. What year are you in? 76 non-null object 4 5. Are you familiar with the concept of AI in Veterinary medicine? 76 non-null object 5 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related) 76 non-null object 6 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? 76 non-null object 7 10. In your opinion what are the benefits of incorporating AI into veterinary education? (Please select all that apply) 76 non-null object 8 12. What concerns, if any, do you have about incorporating AI into veterinary education? (Select all that apply) 76 non-null object 9 14. What do you think would be the best way to incorporate AI in to the veterinary curriculum effectively? (Please select all that apply) 76 non-null object 10 15. Do you feel adequately prepared to learn about AI in your veterinary education? 76 non-null object 11 16. Are you interested in advocating for the integration of AI into veterinary education? 76 non-null object 12 17. In your opinion how important is it to incorporate AI into veterinary practice? 76 non-null object 13 18. In your opinion what are the benefits of incorporating AI into veterinary practice? (Please select all that apply) 76 non-null object 14 19. If you have any other potential benefits of AI in veterinary practice please specify here 17 non-null object 15 20. What concerns, if any, do you have about incorporating AI into veterinary practice? (Select all that apply) 76 non-null object 16 22. which of the following statements best describes your outlook on the future of AI in practice 76 non-null object 17 23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine? 76 non-null object 18 24. If an AI tool was to be developed for clinical practice, what would you like the AI tool to be able to do? (suggestions or ideas are welcome) 34 non-null object 19 26. How strongly do you agree or disagree with the following opinions? 0 non-null float64 20 26.1. Age influences a veterinarian’s openness to use of AI in practice? 76 non-null object 21 26.2. AI can positively impact the field of veterinary medicine 75 non-null object 22 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice 76 non-null object 23 26.4. The disadvantages of AI outweigh its advantages in veterinary practice 76 non-null object 24 26.5. In the next 10 years AI will be more accepted for use by veterinary clinicians 76 non-null object 25 26.6. I am open to AI use in my veterinary career 76 non-null object 26 26.7. AI will decrease human errors in clinical practice 76 non-null object 27 26.8. I am concerned about the ethical implications of using AI in practice 76 non-null object 28 4. What are the first three words that come to mind when someone mentions Artificial intelligence (AI) ? 76 non-null object 29 6. What 3 words do you think of when people talk about AI in Veterinary practice? 76 non-null object 30 8. If you answered 'yes' could you give any specific examples? 48 non-null object 31 11. If you have any other potential benefits of AI in veterinary education please specify here 21 non-null object 32 13. If you have any other concerns about AI in veterinary education please specify here 22 non-null object 33 19. If you have any other potential benefits of AI in veterinary practice please specify here.1 17 non-null object 34 21. If you have any other concerns with AI in veterinary practice please specify here 14 non-null object 35 25. What specific areas of veterinary medicine do you believe could benefit the most from the integration of AI? Why? 76 non-null object 36 Completion Date 76 non-null object dtypes: float64(1), object(36) memory usage: 22.1+ KB
(None, Response ID 1. Would you like to continue? \ 0 clt8jb2sf01r342d2tdlie569 Yes 1 clt8jd3v101s942d2s2lx59qq Yes 2 clt8jdzcf01sx42d2muflfse8 Yes 3 clt8je7cg01t342d23zvfuei4 Yes 4 clt8kf9wp00hhb7aws8bnua08 Yes 2. How old are you? 3. What year are you in? \ 0 20-23 Third year 1 20-23 Third year 2 20-23 Third year 3 20-23 Third year 4 24-26 Third year 5. Are you familiar with the concept of AI in Veterinary medicine? \ 0 No 1 No 2 No 3 No 4 Yes 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related) \ 0 No 1 Yes 2 No 3 Yes 4 Yes 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? \ 0 Very Important 1 Somewhat important 2 Not important 3 Somewhat important 4 Somewhat important 10. In your opinion what are the benefits of incorporating AI into veterinary education? (Please select all that apply) \ 0 Keeping Pace with Technological Advancements,I... 1 Keeping Pace with Technological Advancements,I... 2 Improved treatment planning 3 Keeping Pace with Technological Advancements,E... 4 Keeping Pace with Technological Advancements,I... 12. What concerns, if any, do you have about incorporating AI into veterinary education? (Select all that apply) \ 0 AI is too 'high tech' and overcomplicated 1 Overreliance on technology,AI is too 'high tec... 2 Overreliance on technology,Ethical challenges 3 Integration challenges within the curriculum ,... 4 I have no concerns 14. What do you think would be the best way to incorporate AI in to the veterinary curriculum effectively? (Please select all that apply) \ 0 Collaborative Research Projects,Lectures and s... 1 Collaborative Research Projects,Hands on work ... 2 Collaborative Research Projects 3 Collaborative Research Projects,Hands on work ... 4 Lectures and seminars ... \ 0 ... 1 ... 2 ... 3 ... 4 ... 26.8. I am concerned about the ethical implications of using AI in practice \ 0 Disagree 1 Agree 2 Neutral 3 Agree 4 Agree 4. What are the first three words that come to mind when someone mentions Artificial intelligence (AI) ? \ 0 Technology \nRobots \nComputers 1 Future \nNew\nUseful 2 Helpful, inaccurate, cheating 3 Cheating, helpful, robot 4 Complex \nFuture \nDevelopment 6. What 3 words do you think of when people talk about AI in Veterinary practice? \ 0 \nComputerised \nIntelligence \nAdvancements 1 Futuristic \nNew\nAssistance 2 Artificial insemination, scary 3 Helpful, inaccurate, rarely used 4 Innovating \nChanging \nBetter 8. If you answered 'yes' could you give any specific examples? \ 0 NaN 1 Chat gpt and Snapchat AI 2 NaN 3 Chat gbt 4 Chat gpt 11. If you have any other potential benefits of AI in veterinary education please specify here \ 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN 13. If you have any other concerns about AI in veterinary education please specify here \ 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN 19. If you have any other potential benefits of AI in veterinary practice please specify here.1 \ 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN 21. If you have any other concerns with AI in veterinary practice please specify here \ 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN 25. What specific areas of veterinary medicine do you believe could benefit the most from the integration of AI? Why? \ 0 Treatment and diagnosis \nSurgery 1 Treatment plans \nUse of large data sets such ... 2 Consults, vets spend a lot of time typing, whi... 3 Dose calculations, consults 4 Handling large data sets stop reduce human error Completion Date 0 2024-03-01 10:51:32 UTC 1 2024-03-01 10:53:07 UTC 2 2024-03-01 10:53:48 UTC 3 2024-03-01 10:53:58 UTC 4 2024-03-01 11:22:48 UTC [5 rows x 37 columns])
# Rename columns for readability and consistency
df.columns = [col.strip().split(". ", 1)[-1].replace("?", "").replace("(", "").replace(")", "").replace("\n", " ").strip().replace(" ", "_").lower() for col in df.columns]
# Display cleaned column names
df.columns.tolist()
['response_id', 'would_you_like_to_continue', 'how_old_are_you', 'what_year_are_you_in', 'are_you_familiar_with_the_concept_of_ai_in_veterinary_medicine', 'have_you_ever_used_a_ai_based_platform_or_technology_not_necessarily_veterinary_related', 'in_your_opinion,_how_important_is_it_to_incorporate_ai_into_veterinary_teaching_and_learning', 'in_your_opinion_what_are_the_benefits_of_incorporating_ai_into_veterinary_education_please_select_all_that_apply', 'what_concerns,_if_any,_do_you_have_about_incorporating_ai_into_veterinary_education_select_all_that_apply', 'what_do_you_think_would_be_the_best_way_to_incorporate_ai_in_to_the_veterinary_curriculum_effectively_please_select_all_that_apply', 'do_you_feel_adequately_prepared_to_learn_about_ai_in_your_veterinary_education', 'are_you_interested_in_advocating_for_the_integration_of_ai_into_veterinary_education', 'in_your_opinion_how_important_is_it_to_incorporate_ai_into_veterinary_practice', 'in_your_opinion_what_are_the_benefits_of_incorporating_ai_into_veterinary_practice_please_select_all_that_apply', 'if_you_have_any_other_potential_benefits_of_ai_in_veterinary_practice_please_specify_here', 'what_concerns,_if_any,_do_you_have_about_incorporating_ai_into_veterinary_practice_select_all_that_apply', 'which_of_the_following_statements_best_describes_your_outlook_on_the_future_of_ai_in_practice', 'do_you_believe_collaboration_between_veterinarians_and_ai_developers_is_essential_for_the_successful_implementation_of_ai_in_veterinary_medicine', 'if_an_ai_tool_was_to_be_developed_for_clinical_practice,_what_would_you_like_the_ai_tool_to_be_able_to_do_suggestions_or_ideas_are_welcome', 'how_strongly_do_you_agree_or_disagree_with_the_following_opinions', 'age_influences_a_veterinarian’s_openness_to_use_of_ai_in_practice', 'ai_can_positively_impact_the_field_of_veterinary_medicine', 'i_trust_the_reliability_and_accuracy_of_ai_systems_for_supporting_clinical_decision-making_in_veterinary_practice', 'the_disadvantages_of_ai_outweigh_its_advantages_in_veterinary_practice', 'in_the_next_10_years_ai_will_be_more_accepted_for_use_by_veterinary_clinicians', 'i_am_open_to_ai_use_in_my_veterinary_career', 'ai_will_decrease_human_errors_in_clinical_practice', 'i_am_concerned_about_the_ethical_implications_of_using_ai_in_practice', 'what_are_the_first_three_words_that_come_to_mind_when_someone_mentions_artificial_intelligence_ai', 'what_3_words_do_you_think_of_when_people_talk_about_ai_in_veterinary_practice', "if_you_answered_'yes'_could_you_give_any_specific_examples", 'if_you_have_any_other_potential_benefits_of_ai_in_veterinary_education_please_specify_here', 'if_you_have_any_other_concerns_about_ai_in_veterinary_education_please_specify_here', 'if_you_have_any_other_potential_benefits_of_ai_in_veterinary_practice_please_specify_here.1', 'if_you_have_any_other_concerns_with_ai_in_veterinary_practice_please_specify_here', 'what_specific_areas_of_veterinary_medicine_do_you_believe_could_benefit_the_most_from_the_integration_of_ai_why', 'completion_date']
import matplotlib.pyplot as plt
import seaborn as sns
# Set seaborn style
sns.set(style="whitegrid")
# Create plots for age and year distributions
fig, axs = plt.subplots(1, 2, figsize=(16, 6))
# Plot age distribution
sns.countplot(data=df, x='how_old_are_you', order=df['how_old_are_you'].value_counts().index, ax=axs[0], palette="viridis")
axs[0].set_title('Age Distribution of Respondents')
axs[0].set_xlabel('Age Group')
axs[0].set_ylabel('Number of Respondents')
# Plot year in school distribution
sns.countplot(data=df, x='what_year_are_you_in', order=df['what_year_are_you_in'].value_counts().index, ax=axs[1], palette="mako")
axs[1].set_title('Academic Year Distribution')
axs[1].set_xlabel('Year in School')
axs[1].set_ylabel('Number of Respondents')
plt.tight_layout()
plt.show()
# Plot AI familiarity and usage
fig, axs = plt.subplots(1, 2, figsize=(16, 6))
# AI Familiarity
sns.countplot(data=df, x='are_you_familiar_with_the_concept_of_ai_in_veterinary_medicine',
order=df['are_you_familiar_with_the_concept_of_ai_in_veterinary_medicine'].value_counts().index,
ax=axs[0], palette="coolwarm")
axs[0].set_title('Familiarity with AI in Veterinary Medicine')
axs[0].set_xlabel('Familiar with AI Concept')
axs[0].set_ylabel('Number of Respondents')
# AI Usage in General
sns.countplot(data=df, x='have_you_ever_used_a_ai_based_platform_or_technology_not_necessarily_veterinary_related',
order=df['have_you_ever_used_a_ai_based_platform_or_technology_not_necessarily_veterinary_related'].value_counts().index,
ax=axs[1], palette="cubehelix")
axs[1].set_title('General Use of AI-Based Platforms')
axs[1].set_xlabel('Used AI-Based Tech')
axs[1].set_ylabel('Number of Respondents')
plt.tight_layout()
plt.show()
# Print all column names to identify the exact matching names due to formatting issues
df.columns.tolist()
['response_id', 'would_you_like_to_continue', 'how_old_are_you', 'what_year_are_you_in', 'are_you_familiar_with_the_concept_of_ai_in_veterinary_medicine', 'have_you_ever_used_a_ai_based_platform_or_technology_not_necessarily_veterinary_related', 'in_your_opinion,_how_important_is_it_to_incorporate_ai_into_veterinary_teaching_and_learning', 'in_your_opinion_what_are_the_benefits_of_incorporating_ai_into_veterinary_education_please_select_all_that_apply', 'what_concerns,_if_any,_do_you_have_about_incorporating_ai_into_veterinary_education_select_all_that_apply', 'what_do_you_think_would_be_the_best_way_to_incorporate_ai_in_to_the_veterinary_curriculum_effectively_please_select_all_that_apply', 'do_you_feel_adequately_prepared_to_learn_about_ai_in_your_veterinary_education', 'are_you_interested_in_advocating_for_the_integration_of_ai_into_veterinary_education', 'in_your_opinion_how_important_is_it_to_incorporate_ai_into_veterinary_practice', 'in_your_opinion_what_are_the_benefits_of_incorporating_ai_into_veterinary_practice_please_select_all_that_apply', 'if_you_have_any_other_potential_benefits_of_ai_in_veterinary_practice_please_specify_here', 'what_concerns,_if_any,_do_you_have_about_incorporating_ai_into_veterinary_practice_select_all_that_apply', 'which_of_the_following_statements_best_describes_your_outlook_on_the_future_of_ai_in_practice', 'do_you_believe_collaboration_between_veterinarians_and_ai_developers_is_essential_for_the_successful_implementation_of_ai_in_veterinary_medicine', 'if_an_ai_tool_was_to_be_developed_for_clinical_practice,_what_would_you_like_the_ai_tool_to_be_able_to_do_suggestions_or_ideas_are_welcome', 'how_strongly_do_you_agree_or_disagree_with_the_following_opinions', 'age_influences_a_veterinarian’s_openness_to_use_of_ai_in_practice', 'ai_can_positively_impact_the_field_of_veterinary_medicine', 'i_trust_the_reliability_and_accuracy_of_ai_systems_for_supporting_clinical_decision-making_in_veterinary_practice', 'the_disadvantages_of_ai_outweigh_its_advantages_in_veterinary_practice', 'in_the_next_10_years_ai_will_be_more_accepted_for_use_by_veterinary_clinicians', 'i_am_open_to_ai_use_in_my_veterinary_career', 'ai_will_decrease_human_errors_in_clinical_practice', 'i_am_concerned_about_the_ethical_implications_of_using_ai_in_practice', 'what_are_the_first_three_words_that_come_to_mind_when_someone_mentions_artificial_intelligence_ai', 'what_3_words_do_you_think_of_when_people_talk_about_ai_in_veterinary_practice', "if_you_answered_'yes'_could_you_give_any_specific_examples", 'if_you_have_any_other_potential_benefits_of_ai_in_veterinary_education_please_specify_here', 'if_you_have_any_other_concerns_about_ai_in_veterinary_education_please_specify_here', 'if_you_have_any_other_potential_benefits_of_ai_in_veterinary_practice_please_specify_here.1', 'if_you_have_any_other_concerns_with_ai_in_veterinary_practice_please_specify_here', 'what_specific_areas_of_veterinary_medicine_do_you_believe_could_benefit_the_most_from_the_integration_of_ai_why', 'completion_date']
pip install ace
Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: ace in c:\users\odaramola1\appdata\roaming\python\python310\site-packages (0.3.3) Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (from ace) (1.23.5) Requirement already satisfied: scipy>=0.17 in c:\programdata\anaconda3\lib\site-packages (from ace) (1.10.0) Note: you may need to restart the kernel to use updated packages.
pip install ace-tools
Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: ace-tools in c:\users\odaramola1\appdata\roaming\python\python310\site-packages (0.0) Note: you may need to restart the kernel to use updated packages.
import pandas as pd
# Load your CSV file
df = pd.read_csv("C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/Raw - analytics-uncoded-15-04-2024 - edited.csv") # Replace with your actual path
# Clean column names to avoid trailing spaces
df.columns = df.columns.str.strip()
# Select key survey questions
selected_columns = [
"2. How old are you?",
"3. What year are you in?",
"5. Are you familiar with the concept of AI in Veterinary medicine?",
"7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)",
"9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?",
"15. Do you feel adequately prepared to learn about AI in your veterinary education?",
"16. Are you interested in advocating for the integration of AI into veterinary education?",
"17. In your opinion how important is it to incorporate AI into veterinary practice?",
"22. which of the following statements best describes your outlook on the future of AI in practice",
"23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine?"
]
# Generate and display value counts for each selected column
for col in selected_columns:
print(f"\n--- {col} ---")
print(df[col].value_counts(dropna=False))
--- 2. How old are you? --- 20-23 46 Under 20 10 30+ 9 24-26 6 27-30 5 Name: 2. How old are you?, dtype: int64 --- 3. What year are you in? --- Third year 50 Fourth year 11 First year 9 Second year 5 Fifth year 1 Name: 3. What year are you in?, dtype: int64 --- 5. Are you familiar with the concept of AI in Veterinary medicine? --- No 34 Somewhat familiar 31 Yes 11 Name: 5. Are you familiar with the concept of AI in Veterinary medicine?, dtype: int64 --- 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related) --- Yes 48 No 28 Name: 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related), dtype: int64 --- 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? --- Somewhat important 52 Very Important 14 Not important 10 Name: 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?, dtype: int64 --- 15. Do you feel adequately prepared to learn about AI in your veterinary education? --- No 42 Yes 34 Name: 15. Do you feel adequately prepared to learn about AI in your veterinary education?, dtype: int64 --- 16. Are you interested in advocating for the integration of AI into veterinary education? --- Yes 41 No 35 Name: 16. Are you interested in advocating for the integration of AI into veterinary education?, dtype: int64 --- 17. In your opinion how important is it to incorporate AI into veterinary practice? --- Somewhat important 41 Very important 25 Not important 10 Name: 17. In your opinion how important is it to incorporate AI into veterinary practice?, dtype: int64 --- 22. which of the following statements best describes your outlook on the future of AI in practice --- I am optimistic 39 I am sceptical 28 I have no opinion 9 Name: 22. which of the following statements best describes your outlook on the future of AI in practice, dtype: int64 --- 23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine? --- Yes 68 No 8 Name: 23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine?, dtype: int64
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load and clean data
df = pd.read_csv("C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/Raw - analytics-uncoded-15-04-2024 - edited.csv") # Replace with your actual file path
df.columns = df.columns.str.strip() # Remove trailing spaces from headers
# List of key categorical survey questions
columns_to_plot = [
"2. How old are you?",
"3. What year are you in?",
"5. Are you familiar with the concept of AI in Veterinary medicine?",
"7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)",
"9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?",
"15. Do you feel adequately prepared to learn about AI in your veterinary education?",
"16. Are you interested in advocating for the integration of AI into veterinary education?",
"17. In your opinion how important is it to incorporate AI into veterinary practice?",
"22. which of the following statements best describes your outlook on the future of AI in practice",
"23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine?"
]
# Plot each as a bar chart
for col in columns_to_plot:
plt.figure(figsize=(10, 5))
sns.countplot(y=df[col], order=df[col].value_counts().index, palette="viridis")
plt.title(f"Response Distribution: {col}", fontsize=12)
plt.xlabel("Count")
plt.ylabel("Response")
plt.tight_layout()
plt.show()
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load and clean the data
df = pd.read_csv("C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/Raw - analytics-uncoded-15-04-2024 - edited.csv") # Replace with your actual file path
df.columns = df.columns.str.strip() # Clean column headers
# List of key categorical survey questions
columns_to_plot = [
"2. How old are you?",
"3. What year are you in?",
"5. Are you familiar with the concept of AI in Veterinary medicine?",
"7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)",
"9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?",
"15. Do you feel adequately prepared to learn about AI in your veterinary education?",
"16. Are you interested in advocating for the integration of AI into veterinary education?",
"17. In your opinion how important is it to incorporate AI into veterinary practice?",
"22. which of the following statements best describes your outlook on the future of AI in practice",
"23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine?"
]
# Create vertical bar plots
for col in columns_to_plot:
plt.figure(figsize=(12, 5))
sns.countplot(data=df, x=col, order=df[col].value_counts().index, palette="crest")
plt.title(f"Distribution of Responses: {col}", fontsize=12)
plt.xticks(rotation=45, ha='right')
plt.ylabel("Count")
plt.xlabel("Response")
plt.tight_layout()
plt.show()
# Re-run categorical distribution overview and display using standard Python (no ace_tools)
# Clean column headers again just to ensure consistency
df.columns = df.columns.str.strip()
# Define relevant columns
categorical_columns = [
"2. How old are you?",
"3. What year are you in?",
"5. Are you familiar with the concept of AI in Veterinary medicine?",
"7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)",
"9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?",
"15. Do you feel adequately prepared to learn about AI in your veterinary education?",
"16. Are you interested in advocating for the integration of AI into veterinary education?",
"17. In your opinion how important is it to incorporate AI into veterinary practice?",
"22. which of the following statements best describes your outlook on the future of AI in practice",
"23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine?"
]
# Generate value counts and display each
categorical_distributions = {}
for col in categorical_columns:
counts = df[col].value_counts(dropna=False)
categorical_distributions[col] = counts
print(f"\n--- {col} ---")
print(counts)
--- 2. How old are you? --- 20-23 46 Under 20 10 30+ 9 24-26 6 27-30 5 Name: 2. How old are you?, dtype: int64 --- 3. What year are you in? --- Third year 50 Fourth year 11 First year 9 Second year 5 Fifth year 1 Name: 3. What year are you in?, dtype: int64 --- 5. Are you familiar with the concept of AI in Veterinary medicine? --- No 34 Somewhat familiar 31 Yes 11 Name: 5. Are you familiar with the concept of AI in Veterinary medicine?, dtype: int64 --- 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related) --- Yes 48 No 28 Name: 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related), dtype: int64 --- 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? --- Somewhat important 52 Very Important 14 Not important 10 Name: 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?, dtype: int64 --- 15. Do you feel adequately prepared to learn about AI in your veterinary education? --- No 42 Yes 34 Name: 15. Do you feel adequately prepared to learn about AI in your veterinary education?, dtype: int64 --- 16. Are you interested in advocating for the integration of AI into veterinary education? --- Yes 41 No 35 Name: 16. Are you interested in advocating for the integration of AI into veterinary education?, dtype: int64 --- 17. In your opinion how important is it to incorporate AI into veterinary practice? --- Somewhat important 41 Very important 25 Not important 10 Name: 17. In your opinion how important is it to incorporate AI into veterinary practice?, dtype: int64 --- 22. which of the following statements best describes your outlook on the future of AI in practice --- I am optimistic 39 I am sceptical 28 I have no opinion 9 Name: 22. which of the following statements best describes your outlook on the future of AI in practice, dtype: int64 --- 23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine? --- Yes 68 No 8 Name: 23. Do you believe collaboration between veterinarians and AI developers is essential for the successful implementation of AI in veterinary medicine?, dtype: int64
# Descriptive statistics for numeric and categorical data
# Basic descriptive stats for numeric data (only one column appears numeric from earlier check)
numeric_description = df.describe(include=[float, int])
# Basic stats for categorical/object data
categorical_description = df.describe(include=[object])
numeric_description, categorical_description
( 26. How strongly do you agree or disagree with the following opinions? count 0.0 mean NaN std NaN min NaN 25% NaN 50% NaN 75% NaN max NaN , Response ID 1. Would you like to continue? \ count 76 76 unique 76 1 top clt8jb2sf01r342d2tdlie569 Yes freq 1 76 2. How old are you? 3. What year are you in? \ count 76 76 unique 5 5 top 20-23 Third year freq 46 50 5. Are you familiar with the concept of AI in Veterinary medicine? \ count 76 unique 3 top No freq 34 7. Have you ever used a AI based platform or technology? (not necessarily veterinary related) \ count 76 unique 2 top Yes freq 48 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? \ count 76 unique 3 top Somewhat important freq 52 10. In your opinion what are the benefits of incorporating AI into veterinary education? (Please select all that apply) \ count 76 unique 11 top Keeping Pace with Technological Advancements,I... freq 23 12. What concerns, if any, do you have about incorporating AI into veterinary education? (Select all that apply) \ count 76 unique 16 top Overreliance on technology,Ethical challenges freq 24 14. What do you think would be the best way to incorporate AI in to the veterinary curriculum effectively? (Please select all that apply) \ count 76 unique 23 top Continuous Professional Development programmes freq 14 ... \ count ... unique ... top ... freq ... 26.8. I am concerned about the ethical implications of using AI in practice \ count 76 unique 4 top Agree freq 43 4. What are the first three words that come to mind when someone mentions Artificial intelligence (AI) ? \ count 76 unique 72 top Helpful, inaccurate, cheating freq 2 6. What 3 words do you think of when people talk about AI in Veterinary practice? \ count 76 unique 73 top Futuristic \nNew\nAssistance freq 2 8. If you answered 'yes' could you give any specific examples? \ count 48 unique 40 top ChatGPT freq 5 11. If you have any other potential benefits of AI in veterinary education please specify here \ count 21 unique 18 top Simulation and virtual reality, continuous lea... freq 3 13. If you have any other concerns about AI in veterinary education please specify here \ count 22 unique 18 top Depersonalisation of learning\nJob displacemen... freq 2 19. If you have any other potential benefits of AI in veterinary practice please specify here.1 \ count 17 unique 15 top Help come up with differentials that vets may ... freq 2 21. If you have any other concerns with AI in veterinary practice please specify here \ count 14 unique 9 top data privacy and security, algorithm bias, cos... freq 3 25. What specific areas of veterinary medicine do you believe could benefit the most from the integration of AI? Why? \ count 76 unique 72 top Treatment plans \nUse of large data sets such ... freq 2 Completion Date count 76 unique 75 top 2024-03-19 14:41:20 UTC freq 2 [4 rows x 36 columns])
# Cross-tab analysis: AI Familiarity vs Importance of AI in Education
crosstab_familiarity_importance = pd.crosstab(
df["5. Are you familiar with the concept of AI in Veterinary medicine?"],
df["9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?"],
margins=True,
normalize='index'
)
# Raw counts as well
crosstab_counts = pd.crosstab(
df["5. Are you familiar with the concept of AI in Veterinary medicine?"],
df["9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?"],
margins=True
)
crosstab_familiarity_importance, crosstab_counts
(9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Not important \ 5. Are you familiar with the concept of AI in V... No 0.176471 Somewhat familiar 0.064516 Yes 0.181818 All 0.131579 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Somewhat important \ 5. Are you familiar with the concept of AI in V... No 0.617647 Somewhat familiar 0.741935 Yes 0.727273 All 0.684211 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Very Important 5. Are you familiar with the concept of AI in V... No 0.205882 Somewhat familiar 0.193548 Yes 0.090909 All 0.184211 , 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Not important \ 5. Are you familiar with the concept of AI in V... No 6 Somewhat familiar 2 Yes 2 All 10 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Somewhat important \ 5. Are you familiar with the concept of AI in V... No 21 Somewhat familiar 23 Yes 8 All 52 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Very Important \ 5. Are you familiar with the concept of AI in V... No 7 Somewhat familiar 6 Yes 1 All 14 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? All 5. Are you familiar with the concept of AI in V... No 34 Somewhat familiar 31 Yes 11 All 76 )
# Cross-tab analysis: AI Usage vs. Willingness to Advocate for AI in Education
crosstab_usage_advocacy = pd.crosstab(
df["7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)"],
df["16. Are you interested in advocating for the integration of AI into veterinary education?"],
margins=True,
normalize='index'
)
# Raw count version
crosstab_usage_advocacy_counts = pd.crosstab(
df["7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)"],
df["16. Are you interested in advocating for the integration of AI into veterinary education?"],
margins=True
)
crosstab_usage_advocacy, crosstab_usage_advocacy_counts
(16. Are you interested in advocating for the integration of AI into veterinary education? No \ 7. Have you ever used a AI based platform or te... No 0.607143 Yes 0.375000 All 0.460526 16. Are you interested in advocating for the integration of AI into veterinary education? Yes 7. Have you ever used a AI based platform or te... No 0.392857 Yes 0.625000 All 0.539474 , 16. Are you interested in advocating for the integration of AI into veterinary education? No \ 7. Have you ever used a AI based platform or te... No 17 Yes 18 All 35 16. Are you interested in advocating for the integration of AI into veterinary education? Yes \ 7. Have you ever used a AI based platform or te... No 11 Yes 30 All 41 16. Are you interested in advocating for the integration of AI into veterinary education? All 7. Have you ever used a AI based platform or te... No 28 Yes 48 All 76 )
# Cross-tab analysis: Year of Study vs. AI Outlook
crosstab_year_outlook = pd.crosstab(
df["3. What year are you in?"],
df["22. which of the following statements best describes your outlook on the future of AI in practice"],
margins=True,
normalize='index'
)
# Raw count version
crosstab_year_outlook_counts = pd.crosstab(
df["3. What year are you in?"],
df["22. which of the following statements best describes your outlook on the future of AI in practice"],
margins=True
)
crosstab_year_outlook, crosstab_year_outlook_counts
(22. which of the following statements best describes your outlook on the future of AI in practice I am optimistic \ 3. What year are you in? Fifth year 1.000000 First year 1.000000 Fourth year 0.454545 Second year 0.800000 Third year 0.400000 All 0.513158 22. which of the following statements best describes your outlook on the future of AI in practice I am sceptical \ 3. What year are you in? Fifth year 0.000000 First year 0.000000 Fourth year 0.545455 Second year 0.200000 Third year 0.420000 All 0.368421 22. which of the following statements best describes your outlook on the future of AI in practice I have no opinion 3. What year are you in? Fifth year 0.000000 First year 0.000000 Fourth year 0.000000 Second year 0.000000 Third year 0.180000 All 0.118421 , 22. which of the following statements best describes your outlook on the future of AI in practice I am optimistic \ 3. What year are you in? Fifth year 1 First year 9 Fourth year 5 Second year 4 Third year 20 All 39 22. which of the following statements best describes your outlook on the future of AI in practice I am sceptical \ 3. What year are you in? Fifth year 0 First year 0 Fourth year 6 Second year 1 Third year 21 All 28 22. which of the following statements best describes your outlook on the future of AI in practice I have no opinion \ 3. What year are you in? Fifth year 0 First year 0 Fourth year 0 Second year 0 Third year 9 All 9 22. which of the following statements best describes your outlook on the future of AI in practice All 3. What year are you in? Fifth year 1 First year 9 Fourth year 11 Second year 5 Third year 50 All 76 )
# Cross-tab analysis: Ethical Concerns vs. Trust in AI
# Columns used:
# - Ethical Concern: "26.8. I am concerned about the ethical implications of using AI in practice"
# - Trust in AI: "26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice"
crosstab_ethics_trust = pd.crosstab(
df["26.8. I am concerned about the ethical implications of using AI in practice"],
df["26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice"],
margins=True,
normalize='index'
)
# Raw count version
crosstab_ethics_trust_counts = pd.crosstab(
df["26.8. I am concerned about the ethical implications of using AI in practice"],
df["26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice"],
margins=True
)
crosstab_ethics_trust, crosstab_ethics_trust_counts
(26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Agree \ 26.8. I am concerned about the ethical implicat... Agree 0.046512 Disagree 0.333333 Neutral 0.157895 Strongly agree 0.250000 All 0.118421 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Disagree \ 26.8. I am concerned about the ethical implicat... Agree 0.372093 Disagree 0.166667 Neutral 0.315789 Strongly agree 0.375000 All 0.342105 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Neutral \ 26.8. I am concerned about the ethical implicat... Agree 0.511628 Disagree 0.333333 Neutral 0.368421 Strongly agree 0.250000 All 0.434211 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Strongly agree \ 26.8. I am concerned about the ethical implicat... Agree 0.023256 Disagree 0.166667 Neutral 0.157895 Strongly agree 0.000000 All 0.065789 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Strongly disagree 26.8. I am concerned about the ethical implicat... Agree 0.046512 Disagree 0.000000 Neutral 0.000000 Strongly agree 0.125000 All 0.039474 , 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Agree \ 26.8. I am concerned about the ethical implicat... Agree 2 Disagree 2 Neutral 3 Strongly agree 2 All 9 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Disagree \ 26.8. I am concerned about the ethical implicat... Agree 16 Disagree 1 Neutral 6 Strongly agree 3 All 26 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Neutral \ 26.8. I am concerned about the ethical implicat... Agree 22 Disagree 2 Neutral 7 Strongly agree 2 All 33 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Strongly agree \ 26.8. I am concerned about the ethical implicat... Agree 1 Disagree 1 Neutral 3 Strongly agree 0 All 5 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice Strongly disagree \ 26.8. I am concerned about the ethical implicat... Agree 2 Disagree 0 Neutral 0 Strongly agree 1 All 3 26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice All 26.8. I am concerned about the ethical implicat... Agree 43 Disagree 6 Neutral 19 Strongly agree 8 All 76 )
# Cross-tab analysis: Preparedness vs Importance of AI in Veterinary Education
# Columns used:
# - Preparedness: "15. Do you feel adequately prepared to learn about AI in your veterinary education?"
# - Perceived Importance: "9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?"
crosstab_preparedness_importance = pd.crosstab(
df["15. Do you feel adequately prepared to learn about AI in your veterinary education?"],
df["9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?"],
margins=True,
normalize='index'
)
# Raw count version
crosstab_preparedness_importance_counts = pd.crosstab(
df["15. Do you feel adequately prepared to learn about AI in your veterinary education?"],
df["9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?"],
margins=True
)
crosstab_preparedness_importance, crosstab_preparedness_importance_counts
(9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Not important \ 15. Do you feel adequately prepared to learn ab... No 0.142857 Yes 0.117647 All 0.131579 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Somewhat important \ 15. Do you feel adequately prepared to learn ab... No 0.738095 Yes 0.617647 All 0.684211 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Very Important 15. Do you feel adequately prepared to learn ab... No 0.119048 Yes 0.264706 All 0.184211 , 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Not important \ 15. Do you feel adequately prepared to learn ab... No 6 Yes 4 All 10 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Somewhat important \ 15. Do you feel adequately prepared to learn ab... No 31 Yes 21 All 52 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? Very Important \ 15. Do you feel adequately prepared to learn ab... No 5 Yes 9 All 14 9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning? All 15. Do you feel adequately prepared to learn ab... No 42 Yes 34 All 76 )
from sklearn.feature_extraction.text import CountVectorizer
from wordcloud import WordCloud
import matplotlib.pyplot as plt
# Combine all text from selected open-ended fields on AI benefits and concerns
text_columns = [
"11. If you have any other potential benefits of AI in veterinary education please specify here",
"13. If you have any other concerns about AI in veterinary education please specify here",
"19. If you have any other potential benefits of AI in veterinary practice please specify here.1",
"21. If you have any other concerns with AI in veterinary practice please specify here"
]
# Combine all responses into one text blob per category
benefits_text = df[text_columns[0]].dropna().astype(str).str.cat(sep=' ')
concerns_text = df[text_columns[1]].dropna().astype(str).str.cat(sep=' ')
practice_benefits_text = df[text_columns[2]].dropna().astype(str).str.cat(sep=' ')
practice_concerns_text = df[text_columns[3]].dropna().astype(str).str.cat(sep=' ')
# Generate and plot word clouds
def plot_wordcloud(text, title):
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text)
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.title(title, fontsize=14)
plt.axis('off')
plt.tight_layout()
plt.show()
# Plot each category
plot_wordcloud(benefits_text, "AI Benefits in Veterinary Education")
plot_wordcloud(concerns_text, "AI Concerns in Veterinary Education")
plot_wordcloud(practice_benefits_text, "AI Benefits in Veterinary Practice")
plot_wordcloud(practice_concerns_text, "AI Concerns in Veterinary Practice")
import seaborn as sns
import numpy as np
# Select and encode Likert scale responses numerically
likert_columns = [
"26.1. Age influences a veterinarian’s openness to use of AI in practice?",
"26.2. AI can positively impact the field of veterinary medicine",
"26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice",
"26.4. The disadvantages of AI outweigh its advantages in veterinary practice",
"26.5. In the next 10 years AI will be more accepted for use by veterinary clinicians",
"26.6. I am open to AI use in my veterinary career",
"26.7. AI will decrease human errors in clinical practice",
"26.8. I am concerned about the ethical implications of using AI in practice"
]
# Likert scale encoding
likert_mapping = {
"Strongly disagree": 1,
"Disagree": 2,
"Neutral": 3,
"Agree": 4,
"Strongly agree": 5
}
# Create numerical DataFrame for correlation analysis
likert_df = df[likert_columns].replace(likert_mapping)
# Compute correlation matrix
correlation_matrix = likert_df.corr()
# Plot heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt=".2f", linewidths=0.5)
plt.title("Correlation Heatmap of AI Attitudes")
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
# Plot heatmap again without annotations or labels for a cleaner visual
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, cmap='coolwarm', cbar=False)
plt.xticks([])
plt.yticks([])
plt.title("Correlation Heatmap of AI Attitudes (Unlabeled)")
plt.tight_layout()
plt.show()
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
# Clean and scale data
scaled_data = StandardScaler().fit_transform(likert_df.dropna())
# Apply KMeans clustering (assume 3 clusters for simplicity)
kmeans = KMeans(n_clusters=3, random_state=42)
clusters = kmeans.fit_predict(scaled_data)
# Reduce dimensions for visualization
pca = PCA(n_components=2)
reduced_data = pca.fit_transform(scaled_data)
# Plot the clusters
plt.figure(figsize=(10, 6))
plt.scatter(reduced_data[:, 0], reduced_data[:, 1], c=clusters, cmap='Set1', s=60)
plt.title("Clusters of Respondents Based on AI Attitudes")
plt.xlabel("Principal Component 1")
plt.ylabel("Principal Component 2")
plt.grid(True)
plt.tight_layout()
plt.show()
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: UserWarning: KMeans is known to have a memory leak on Windows with MKL, when there are less chunks than available threads. You can avoid it by setting the environment variable OMP_NUM_THREADS=1. warnings.warn(
from docx import Document
from docx.shared import Inches
# Create Word document
doc = Document()
doc.add_heading("AI in Veterinary Education & Practice – Survey Analysis Report", 0)
# Introduction
doc.add_paragraph(
"This report presents a detailed analysis of survey responses related to attitudes, knowledge, and perceptions of AI among veterinary students and professionals. The insights are derived from 76 responses collected through a structured questionnaire."
)
# Section: Descriptive Statistics
doc.add_heading("1. Descriptive Statistics", level=1)
doc.add_paragraph(
"The sample is composed mostly of students aged 20–23 in their third year of study. "
"Most respondents are somewhat familiar with AI and have used AI tools. "
"While many recognize the importance of AI in education and practice, not all feel adequately prepared to engage with it."
)
# Section: Key Cross-Tab Analyses
doc.add_heading("2. Cross-Tab Insights", level=1)
doc.add_paragraph("• AI Familiarity vs. Perceived Importance:")
doc.add_paragraph(" - Students who are only somewhat familiar with AI rated its importance higher than those who were fully familiar.")
doc.add_paragraph("• AI Usage vs. Advocacy:")
doc.add_paragraph(" - Those who used AI were significantly more willing to advocate for its inclusion in education (62.5% vs 39.3%).")
doc.add_paragraph("• Year of Study vs. AI Outlook:")
doc.add_paragraph(" - Optimism about AI was highest among first-year students, and skepticism rose in mid to late years.")
doc.add_paragraph("• Ethical Concerns vs. Trust in AI:")
doc.add_paragraph(" - A strong inverse relationship exists between ethical concerns and trust in AI reliability.")
doc.add_paragraph("• Preparedness vs. Importance of AI in Education:")
doc.add_paragraph(" - Those who feel prepared are twice as likely to consider AI very important compared to those who don’t.")
# Section: Word Clouds
doc.add_heading("3. Textual Insights", level=1)
doc.add_paragraph("Thematic word clouds revealed key concerns and aspirations:")
doc.add_paragraph("• Benefits include simulation, interactivity, diagnostic aid, and efficiency.")
doc.add_paragraph("• Concerns focus on bias, job displacement, depersonalization, and data privacy.")
# Section: Correlation Heatmap
doc.add_heading("4. Correlation Heatmap of Attitudes", level=1)
doc.add_paragraph(
"Strong positive relationships exist among openness, trust, belief in AI's benefits, and future adoption. "
"Ethical concerns were inversely related to trust and openness."
)
# Section: Clustering Results
doc.add_heading("5. Clustering AI Attitudes", level=1)
doc.add_paragraph(
"Respondents were clustered into three distinct segments based on their attitude responses:"
)
doc.add_paragraph("• Cluster 0: High trust and openness, low ethical concern")
doc.add_paragraph("• Cluster 1: Neutral/moderate views")
doc.add_paragraph("• Cluster 2: Skeptical and ethically cautious")
# Conclusion
doc.add_heading("Conclusion & Recommendations", level=1)
doc.add_paragraph(
"Understanding student attitudes towards AI is crucial for curriculum planning. Preparedness correlates with positive perception, suggesting that focused educational modules can enhance adoption. Ethical discussions and transparent practices should be included to address skepticism."
)
# Save the document
doc_path = "C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/AI_Veterinary_Survey_Analysis_Report2.docx"
doc.save(doc_path)
doc_path
'C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/AI_Veterinary_Survey_Analysis_Report2.docx'
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import NMF
# Combine all benefit and concern responses into one dataset
open_ended_cols = [
"11. If you have any other potential benefits of AI in veterinary education please specify here",
"13. If you have any other concerns about AI in veterinary education please specify here",
"19. If you have any other potential benefits of AI in veterinary practice please specify here.1",
"21. If you have any other concerns with AI in veterinary practice please specify here"
]
combined_text = df[open_ended_cols].fillna("").astype(str).agg(" ".join, axis=1)
# Use TF-IDF to extract meaningful themes
vectorizer = TfidfVectorizer(max_df=0.95, min_df=2, stop_words="english")
tfidf = vectorizer.fit_transform(combined_text)
# Apply NMF to extract topics/themes
nmf_model = NMF(n_components=5, random_state=42)
nmf_model.fit(tfidf)
# Display top words for each theme
themes = {}
feature_names = vectorizer.get_feature_names_out()
for topic_idx, topic in enumerate(nmf_model.components_):
top_features = [feature_names[i] for i in topic.argsort()[:-11:-1]]
themes[f"Theme {topic_idx + 1}"] = top_features
themes
{'Theme 1': ['personalised', 'tutoring', 'learning', 'cheating', 'adaptive', 'systems', 'testing', 'genetic', 'interactive', 'livestock'], 'Theme 2': ['learning', 'reality', 'simulation', 'virtual', 'continuous', 'research', 'workflow', 'aid', 'efficiency', 'access'], 'Theme 3': ['ai', 'using', 'detecting', 'lack', 'things', 'rare', 'diseases', 'miss', 'interactive', 'help'], 'Theme 4': ['people', 'use', 'students', 'make', 'technology', 'equipment', 'expensive', 'extensive', 'knowledge', 'requires'], 'Theme 5': ['diagnosis', 'accuracy', 'development', 'treatment', 'decision', 'vets', 'come', 'differentials', 'make', 'depersonalisation']}
import matplotlib.pyplot as plt
# Convert themes into a DataFrame for easier plotting
import pandas as pd
themes_df = pd.DataFrame.from_dict(themes, orient='index').T
# Plot 1: Bar Plot showing word frequency across themes (appearances of top words)
word_counts = pd.Series([word for sublist in themes.values() for word in sublist]).value_counts()
plt.figure(figsize=(12, 6))
word_counts.plot(kind='bar')
plt.title("Top Word Frequency Across All Themes")
plt.ylabel("Frequency in Themes")
plt.xlabel("Words")
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
# Plot 2: Heatmap of themes vs. top words
theme_matrix = pd.DataFrame(0, index=themes_df.columns, columns=pd.unique(themes_df.values.ravel()))
for theme, words in themes.items():
for word in words:
theme_matrix.loc[theme, word] += 1
plt.figure(figsize=(10, 6))
sns.heatmap(theme_matrix, annot=True, cmap='YlGnBu', cbar=False)
plt.title("Heatmap: Themes vs. Associated Words")
plt.xticks(rotation=45, ha='right')
plt.yticks(rotation=0)
plt.tight_layout()
plt.show()
# Plot 3: Pie Chart - number of unique words per theme
theme_word_counts = {theme: len(set(words)) for theme, words in themes.items()}
plt.figure(figsize=(8, 8))
plt.pie(theme_word_counts.values(), labels=theme_word_counts.keys(), autopct='%1.1f%%', startangle=140)
plt.title("Proportion of Unique Words per Theme")
plt.axis('equal')
plt.tight_layout()
plt.show()
# Assign each response to the most dominant topic (theme) using the NMF model
dominant_theme_indices = nmf_model.transform(tfidf).argmax(axis=1)
# Count how many responses fall under each theme
theme_distribution = pd.Series(dominant_theme_indices).value_counts().sort_index()
theme_distribution.index = [f"Theme {i+1}" for i in theme_distribution.index]
# Plot theme importance by respondent count
plt.figure(figsize=(8, 5))
theme_distribution.plot(kind='bar', color='skyblue')
plt.title("Theme Importance Based on Respondent Association")
plt.xlabel("Theme")
plt.ylabel("Number of Responses")
plt.xticks(rotation=0)
plt.tight_layout()
plt.show()
theme_distribution
Theme 1 51 Theme 2 6 Theme 3 10 Theme 4 4 Theme 5 5 dtype: int64
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import classification_report, confusion_matrix
# Select relevant columns
features = df[[
"3. What year are you in?",
"5. Are you familiar with the concept of AI in Veterinary medicine?",
"7. Have you ever used a AI based platform or technology? (not necessarily veterinary related)",
"9. In your opinion, how important is it to incorporate AI into veterinary teaching and learning?",
"15. Do you feel adequately prepared to learn about AI in your veterinary education?",
"17. In your opinion how important is it to incorporate AI into veterinary practice?",
"26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice",
"26.8. I am concerned about the ethical implications of using AI in practice"
]]
target = df["16. Are you interested in advocating for the integration of AI into veterinary education?"]
# Encode features and target
features_encoded = features.apply(LabelEncoder().fit_transform)
target_encoded = LabelEncoder().fit_transform(target)
# Split dataset
X_train, X_test, y_train, y_test = train_test_split(features_encoded, target_encoded, test_size=0.3, random_state=42)
# Fit logistic regression model
model = LogisticRegression(max_iter=1000)
model.fit(X_train, y_train)
# Predict and evaluate
y_pred = model.predict(X_test)
report = classification_report(y_test, y_pred, output_dict=True)
conf_matrix = confusion_matrix(y_test, y_pred)
report, conf_matrix
({'0': {'precision': 0.8181818181818182, 'recall': 0.75, 'f1-score': 0.7826086956521738, 'support': 12}, '1': {'precision': 0.75, 'recall': 0.8181818181818182, 'f1-score': 0.7826086956521738, 'support': 11}, 'accuracy': 0.782608695652174, 'macro avg': {'precision': 0.7840909090909092, 'recall': 0.7840909090909092, 'f1-score': 0.7826086956521738, 'support': 23}, 'weighted avg': {'precision': 0.7855731225296444, 'recall': 0.782608695652174, 'f1-score': 0.782608695652174, 'support': 23}}, array([[9, 3], [2, 9]], dtype=int64))
[[9, 3], # 9 correct non-advocate, 3 false positives
[2, 9]] # 9 correct advocate, 2 false negatives
[[9, 3], [2, 9]]
import numpy as np
# Extract feature importances from logistic regression (using absolute values for clarity)
importance = np.abs(model.coef_[0])
feature_names = features.columns
# Create a bar plot of feature importances
plt.figure(figsize=(10, 6))
plt.barh(feature_names, importance, color='teal')
plt.xlabel("Importance (absolute coefficient)")
plt.title("Feature Importance in Predicting AI Advocacy")
plt.gca().invert_yaxis()
plt.tight_layout()
plt.show()
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# Train Random Forest classifier
rf_model = RandomForestClassifier(n_estimators=100, random_state=42)
rf_model.fit(X_train, y_train)
rf_pred = rf_model.predict(X_test)
# Evaluate performance
rf_accuracy = accuracy_score(y_test, rf_pred)
rf_report = classification_report(y_test, rf_pred, output_dict=True)
rf_conf_matrix = confusion_matrix(y_test, rf_pred)
# Test interaction effects manually: Add interaction terms to logistic regression model
# We'll use: Preparedness x Trust and Preparedness x Ethical Concern
interaction_df = features_encoded.copy()
interaction_df['Preparedness*Trust'] = (
features_encoded["15. Do you feel adequately prepared to learn about AI in your veterinary education?"] *
features_encoded["26.3. I trust the reliability and accuracy of AI systems for supporting clinical decision-making in veterinary practice"]
)
interaction_df['Preparedness*Ethics'] = (
features_encoded["15. Do you feel adequately prepared to learn about AI in your veterinary education?"] *
features_encoded["26.8. I am concerned about the ethical implications of using AI in practice"]
)
# Split again with interaction terms
X_train_i, X_test_i, y_train_i, y_test_i = train_test_split(interaction_df, target_encoded, test_size=0.3, random_state=42)
model_interactions = LogisticRegression(max_iter=1000)
model_interactions.fit(X_train_i, y_train_i)
inter_pred = model_interactions.predict(X_test_i)
# Evaluate interaction model
inter_accuracy = accuracy_score(y_test_i, inter_pred)
inter_report = classification_report(y_test_i, inter_pred, output_dict=True)
inter_conf_matrix = confusion_matrix(y_test_i, inter_pred)
rf_accuracy, rf_report, rf_conf_matrix, inter_accuracy, inter_report, inter_conf_matrix
(0.782608695652174, {'0': {'precision': 0.8181818181818182, 'recall': 0.75, 'f1-score': 0.7826086956521738, 'support': 12}, '1': {'precision': 0.75, 'recall': 0.8181818181818182, 'f1-score': 0.7826086956521738, 'support': 11}, 'accuracy': 0.782608695652174, 'macro avg': {'precision': 0.7840909090909092, 'recall': 0.7840909090909092, 'f1-score': 0.7826086956521738, 'support': 23}, 'weighted avg': {'precision': 0.7855731225296444, 'recall': 0.782608695652174, 'f1-score': 0.782608695652174, 'support': 23}}, array([[9, 3], [2, 9]], dtype=int64), 0.6956521739130435, {'0': {'precision': 0.7272727272727273, 'recall': 0.6666666666666666, 'f1-score': 0.6956521739130435, 'support': 12}, '1': {'precision': 0.6666666666666666, 'recall': 0.7272727272727273, 'f1-score': 0.6956521739130435, 'support': 11}, 'accuracy': 0.6956521739130435, 'macro avg': {'precision': 0.696969696969697, 'recall': 0.696969696969697, 'f1-score': 0.6956521739130435, 'support': 23}, 'weighted avg': {'precision': 0.6982872200263504, 'recall': 0.6956521739130435, 'f1-score': 0.6956521739130435, 'support': 23}}, array([[8, 4], [3, 8]], dtype=int64))
# Update the Word document with Random Forest comparison and interaction model findings
# Reopen the document
doc = Document("C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/AI_Veterinary_Survey_Analysis_Report2.docx")
# Add new section for Predictive Modeling Enhancements
doc.add_heading("6. Advanced Predictive Modeling: AI Advocacy", level=1)
doc.add_paragraph(
"To better understand which factors predict a respondent's willingness to advocate for AI in veterinary education, two predictive models were tested: "
"a Logistic Regression and a Random Forest classifier."
)
doc.add_heading("6.1 Model Comparison", level=2)
doc.add_paragraph(
"Both models achieved identical accuracy of 78.3%. Logistic Regression and Random Forest performed nearly equally across all metrics, "
"suggesting consistent predictive features such as trust in AI, preparedness to learn AI, and prior experience using AI technology."
)
doc.add_heading("6.2 Interaction Effects", level=2)
doc.add_paragraph(
"Interaction terms between preparedness and trust, as well as preparedness and ethical concern, were tested within a modified logistic model. "
"The interaction model achieved a slightly lower accuracy of 69.6%, indicating that while interaction effects might exist, more data would be "
"needed to reliably detect and model these relationships."
)
doc.add_paragraph(
"Overall, these results reinforce that the key predictors of AI advocacy include trust in AI reliability, perceived importance in practice, "
"and a feeling of readiness to learn about AI."
)
# Save updated report
updated_doc_path = "C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/AI_Veterinary_Survey_Analysis_Report3.docx"
doc.save(updated_doc_path)
updated_doc_path
'C:/Users/ODaramola1/OneDrive - UCLan/Documents/UoS Laptop/UoS Deskstop/ResearchProjects&DoctoralCollege/2023 - 2024 Yr 3 projects/new analysis - kay/AI_Veterinary_Survey_Analysis_Report3.docx'