Cover Material, Copyright, and License
Preface
- Book Cover
- About the Author
- Using the Example Code
- Acknowledgements
Python Development Environment
- Managing Python with uv
Part 1 - Machine Learning
“Classic” Machine Learning
- Example Material
- Classification Models using Scikit-learn
- Classic Machine Learning Wrap-up
- Optional Practice Problems
Regression and Clustering
- Regression: Predicting Housing Prices
- Clustering: Discovering Groups in Data
- Regression and Clustering Wrap-up
- Optional Practice Problems
Exploratory Data Analysis and Feature Engineering
- Exploratory Data Analysis
- Feature Engineering
- EDA and Feature Engineering Wrap-up
- Optional Practice Problems
Anomaly Detection
- The Wisconsin Breast Cancer Dataset
- Data Preprocessing
- Approach 1: Gaussian Statistical Detector
- Approach 2: Isolation Forest
- Running the Example
- Interpreting the Results
- Anomaly Detection Wrap-up
- Optional Practice Problems
Part 2 - Deep Learning
The Basics of Deep Learning
- Using PyTorch for Building a Cancer Prediction Model
- Optional Practice Problems
Natural Language Processing Using Deep Learning
- Hugging Face and the Transformers Library
- Comparing Sentences for Similarity Using Transformer Models
- Deep Learning Natural Language Processing Wrap-up
- Optional Practice Problems
Part IV - Overviews of Image Generation, Reinforcement Learning, and Recommendation Systems
Overview of Image Generation
- Image Generation Using Stable Diffusion and PyTorch
- Image Generation Using Google’s Imagen API
- Mini-DALL·E: A Lightweight Alternative
- Recommended Reading for Image Generation
- Optional Practice Problems
Categorical Deep Learning: From Axioms to Implementation using Category Theory
- The Para Category and Lens Composition
- Markov Categories and Stochastic Morphisms
- Invariance and Equivariance: Colimits in Geometry
- The Topos Framework: Subobject Classifiers and Sheaves
- Natural Transformations and Knowledge Distillation
- Categorical Deep Learning Wrap-up
- Optional Practice Problems
Overview of Reinforcement Learning (Optional Material)
- Overview
- Available RL Tools
- An Introduction to Markov Decision Process
- A Concrete Example: Q-Learning with Gymnasium
- Reinforcement Learning Wrap-up
- Optional Practice Problems
Overview of Recommendation Systems (Optional Material)
- TensorFlow Recommenders
- Recommendation Systems Wrap-up
Part 3 - Large Language Models
Introduction to Transformers and Large Language Models
- The Transformer Architecture
- Tokenization
- From Transformers to Large Language Models
- Key Capabilities of Modern LLMs
- Practical Considerations
LLMs with Public APIs
- Setup and Authentication
- Text Generation
- Thinking Models
- Multi-Turn Conversations
- Multimodal Input: Analyzing Images
- Web Search with LLMs
- Structured Output
- Practical Considerations
- Summary
- Optional Practice Problems
LLMs with Local Models
- Installing Ollama
- Downloading and Running Models
- Using Ollama from Python
- Reasoning with Local Models
- Conversation Memory with Ollama
- Prompt Caching for Performance
- Image to Text Description (Vision Models)
- OpenAI-Compatible API
- Alternative Tools for Running Local Models
- Hardware Considerations
- Summary
- Optional Practice Problems
Text Adventure Game with an LLM Game Master
- How It Works
- The System Prompt
- The Game Engine
- Playing the Game
- Customizing Your Adventure
- Why This Matters
- Running the Example
- Summary
Semantic Web Question Answering with SPARQL and Large Language Models
- A Live Example to Motivate the Reader
- What This Program Does
- The Semantic Web and RDF
- SPARQL Query Language
- The Shared Library:
library.py - Example 1: DBpedia (
DBPedia.py) - Example 2: Wikidata (
Wikidata.py) - Example 3: Combined DBpedia + Wikidata (
DBPedia_and_Wikidata.py) - Running the Code
- Example Queries
- Troubleshooting
- Exercises
- Further Reading
Part 4 - Symbolic AI and Knowledge Representation
Symbolic AI
- Comparison of Symbolic AI and Deep Learning
- Implementing Frame Data Structures in Python
- Use Predicate Logic by Calling Swi-Prolog
- Swi-Prolog and Python Deep Learning Interop
- Soar Cognitive Architecture
- Constraint Programming with MiniZinc and Python
- Good Old Fashioned Symbolic AI Wrap-up
- Optional Practice Problems
Expert Systems Using the Rete Algorithm
- 1. Rete Engine Architecture & Design
- 2. Implementing the Trickier Parts of Rete
- 3. Case Studies & Design Advice
- Wrap Up
- Optional Practice Problems
A Chess Engine and AI Player in Pure Python
- Architecture Overview
- Board Representation
- Precomputed Move Tables
- The Move Class
- Move Generation
- Make Move and Unmake Move
- Zobrist Hashing
- Evaluation
- Search: Negamax with Alpha-Beta Pruning
- The Transposition Table
- Quiescence Search
- Move Ordering
- Iterative Deepening
- The Interactive CLI
- Testing with Perft
- Playing Against the Bot
- Running the Example
- Why This Matters
- Summary
Part 5 - Knowledge Representation
Getting Setup To Use Graph and Relational Databases
- Querying Wikidata with SPARQL and Python
- The SQLite Relational Database for Knowledge Representation
- Optional Practice Problems
Optional Material: A Deeper Dive Into Semantic Web and Linked Data
- Overview and Theory
Open Knowledge Format (OKF) for Human-Agent Systems
- References & Inspiration
- What is Open Knowledge Format (OKF)?
- Sample Knowledge Bundle Structure
- Python Architecture: The OKF Explorer
- Example Output
- Wrap Up
- Optional Practice Problems