Skip to main content

Textbook ML/AI algorithms (Bishop PRML + Norvig AIMA) backed by established libraries as subroutines

Project description

mlai-textbooks

pip install mlai-textbooksimport 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlai_textbooks-0.1.0.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlai_textbooks-0.1.0-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file mlai_textbooks-0.1.0.tar.gz.

File metadata

  • Download URL: mlai_textbooks-0.1.0.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for mlai_textbooks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f2839f0f964fd51a957e5e054d6a655111ea59aa30618e9338c8938207c2190
MD5 ebac9c48d905938cddcbdff727582971
BLAKE2b-256 f72b3584cf7596df75ea56bee022b158ac500fa710334292487ec855492157a7

See more details on using hashes here.

File details

Details for the file mlai_textbooks-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mlai_textbooks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for mlai_textbooks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97c8ae763ac12b08eedda4131fdff1b7e1b6ed7828a91c57995c49d7a331ddfd
MD5 174528f4afb5b13d0c1746ae7314778b
BLAKE2b-256 074c1701047ca177b2f50beefe34e50a359dc10e5de8135a596a2aa4dbbfc595

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page