Skip to content

Least-squares chapter: blocks that break when run top to bottom, and two claims that do not hold #281

Description

@kgdunn

Running least-squares-modelling/ as one script (the chapter's own contract) against process-improve 1.78.0:

Blocks that fail

  • investigating-an-existing-linear-model.rst:185 sets pd.options.plotting.backend = "plotly". Two later blocks were written for the matplotlib backend and break once that option is set: summary-of-steps-to-build-and-investigate-a-linear-model.rst:153-158 (subset.plot.scatter(...).set_title(...): a plotly Figure has no set_title) and multiple-linear-regression.rst:230 (.plot(..., grid=True): plotly's line() rejects grid). Either use plotly idioms in those blocks (the book's stated style) or stop switching the backend mid-chapter.
  • least-squares-exercises.rst:975-981: digester.hist(figsize=..., bins=30, color="lightblue") fails under the plotly backend (color must be a column), and digester.corr()["Y-Kappa"] raises ValueError: could not convert string to float: '31-00:00' because the Kamyr file's Observation column is text. The question at line 955 says to drop non-numeric identifier columns; the starter code never does.
  • covariance-and-correlation.rst:158-180 is a fill-in-the-blank exercise (___) and cannot run; it needs a .. code-check: skip marker with the reason.

Claims that do not hold

  • least-squares-models-with-a-single-x-variable.rst:269-271: "everything shown here carries over unchanged to scikit-learn's own LinearRegression". The block below reads mymodel.coefficients_ (sklearn has coef_, not coefficients_) and relies on print(mymodel) rendering an R-style summary; neither carries over. Only intercept_, fit, predict and score do.
  • multiple-linear-regression.rst:286-288: "a single column of random noise moves R2 only in the fifth decimal (0.93831 to 0.93832)". Over 1000 seeds the median new R2 is 0.93849 (fourth decimal; expected increase (1-R2)/(n-k) = 0.00042); only 6% of seeds round to 0.93832. No seed is given, so the sentence is not reproducible as written.

Smaller items

  • enrichment-topics.rst:130 and least-squares-models-with-a-single-x-variable.rst:268 link to github.com/kgdunn/process_improve (underscore, HTTP 403).
  • least-squares-exercises.rst:894 calls a process_improve block "A Pandas / scikit-learn version".
  • outliers-discrepancy-leverage-and-influence-of-the-observations.rst:108-110 says unconditionally that leverage_ and influence_ are provided; the library computes them only for a single predictor with an intercept and returns NaN otherwise (OLS.leverage_ and OLS.influence_ are silently NaN for multiple regression and for fit_intercept=False process-improve#545).
  • least-squares-models-with-a-single-x-variable.rst:208-211: the comment shows const / x1 labels, but mod_ls.params on an ndarray prints an unlabelled array. :296: "the shape these estimators expect"; OLS.fit reshapes 1-D input itself.
  • least-squares-exercises.rst:865: the upper bound 9.49 is written as 9.4.
  • enrichment-topics.rst:148-152: comment says "slope ... and intercept", the print shows intercept first.

All 54 quoted numbers in these files reproduced except the fifth-decimal claim. Found by executing every code block of the book (#274).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions