Skip to main content

mlai-textbooks

pip install mlai-textbooks → import ml_ai_library

Textbook ML/AI algorithms from Bishop PRML and Norvig AIMA — every algorithm delegates to an established library as its numerical engine. No hand-rolled subroutines.

Module Algorithms Backed by
bishop.linear_models Bayesian LR, Logistic IRLS, RVM sklearn, numpy
bishop.sampling Rejection, Importance, MH, Gibbs, Ensemble MCMC emcee, scipy
bishop.sequential Kalman Filter, RTS Smoother, Particle Filter scipy.linalg, numpy
bishop.mixture_models GMM, Bayesian GMM, K-Means sklearn
bishop.dimensionality PCA, Kernel PCA, Factor Analysis, t-SNE sklearn
bishop.kernel_methods GP Regression, SVM, Kernel PCA sklearn
bishop.neural_networks MLP, CNN, RNN, VAE, GAN PyTorch
norvig.search BFS, DFS, IDDFS, UCS, A*, Greedy, Beam networkx
norvig.csp Backtracking, AC-3 python-constraint2
norvig.logic PropKB (TELL/ASK), Unify, FOL-BC sympy
norvig.adversarial Minimax, Alpha-Beta, MCTS mcts
norvig.mdp Value Iteration, Policy Iteration numpy
norvig.nlp N-Gram LM, CYK Parser, Viterbi POS nltk
norvig.game_theory Nash Equilibria, Maximin, Dominant Strategy nashpy
norvig.planning STRIPS, HTN Planning (pure Python)
norvig.rl Q-Learning, SARSA, REINFORCE gymnasium, PyTorch
llm_agents.* ReAct, Planning, Logic, RL-Policy, Multi-Agent litellm

Quick Start

# A* search using networkx internally
from ml_ai_library.norvig.search import GraphProblem, astar_search
import networkx as nx
G = nx.DiGraph()
G.add_edge('A', 'B', weight=1); G.add_edge('B', 'C', weight=2)
node = astar_search(GraphProblem(G, 'A', 'C'))
print(node.solution())   # ['B', 'C']

# Nash equilibria via nashpy
from ml_ai_library.norvig.game_theory import NormalFormGame, nash_equilibria
import numpy as np
game = NormalFormGame(np.array([[3,0],[5,1]]), np.array([[3,5],[0,1]]))
print(nash_equilibria(game))

# Ensemble MCMC via emcee
from ml_ai_library.bishop.sampling import emcee_sample
samples = emcee_sample(lambda x: -0.5 * x @ x, ndim=2, n_steps=500)

# Kalman filter via scipy.linalg
from ml_ai_library.bishop.sequential import KalmanFilter
import numpy as np
kf = KalmanFilter(F=np.eye(2), H=np.eye(2),
                  Q=0.01*np.eye(2), R=0.1*np.eye(2),
                  x0=np.zeros(2), P0=np.eye(2))
means, covs = kf.filter(observations)

# LLM ReAct agent
from ml_ai_library.llm_agents.react_agent import ReActAgent
agent = ReActAgent(model="gpt-4o-mini")
print(agent.run("What is 2+2?"))

License

MIT

Metadata

Release files for mlai-textbooks 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlai-textbooks 0.1.0
File Size Uploaded
mlai_textbooks-0.1.0.tar.gz 43.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mlai-textbooks 0.1.0
File Interpreter ABI Platform
mlai_textbooks-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 94.3 kB

Release files / mlai_textbooks-0.1.0.tar.gz

Download URL mlai_textbooks-0.1.0.tar.gz
Size 43.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5f2839f0f964fd51a957e5e054d6a655111ea59aa30618e9338c8938207c2190
BLAKE2b-256 checksum
How to use checksums
f72b3584cf7596df75ea56bee022b158ac500fa710334292487ec855492157a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / mlai_textbooks-0.1.0-py3-none-any.whl

Download URL mlai_textbooks-0.1.0-py3-none-any.whl
Size 50.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97c8ae763ac12b08eedda4131fdff1b7e1b6ed7828a91c57995c49d7a331ddfd
BLAKE2b-256 checksum
How to use checksums
074c1701047ca177b2f50beefe34e50a359dc10e5de8135a596a2aa4dbbfc595
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page