← All Series
Complete 11/11 parts published

Python for Java Developers: From Streams to Tensors

A 10-part, example-driven Python series for experienced Java, C# and other mainstream developers heading into data science, machine learning and AI. It follows Arjun, a veteran Java architect at a payments company, as he is pulled into an ML fraud-detection initiative and has to become productive in Python fast. Each part maps what you already know to the Pythonic way, explains the critical mental-model shifts in depth, and builds toward NumPy, pandas, scikit-learn, PyTorch and LLM-era tooling — with runnable code, tips, tricks and the gotchas that bite Java people specifically.

0
Conceptual Complete

Python for Java Developers: From Streams to Tensors

A 10-part, example-driven Python series for seasoned Java and C# developers moving into data science, ML and AI. Follow Arjun, a Java architect pulled into a fraud-detection ML project, from culture shock to PyTorch.

1
Conceptual Complete

"The Culture Shock" — Names, Objects and the Runtime

Arjun's first Python code review goes badly. We cover how Python executes code, why variables are names bound to objects, mutability and aliasing, is vs ==, truthiness, numeric surprises, modules, and a proper project setup with uv.

2
Conceptual Complete

"Collections Without Ceremony" — Lists, Dicts, Sets and Comprehensions

The Streams API, translated. Lists, tuples, dicts and sets; slicing and unpacking; comprehensions as the idiomatic map/filter/collect; sorting with keys; and the collections module — Counter, defaultdict, deque — applied to transaction data.

3
Conceptual Complete

"Functions Are Values" — Arguments, Closures and Decorators

No more single-method interfaces. Positional, keyword, *args and **kwargs; the mutable-default trap; lambdas; closures and LEGB scoping; and decorators — Python's ten-line answer to Spring AOP — for timing, retries and caching.

4
Conceptual Complete

"Objects Without the Ceremony" — Classes, Dunders, Dataclasses and Protocols

Arjun writes a Java-style Transaction class with getters and setters and gets gently mocked. Properties, the Python data model (__repr__, __eq__, __hash__, __len__, __getitem__), @dataclass, class methods, inheritance, enums, and duck typing formalised with Protocol.

5
Conceptual Complete

"The Lazy River" — Iterators, Generators and Context Managers

A 40 GB transaction export will not fit in memory. The iterator protocol, generators and yield, lazy generator pipelines, itertools, exceptions and EAFP, pathlib and csv, and with-statements as Python's try-with-resources.

6
Conceptual Complete

"Types Strike Back" — Type Hints, Pydantic and Modern Tooling

Arjun misses his compiler. Type hints and what they do (and do not) do at runtime, generics, TypedDict, mypy, runtime validation with Pydantic, project layout with pyproject.toml, ruff, pytest and logging — the Maven-and-JUnit toolkit for Python.

7
Conceptual Complete

"Thinking in Arrays" — NumPy, Vectorisation and Broadcasting

Why the for loop is the enemy of numeric Python. The ndarray and its memory model, dtypes, vectorised operations, axes, boolean masks, broadcasting rules, views vs copies, NaN handling, random generators, and cosine-similarity search from scratch.

8
Conceptual Complete

"DataFrames for SQL Minds" — pandas in Practice

pandas explained through SQL. Series, DataFrames and the Index; selection with loc and iloc; filtering; groupby as GROUP BY and transform as a window function; merge as JOIN; time series and rolling windows; missing data; Copy-on-Write; and building a fraud feature table.

9
Project Complete

"The First Model" — scikit-learn, Pipelines and Honest Metrics

Sentinel's first fraud model. The estimator API, stratified train/test splits, Pipeline and ColumnTransformer, logistic regression vs random forests, why accuracy lies on imbalanced data, precision-recall and threshold tuning, cross-validation, data leakage, and persisting models.

10
Project Complete

"Into the Deep End" — PyTorch, Concurrency and the AI Toolkit

Tensors, autograd and a hand-written PyTorch training loop. Then the questions a Java architect asks: the GIL, threads vs processes, asyncio for fanning out LLM calls, embeddings and semantic search, validated structured output, and how Python models reach JVM services.