Data science demo nodejavascript.com

A number you cannot check is an opinion.

So this page checks its own numbers in front of you. Pick a published dataset, or drop in your own file, and every figure below is computed in your browser from that data — with the arithmetic shown, the convention named, and the uncertainty printed beside every estimate. Nothing is uploaded, because there is nowhere for it to go.

Start with a dataset How to check a number here

Anscombe's first set, drawn from site/data/anscombe.json. The other three sets in section 3 share its mean, its variance, its correlation and its slope — and look nothing like it.

1 · The data

Four published datasets are shipped with the page. Each one is here because it teaches something that a summary statistic hides, and each is cited at the bottom of this page.

A header row is required. Quoted fields are read properly.

2 · One column, described

Every figure in the table is printed with the rule that produced it, because each of them has more than one defensible definition and the difference is not always small.

3 · Four datasets that agree, and do not

Anscombe published these four sets in 1973 to make one point: the mean of x, the mean of y, the variance, the correlation and the fitted line are the same in all four, to three decimal places — and the four pictures are not the same data at all. The numbers below are computed here, from the data, not copied from the paper.

One scatter per set, always on the same axes, with its own least-squares line. Hover a point for its values.

4 · A fitted line, with what it assumes

A slope on its own is the most over-read number in public life. Here it arrives with its standard error, the p-value from the t distribution, the share of variance it explains, an honest out-of-fold error, and the assumptions that have to hold — plus the leverage check — before any of it means what it appears to mean.

How well does it predict something it has not seen?

The R² above is measured on the same rows that fitted the line, so it is always a little optimistic. Cross-validation holds rows out, fits on the rest, and scores what is left — twenty times over, because one split gives one number and that number moves.

The assumptions, checked where a check is possible

5 · Telling classes apart

Accuracy alone hides which mistake is being made, so the confusion matrix comes first; the ROC curve comes second because it is the one summary that survives an unbalanced sample. Both are computed out-of-fold, on rows the classifier never saw.

6 · How to check a number here

Four things turn a figure into evidence: it can be recomputed, its convention is named, its uncertainty is printed, and the sample it came from is stated. This page does all four; the middle two are the ones most dashboards skip.

  1. Recompute it. Every statistic on this page comes from site/stats.js, which has no dependency on the page and is imported by the test suite as well as by the browser. The tests in tools/test-stats.mjs compare it against values computed separately in Python with statistics and scipy, and against the four-decimal summary of Anscombe's quartet that every textbook prints.
  2. Read the convention. Standard deviation uses the n − 1 denominator. Quantiles use Hyndman & Fan type 7, which is what R, NumPy and Excel give, so the same number appears if you check it elsewhere. Skewness is the adjusted sample moment G1; kurtosis is excess kurtosis, so a normal distribution is 0 and not 3. Correlation is Pearson's unless it says Spearman, which is Pearson's on averaged ranks.
  3. Read the uncertainty, not the point. A slope with a standard error of a third of its own size is not evidence of anything, however tidy it looks. A cross-validated score is printed as a mean and a spread across repeats for the same reason.
  4. Ask what the sample is. Iris is 150 flowers measured in the 1930s; the penguins are 344 birds from three islands in the Palmer Archipelago; Old Faithful is 272 eruptions recorded between 1985 and 1986. A conclusion reaches no further than the sample does, and no statistic on any page can repair that.

7 · What leaves this page

Nothing, unless you say yes to the only question it asks.

The datasets, with their papers

8 · Run it yourself

It is a static page and a statistics module with no dependencies. Serve the folder and open it — that is the whole installation.

python3 tools/serve.py 8161     # http://127.0.0.1:8161
node tools/test-stats.mjs       # the arithmetic, 89 assertions
python3 tools/check-page.py     # the page against the family's rules

The site is served with no-store on purpose: a browser holding a cached copy makes a correct change look like no change at all.