Practice Streamlit basics and build a small interactive task board in three short Python lab scripts (no notebooks), plus an end-to-end ML → API → Streamlit exercise.
- Python 3.11 recommended (optional):
pyenv local 3.11.3 - Create/activate a virtual environment:
- macOS/Linux:
python -m venv .venv && source .venv/bin/activate - Windows (PowerShell):
python -m venv .venv && .venv\\Scripts\\Activate.ps1
- macOS/Linux:
- Install deps:
pip install --upgrade pip && pip install -r requirements.txt
- 01_streamlit_fundamentals.py — First steps with Streamlit, page layout, text, inputs, and reruns.
- 02_streamlit_widgets_state.py — Forms, session state, callbacks, and handling user input.
- 03_streamlit_data_app.py — Building a simple data app with tables, filtering, and tidy UI patterns.
- main.py — Task-board app that combines the lab patterns (add/filter/complete/delete tasks).
- ml_api_demo/ — Self-contained ML → API → Streamlit exercise (notebook + redundant script for headless retraining):
- 04_train_and_save_model.ipynb — Train and save a simple iris classifier (produces
ml_api_demo/artifacts/iris_model.joblib). - train_model.py — Script alternative to produce the same artifact without notebooks.
- model_api.py — FastAPI service that loads the saved model and exposes
/predict. - streamlit_api_client.py — Streamlit UI to call the API and view predictions.
- More detail: see ml_api_demo/README.md.
- 04_train_and_save_model.ipynb — Train and save a simple iris classifier (produces
- Fundamentals:
streamlit run 01_streamlit_fundamentals.py - Widgets + State:
streamlit run 02_streamlit_widgets_state.py - Data App:
streamlit run 03_streamlit_data_app.py - Task board demo:
streamlit run main.py
- Train and save the model
- Notebook: run
ml_api_demo/04_train_and_save_model.ipynb - Script:
python ml_api_demo/train_model.py - Output:
ml_api_demo/artifacts/iris_model.joblib
- Notebook: run
- Start the API
uvicorn ml_api_demo.model_api:app --reload --port 8001- Test:
curl -X POST http://127.0.0.1:8001/predict \ -H "Content-Type: application/json" \ -d '{"sepal_length":5.1,"sepal_width":3.5,"petal_length":1.4,"petal_width":0.2}'
- Query from Streamlit
streamlit run ml_api_demo/streamlit_api_client.py- Point the client at
http://127.0.0.1:8001and send predictions.