Skip to content

UofT-DSI | python - Assignment 2#2

Open
akorade wants to merge 2 commits intomainfrom
assignment-2
Open

UofT-DSI | python - Assignment 2#2
akorade wants to merge 2 commits intomainfrom
assignment-2

Conversation

@akorade
Copy link
Owner

@akorade akorade commented Dec 2, 2025

Added code to read and print data from the first inflammation file with error handling for missing files. Implemented the patient_summary function to compute mean, max, and min using numpy, and updated detect_problems to warn if any patient has a mean inflammation of 0. Updated notebook metadata to reflect the current Python environment.

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

I implemented three main functions for analyzing arthritis drug efficacy data:

  • Question 1: Read and display CSV file contents using file handling (readlines())
  • Question 2: Created patient_summary() function to calculate mean, max, or min inflammation statistics for 60 patients across 40 days using NumPy
  • Question 3: Developed detect_problems() function to identify data irregularities by detecting patients with mean inflammation scores of 0

What did you learn from the changes you have made?

  • How to use Python's file handling with open(), with statements, and readlines() method
  • How to leverage NumPy for efficient array operations (np.loadtxt(), np.mean(), np.max(), np.min())
  • The importance of specifying the correct axis (axis=1) when performing operations on 2D arrays to operate row-wise (per patient)
  • How to chain functions together (patient_summary() → check_zeros()) to build more complex data validation logic
  • Error handling with try-except blocks for robust file operations

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

For Question 1, I could have used the csv module instead of readlines():

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

NA

How were these changes tested?

I tested all changes locally using Jupyter Notebook in Visual Studio Code

A reference to a related issue in your repository (if applicable)

NA

Checklist

  • I can confirm that my changes are working as intended

Added code to read and print data from the first inflammation file with error handling for missing files. Implemented the patient_summary function to compute mean, max, and min using numpy, and updated detect_problems to warn if any patient has a mean inflammation of 0. Updated notebook metadata to reflect the current Python environment.
Copy link

@efantinatti efantinatti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @akorade Q1 is OK. Q2 you may consider running max and mean. Q3 you may also consider testing all the files and see which of them you get the True values.

Best,
E. Fantinatti

Enhanced the test code to check min, max, and mean array lengths for patient data. Updated the detect_problems test to execute for all the input files
@akorade
Copy link
Owner Author

akorade commented Dec 11, 2025

Quote reply

@efantinatti Added the test scenarios

@akorade akorade requested a review from efantinatti December 11, 2025 15:33
@efantinatti
Copy link

efantinatti commented Dec 11, 2025

Hi @akorade I can't see the aforementioned changes in this commit 42ba07d

@efantinatti

image

@akorade
Copy link
Owner Author

akorade commented Dec 11, 2025

@efantinatti Could you please reconfirm?

Copy link

@efantinatti efantinatti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akorade I can see your changes now. All good. You can merge it to main.

Best
@efantinatti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants