All articles

Machine Learning

Classic models built from first principles, with the maths derived and the code run on real data.

  1. Logistic Regression from First Principles: Log-Odds, Likelihood and the Decision Threshold

    41 min read

    Logistic regression is linear regression rebuilt for yes-or-no questions: a weighted sum of features pushed through a sigmoid, trained by maximum likelihood. This article derives it from an eight-point example, shows why the loss is log loss and why its gradient is so simple, trains it with gradient descent and Newton’s method you can steer, breaks it on separable data, and then uses it to diagnose breast tumours, where the interesting decisions are about thresholds and probabilities rather than weights.

    • Machine Learning
    • Logistic Regression
    • Classification
    • Statistics
    • Optimization
    • Python
    • scikit-learn
    • NumPy
  2. Linear Regression from First Principles: Least Squares, Geometry and Gradient Descent

    36 min read

    Fitting a straight line is the oldest trick in machine learning and still the one most worth understanding completely. This article builds linear regression from a five-point example to the normal equations, shows why least squares is a projection and a maximum-likelihood estimate at the same time, trains it with gradient descent you can steer, and then puts it to work on a real dataset to see where it holds up and where it breaks.

    • Machine Learning
    • Linear Regression
    • Statistics
    • Optimization
    • Gradient Descent
    • Python
    • scikit-learn
    • NumPy