Convert Figma logo to code with AI

probml logopml-book

"Probabilistic Machine Learning" - a book series by Kevin Murphy

4,905
587
4,905
6

Top Related Projects

12 weeks, 26 lessons, 52 quizzes, classic Machine Learning for all

A series of Jupyter notebooks that walk you through the fundamentals of Machine Learning and Deep Learning in Python using Scikit-Learn, Keras and TensorFlow 2.

The "Python Machine Learning (3rd edition)" book code repository

Notebooks and code for the book "Introduction to Machine Learning with Python"

Python Data Science Handbook: full text in Jupyter Notebooks

21,699

The fastai book, published as Jupyter Notebooks

Quick Overview

The probml/pml-book repository contains the source code and resources for the book "Probabilistic Machine Learning" by Kevin Murphy. This repository serves as a companion to the book, providing code implementations, examples, and supplementary materials for the concepts discussed in the text.

Pros

  • Comprehensive collection of code examples and implementations for probabilistic machine learning concepts
  • Regularly updated with new content and improvements
  • Provides a practical resource for readers to experiment with and understand the book's concepts
  • Includes Jupyter notebooks for interactive learning and exploration

Cons

  • May require a strong background in mathematics and machine learning to fully utilize
  • Some implementations might be complex for beginners
  • Occasional inconsistencies in coding style across different contributors
  • Limited documentation for some of the more advanced topics

Code Examples

# Example 1: Gaussian mixture model
from sklearn.mixture import GaussianMixture
import numpy as np

X = np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])
gmm = GaussianMixture(n_components=2, random_state=42)
gmm.fit(X)

This example demonstrates how to fit a Gaussian mixture model using scikit-learn.

# Example 2: Bayesian linear regression
import pymc3 as pm
import numpy as np

X = np.random.randn(100, 1)
y = 2 * X + 0.5 * np.random.randn(100, 1)

with pm.Model() as model:
    alpha = pm.Normal('alpha', mu=0, sd=10)
    beta = pm.Normal('beta', mu=0, sd=10)
    sigma = pm.HalfNormal('sigma', sd=1)
    
    mu = alpha + beta * X
    y_obs = pm.Normal('y_obs', mu=mu, sd=sigma, observed=y)
    
    trace = pm.sample(1000, tune=1000)

This example shows how to perform Bayesian linear regression using PyMC3.

# Example 3: Hidden Markov Model
import pomegranate as pg

model = pg.HiddenMarkovModel.from_samples(
    pg.NormalDistribution,
    n_components=2,
    X=[[0.1], [0.5], [1.2], [-0.3], [2.3]]
)

print(model.log_probability([[0.1], [0.5], [1.2]]))

This example demonstrates how to create and use a Hidden Markov Model with pomegranate.

Getting Started

To get started with the probml/pml-book repository:

  1. Clone the repository:

    git clone https://github.com/probml/pml-book.git
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Navigate to the desired chapter or example folder and run the Jupyter notebooks or Python scripts:

    jupyter notebook
    
  4. Explore the code examples and experiment with the implementations to deepen your understanding of probabilistic machine learning concepts.

Competitor Comparisons

12 weeks, 26 lessons, 52 quizzes, classic Machine Learning for all

Pros of ML-For-Beginners

  • More beginner-friendly with a structured curriculum
  • Includes hands-on projects and quizzes for practical learning
  • Covers a wider range of ML topics, including ethics and real-world applications

Cons of ML-For-Beginners

  • Less in-depth coverage of advanced mathematical concepts
  • Focuses more on practical implementation rather than theoretical foundations
  • May not be as suitable for readers seeking a comprehensive academic reference

Code Comparison

ML-For-Beginners example (Python):

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LogisticRegression()
model.fit(X_train, y_train)

pml-book example (Python):

import jax.numpy as jnp
from jax import grad, jit
def loss(params, X, y):
    return jnp.mean((X @ params - y)**2)
grad_loss = jit(grad(loss))

The ML-For-Beginners code demonstrates a more practical approach using scikit-learn, while the pml-book code showcases a more advanced implementation using JAX for automatic differentiation and just-in-time compilation.

A series of Jupyter notebooks that walk you through the fundamentals of Machine Learning and Deep Learning in Python using Scikit-Learn, Keras and TensorFlow 2.

Pros of handson-ml2

  • More practical, hands-on approach with code examples and exercises
  • Covers a wider range of machine learning topics, including deep learning
  • Regularly updated with new content and improvements

Cons of handson-ml2

  • Less theoretical depth compared to pml-book
  • Focuses primarily on scikit-learn and TensorFlow, limiting exposure to other libraries
  • May not be as suitable for advanced machine learning researchers

Code Comparison

pml-book example:

def gaussian_pdf(x, mu, sigma):
    return (1 / (sigma * np.sqrt(2 * np.pi))) * np.exp(-0.5 * ((x - mu) / sigma)**2)

handson-ml2 example:

from sklearn.ensemble import RandomForestClassifier

forest_clf = RandomForestClassifier(n_estimators=100, random_state=42)
forest_clf.fit(X_train, y_train)

The pml-book example demonstrates a more theoretical approach by implementing a Gaussian probability density function, while the handson-ml2 example shows a practical application using scikit-learn to create and train a Random Forest classifier.

The "Python Machine Learning (3rd edition)" book code repository

Pros of python-machine-learning-book-3rd-edition

  • More focused on practical implementation with Python
  • Includes detailed explanations of code examples
  • Covers a wide range of machine learning algorithms and techniques

Cons of python-machine-learning-book-3rd-edition

  • Less emphasis on theoretical foundations and mathematical concepts
  • May not cover some advanced topics in as much depth as pml-book
  • Primarily focuses on scikit-learn and TensorFlow, potentially limiting exposure to other libraries

Code Comparison

python-machine-learning-book-3rd-edition:

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1, stratify=y)
sc = StandardScaler()
X_train_std = sc.fit_transform(X_train)
X_test_std = sc.transform(X_test)

pml-book:

import jax.numpy as jnp
from jax import grad, jit

def loss(params, X, y):
    return jnp.mean((X @ params - y) ** 2)

grad_loss = jit(grad(loss))
params = jnp.zeros(X.shape[1])

The code examples highlight the different focus areas of the two repositories. python-machine-learning-book-3rd-edition emphasizes practical implementation using popular libraries like scikit-learn, while pml-book demonstrates more low-level implementations using JAX for advanced optimization techniques.

Notebooks and code for the book "Introduction to Machine Learning with Python"

Pros of introduction_to_ml_with_python

  • More beginner-friendly, with a focus on practical implementation
  • Includes hands-on examples using popular libraries like scikit-learn
  • Covers a wide range of ML topics in a concise manner

Cons of introduction_to_ml_with_python

  • Less comprehensive coverage of advanced ML concepts
  • Fewer mathematical explanations and theoretical foundations
  • Limited focus on deep learning and neural networks

Code Comparison

introduction_to_ml_with_python:

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, random_state=0)
knn = KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)

pml-book:

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal

def plot_gaussian_ellipsoid(mu, Sigma, ax=None, **kwargs):
    n = mu.shape[0]
    if ax is None:
        fig, ax = plt.subplots()
    x = np.linspace(-2, 2, 100)
    y = np.linspace(-2, 2, 100)
    X, Y = np.meshgrid(x, y)

Python Data Science Handbook: full text in Jupyter Notebooks

Pros of PythonDataScienceHandbook

  • More beginner-friendly, with a focus on practical applications
  • Covers a broader range of data science topics, including data visualization and manipulation
  • Includes interactive Jupyter notebooks for hands-on learning

Cons of PythonDataScienceHandbook

  • Less in-depth coverage of machine learning algorithms and theory
  • May not be as suitable for advanced users or researchers
  • Content may become outdated more quickly due to its focus on specific libraries

Code Comparison

PythonDataScienceHandbook:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()

pml-book:

import jax.numpy as jnp
from jax import grad, jit

def f(x):
    return jnp.sum(jnp.sin(x))

grad_f = jit(grad(f))
x = jnp.array([1.0, 2.0, 3.0])
print(grad_f(x))

The PythonDataScienceHandbook example focuses on data visualization using NumPy and Matplotlib, while the pml-book example demonstrates more advanced concepts like automatic differentiation using JAX.

21,699

The fastai book, published as Jupyter Notebooks

Pros of fastbook

  • More interactive and hands-on approach with Jupyter notebooks
  • Focuses on practical implementation using the fastai library
  • Includes real-world examples and case studies

Cons of fastbook

  • Limited coverage of theoretical foundations compared to pml-book
  • Primarily centered around the fastai ecosystem, potentially limiting broader applicability
  • Less comprehensive in covering a wide range of machine learning topics

Code Comparison

pml-book:

import numpy as np
import matplotlib.pyplot as plt

def plot_gaussian(mu, sigma):
    x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100)
    plt.plot(x, stats.norm.pdf(x, mu, sigma))
    plt.title(f"Gaussian (μ={mu}, σ={sigma})")
    plt.show()

fastbook:

from fastai.vision.all import *

path = untar_data(URLs.PETS)/'images'
def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
    path, get_image_files(path), valid_pct=0.2, seed=42,
    label_func=is_cat, item_tfms=Resize(224))

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

"Probabilistic machine learning": a book series by Kevin Murphy

 

Book 0: "Machine Learning: A Probabilistic Perspective" (2012)

See this link

Book 1: "Probabilistic Machine Learning: An Introduction" (2022)

See this link

Book 2: "Probabilistic Machine Learning: Advanced Topics" (2023)

See this link