Skip to content

studyalwaysbro/python-learning-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Learning Lab

Curated educational Python examples rebuilt from older personal scripts, coursework experiments, and standalone prototypes.

This repository is intentionally selective. The goal is to keep the best ideas, rewrite them cleanly, remove brittle local assumptions, and make the examples easier to learn from.

What This Repo Is

  • A cleaned educational lab covering calculus, linear algebra, finance, time series, streaming, and text processing
  • A portfolio-friendly archive of reusable, self-contained examples
  • A safe rewrite of older scripts with secrets, API keys, and local-path assumptions removed

What This Repo Is Not

  • A production trading system or financial guidance
  • A dump of every historical experiment
  • A promise that every model here is statistically sound for live use

Structure

python-learning-lab/
├── src/learning_lab/
│   ├── calculus/           # Numerical integration
│   ├── finance/            # Monte Carlo, correlation, GARCH
│   ├── linear_algebra/     # PCA walkthrough
│   ├── streaming/          # Kafka + Spark examples
│   ├── text/               # LaTeX to plaintext
│   └── time_series/        # SARIMA workflow
├── notebooks/              # Jupyter notebook walkthroughs
├── docs/
│   └── curation_notes.md   # What was kept, rewritten, or dropped
├── inventories/            # Classification CSVs for source files
├── pyproject.toml
├── LICENSE
└── README.md

Modules

Module Description
calculus/riemann_sum_demo.py Midpoint Riemann sums with exact integral comparison
linear_algebra/pca_walkthrough.py Step-by-step PCA on a tiny two-feature dataset
finance/monte_carlo_gbm.py Geometric Brownian Motion simulation (CSV or synthetic data)
finance/correlation_heatmap.py Correlation heatmap from adjusted-close price data
finance/garch_t_simulation.py GARCH(1,1) volatility forecast with Student-t Monte Carlo
streaming/kafka_price_producer.py Kafka producer for streaming price events from CSV
streaming/kafka_social_producer.py Kafka producer for social text events from JSONL
streaming/spark_social_sentiment_stream.py Spark Structured Streaming with VADER sentiment
text/latex_to_plaintext.py Strip common LaTeX commands into readable text
time_series/sarima_workflow.py Train/test SARIMA workflow with holdout evaluation

Getting Started

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Run modules directly:

# Calculus — no extra dependencies
python -m learning_lab.calculus.riemann_sum_demo --plot

# PCA — no extra dependencies
python -m learning_lab.linear_algebra.pca_walkthrough

# Monte Carlo — uses synthetic data by default
python -m learning_lab.finance.monte_carlo_gbm --sims 500 --plot

# With a CSV of historical prices
python -m learning_lab.finance.monte_carlo_gbm --csv prices.csv --plot

Optional Dependencies

Some modules need additional packages, installable via extras:

pip install -e ".[finance]"       # yfinance, seaborn, scipy
pip install -e ".[timeseries]"    # statsmodels, scikit-learn
pip install -e ".[volatility]"    # arch (for GARCH)
pip install -e ".[streaming]"     # confluent-kafka, pyspark, nltk

Streaming Prerequisites

The Kafka and Spark examples are reference implementations that require running infrastructure. They are included as educational reading and as templates, not as standalone demos. To run them you need:

  • A running Kafka broker (default: localhost:9092)
  • Apache Spark (for the Spark Structured Streaming example)
  • Sample CSV/JSONL data files matching the expected schemas

Provenance

This repo was curated from:

  • ~/projects/legacy-python-scripts — older personal Python experiments
  • ~/Documents/Stevens-MS-Math — graduate coursework scripts
  • A small number of home-directory utility scripts

The full classification of every source file (keep, rewrite, archive, drop) is recorded in:

License

MIT

About

Curated educational Python examples: calculus, linear algebra, finance, streaming, time series

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors