Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Infant Feeding Pattern Analysis

A small, self-contained data-analysis project that takes a CSV of infant feeding records and produces interpretable visualizations of feeding patterns over time of day and across months. Started as a personal project to make sense of my own baby's feeding log; rebuilt here as a portfolio piece for messy real-world time-series data wrangling in pandas.

Author: Osmanjan Timtura, Ph.D. · LinkedIn · GitHub


Headline result

The repo ships with two synthetic feeding datasets so the pipeline runs out of the box. Running the analysis on data/sample_breast_milk.csv (5 months of records, July–November 2022) produces:

Average feeding amount by hour-of-day, across months

The plot is dense with biological signal:

  • A late-night feed at ~2am is visible in every month — most newborns wake to eat once overnight.
  • A 5am dip (no feedings) — the typical longest sleep stretch.
  • Daytime feedings are roughly hourly with amounts averaging 0.5–1.5 oz per hour.
  • Each month's curve sits slightly higher than the previous month — visible growth: the same baby is taking in more milk per feeding as it ages.

And the daily-total view:

Daily feeding total over time

The 7-day rolling mean (red) shows daily intake growing from ~13 oz/day at 1 month old to ~28 oz/day at 5 months old — a clean monotonic trend buried in day-to-day noise. This is exactly the kind of signal that simple aggregation reveals and that staring at the raw CSV does not.


What this project demonstrates

For a comp-bio / data-science portfolio, this is the "I can wrangle messy real-world time-series data with pandas" piece. Specifically:

  • Timestamp parsing from human-written CSV ("7/14/22 7:30 AM" format) into proper pandas datetime64.
  • Two-level groupby aggregation (month × hour-of-day) to compute per-bin averages with denominators that match the actual data structure (per-day, not per-record).
  • Two views of the same data: hour-of-day pattern within each month, and daily-total trend across the whole record.
  • A rolling mean layered onto a daily series to separate signal from day-to-day noise.
  • Synthetic-data generator that mimics realistic priors (longer night intervals, growth-per-month, occasional missed-log days) so the repo is reproducible without sharing real personal data.
  • Tests that verify the aggregation math on a hand-checkable small input.
  • CLI + library + notebook entry points so the code is usable three ways.

Reproducing the analysis

git clone https://github.com/OsmanjanTimtura/baby-feeding-trend.git
cd baby-feeding-trend
pip install -r requirements.txt

# Regenerate the synthetic sample CSVs (already committed, but rerun if needed)
python -m src.generate_sample

# Run the analysis with daily-total plot included
python -m src.feeding data/sample_breast_milk.csv --out figures/trend.png --daily

# Plot only specific months
python -m src.feeding data/sample_breast_milk.csv --months 2022-07 2022-11 --out figures/jul_nov.png

Total runtime: under 2 seconds on a laptop. No GPU, no model download.

Use with your own data

The pipeline accepts any CSV with two columns:

Column Format Example
Time Date + 12-hour time + AM/PM 7/14/22 7:30 AM
Amount (oz.) Numeric ounces per feeding 2.5

(Older Time and Amount (oz.) column names are kept for backward compatibility with feeding-tracker app exports. The pipeline renames them internally to timestamp and amount_oz.)

from src.feeding import load_feeding_csv, plot_monthly_trends

df = load_feeding_csv("data/my_baby.csv")
plot_monthly_trends(df, output="figures/my_trend.png")

Repository layout

baby-feeding-trend/
├── README.md                          (this file)
├── requirements.txt
├── LICENSE                            (MIT)
├── .gitignore
├── src/
│   ├── __init__.py
│   ├── feeding.py                     (main analysis pipeline)
│   └── generate_sample.py             (creates synthetic test data)
├── data/
│   ├── sample_breast_milk.csv         (5 months synthetic data, 1051 records)
│   └── sample_formula.csv             (4 months synthetic data, 727 records)
├── figures/
│   ├── feeding_trend_breast_milk.png  (headline figure)
│   └── daily_total.png                (growth-over-time plot)
├── notebooks/
│   └── feeding_demo.ipynb             (interactive walkthrough)
└── tests/
    └── test_feeding.py                (pytest unit tests)

Tools

Python 3.10+ · pandas · numpy · matplotlib · pytest

A note on privacy

The original version of this project ran on records of my own child. For the portfolio version, that data is replaced with a synthetic generator (src/generate_sample.py) that produces realistic-looking records using documented priors (feeding intervals, amount growth per month, miss-day probability). The synthetic data lets anyone reproduce the analysis end-to-end without me sharing private records.

Provenance

The first version of this script was a personal exploratory project written in Python in 2023 to analyze a CSV exported from a baby-tracking app. The current portfolio version is a refactor: pandas-idiomatic aggregation replaces the original manual hour-of-day if/elif chains, a CLI replaces hardcoded file paths, and synthetic data replaces the real records. The original analysis question — "how do this baby's feeding patterns change over months?" — remains the same.

License

MIT License — reuse freely.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages