DSLR

Four scores, and the Sorting Hat answers. The model is the one their gradient descent produced; the arithmetic that applies it is a sigmoid and a dot product, rewritten here in a few lines.

A scatter plot of Herbology against Divination: the students gather into three clearly separated clusters along house lines

The demo needs JavaScript. Here is what it shows.

The four scores

The house

—

Probabilities

  • Ravenclaw—
  • Slytherin—
  • Gryffindor—
  • Hufflepuff—

On the students held out of training—

How it works

What runs here

Not the project’s program: DSLR is written in Python, which a browser cannot run. What runs here is the model its training produced, the weights, means and standard deviations, applied to the scores you pick.

What had to be adapted

The computation that applies the model is rewritten in TypeScript: a normalization, a sigmoid and a dot product. Shipping Python in the page would have cost ten megabytes and several seconds of startup for those few lines.

What differs from the original

Nothing in the result: the Python program and this rewrite classified the same four hundred students, set aside before training, without a single disagreement.