Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Machine Learning Foundations for LLM Work

Free · sign in to start and track progress

1 · Learning from data

  • 1Problems, data and baselines
  • 2Train, validation, test and leakage
  • 3Loss functions and gradient descent

2 · Classifiers and generalisation

  • 4Logistic regression, step by step

    Exercise answers

    • Answer: Logistic regression in numpy, matched against scikit-learn
    • Answer: Softmax cross-entropy and a numerical gradient check
  • 5Metrics, thresholds and calibration
  • 6Overfitting, regularisation and cross-validation

3 · The maths the later courses assume

  • 7Probability for evaluation
  • 8Standard errors, intervals and paired tests
  • 9Vectors, dot products and embeddings
  • 10A small neural network from scratch
CapstoneTicket triage you can defendReference implementation

Module 2 · Classifiers and generalisation · Lesson 4

Logistic regression, step by step

From a weighted sum to a probability with the sigmoid, the cross-entropy loss and its gradient (the same shape as linear regression), a classifier you train in numpy and match against scikit-learn, and the softmax that turns it into a multi-class model and an LLM's output head.

75 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvThe Hollowbrook ticket data

By the end of this lesson you can

  • Derive the sigmoid from log-odds and compute P(urgent | features) for a ticket by hand from weights and a bias
  • Write the binary cross-entropy loss, explain why squared error is the wrong loss for probabilities, and show its gradient has the same form as linear regression's
  • Train logistic regression with your own numpy gradient descent and match scikit-learn's decisions on at least 95% of validation tickets
  • Extend the model to several classes with softmax and read the learned weights as evidence per word
  • Explain why an LLM's next-token layer is a softmax regression over the vocabulary

On this page

  • Intuition: a score that becomes a probability
  • A worked ticket, by hand
  • The loss: cross-entropy, derived gently
  • The gradient has the same form as linear regression
  • Training it on Hollowbrook's tickets
  • The well-specified model
  • The text model
  • From two classes to five: softmax
  • Reading the weights as evidence
  • Why this is an LLM's output head
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: a score that becomes a probability
  2. 02The loss: cross-entropy, derived gently
  3. 03Training it on Hollowbrook's tickets
  4. 04From two classes to five: softmax
  5. 05Why this is an LLM's output head
  6. 06Connections
  7. 07Summary

Sources & further reading

  • Logistic regression (Machine Learning Crash Course)Lab research · GoogleA short, visual pass over the sigmoid and log loss if the equations below feel dense. Read the "Sigmoid function" and "Loss and regularization" pages.
  • CS229 Lecture Notes, chapter 2: Classification and logistic regressionUniversity · Ma, Ng · Stanford · 2026The derivation of the gradient from maximum likelihood, and why it comes out identical in form to the least-squares update. Read sections 2.1 and 2.2, then 2.4 for the multi-class case.
  • Speech and Language Processing, chapter 4: Logistic Regression and Text ClassificationBook · Jurafsky, Martin · 2026Written for exactly this lesson's problem, text classification with sparse word features. Sections 4.2 to 4.6 cover the sigmoid, cross-entropy, the gradient and the multinomial case in the same notation we use.
  • Probabilistic Machine Learning: An Introduction, chapter 10: Logistic regressionBook · Murphy · 2022The most careful treatment of the loss, its convexity and the multinomial version, for when you want the full picture. Sections 10.1 to 10.3.
  • Deep Learning, chapter 5: Machine Learning BasicsBook · Goodfellow, Bengio, Courville · 2016Section 5.7.1 presents logistic regression as the simplest probabilistic supervised learner, which is the framing that carries into neural networks and the LLM output head.
  • Linear models: Logistic regression (scikit-learn user guide)Docs · scikit-learnWhat `LogisticRegression` actually minimises, including the regularisation term controlled by `C`, which explains why its weights differ slightly from unregularised gradient descent.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks