Skip to content

UofT-DSI | DSI | - Assignment 2#383

Open
zaf-tech wants to merge 5 commits into
UofT-DSI:mainfrom
zaf-tech:assignment-2
Open

UofT-DSI | DSI | - Assignment 2#383
zaf-tech wants to merge 5 commits into
UofT-DSI:mainfrom
zaf-tech:assignment-2

Conversation

@zaf-tech

Copy link
Copy Markdown

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

Completed the three required parts of assignment_2.ipynb:

  1. Read inflammation_01.csv with readlines() and printed each row.
  2. Implemented patient_summary(file_path, operation) using np.loadtxt + np.mean/np.max/np.min with axis=1 to summarize each of the 60 patients' 40-day flare-up counts.
  3. Implemented detect_problems(file_path), which calls patient_summary(file_path, 'mean') and passes the result to the provided check_zeros() helper.

What did you learn from the changes you have made?

How NumPy's axis parameter controls whether a reduction (mean/max/min) is applied per-row vs per-column — axis=1 was needed here to get one summary value per patient (row) rather than per day (column). Also reinforced composing small functions (patient_summarydetect_problems) instead of duplicating logic.

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

Could have used pandas.read_csv + DataFrame.mean(axis=1) instead of np.loadtxt. Stuck with NumPy since that's what the assignment hints and course slides (10_numpy) pointed to, and it avoids adding a pandas dependency for a one-off summary.

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

My local assignment-2 branch had drifted from a stale remote branch with an older solution attempt; I reset it to start clean from main. Separately, this repo's root pyproject.toml pulls in a large, unrelated dependency set (deploying-ai-env) that fails to build on this machine's Python version, so uv run at the project root couldn't execute the notebook. I worked around it by running jupyter nbconvert --execute in an isolated environment (uv run --no-project --with numpy --with nbconvert --with ipykernel) so I could verify the notebook end-to-end without touching the project's dependency file.

How were these changes tested?

Executed the full notebook non-interactively via jupyter nbconvert --to notebook --execute and confirmed the real outputs:

  • Cell 1 prints all 60 rows of inflammation_01.csv.
  • len(patient_summary(all_paths[0], 'min'))60, as required.
  • detect_problems(all_paths[0])False, matching the expected result.

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

Checklist

  • I can confirm that my changes are working as intended

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.

1 participant