03. Machine Learning
Paste a restaurant or movie review and a feedforward neural network predicts its star rating on a 1 to 5 scale. All inference runs in your browser.
Ctrl+Enter to classify
The classifier was trained on 8,000 Yelp reviews with 1 to 5 star ratings. Each review is represented as a bag-of-words vector over the 8,000 most common tokens. The model is a two-layer feedforward neural network with 64 hidden units and a ReLU activation, trained using stochastic gradient descent with minibatches of 32.
Model weights are exported as JSON (4 MB) and loaded at startup. Inference is a sparse matrix-vector product done entirely in TypeScript, no WebAssembly or GPU required.
Accuracy note: 5-class star prediction is genuinely hard. The model reaches about 61% exact-match accuracy on held-out data (compared to 20% random chance). Adjacent-class errors (e.g., predicting 4 stars instead of 5) are common.