python-novice-inflammation icon indicating copy to clipboard operation
python-novice-inflammation copied to clipboard

Prose error describing numpy rows and columns relative to axis number...

Open KjellSwedin opened this issue 9 years ago • 2 comments

The following line shows rows with axis 0:

"If we ask for the average across axis 0 (rows in our 2D example), we get:"

and here columns are show with axis 1:

"If we average across axis 1 (columns in our 2D example), we get:"

The diagram above correctly shows axis 0 as columns and axis 1 as rows.

KjellSwedin avatar Oct 07 '16 22:10 KjellSwedin

Perhaps this episode has been updated since October 7, but the prose looks correct to me and consistent with the diagram, although it could be clearer. The current text is a bit glib about the semantics of axis, which could lead to confusion.

numpy.mean(data, axis=0) means "Take the average across all rows (axis=0) for each column. The diagram shows the result, which is a vector of columns".

Likewise, numpy.mean(data, axis=1) means "Take the average across all columns (axis=1) for each row. The diagram shows the result, which is a vector of rows".

The main inconsistency that I would like to report is that the diagram uses object notation to take the mean:

data.mean(axis=1)

whereas the code cell uses functional notation:

print(numpy.mean(data, axis=1))

While both notations are correct, this discrepancy adds more cognitive burden to the learner.

Secondly, in the diagram, the axis=1 example is shown first, followed by the axis=0 example, whereas in the code cells, the axis=0 example is shown first, followed by the axis=1 example. Again, while both the code and the diagram are correct, it adds more cognitive burden to the learner than if the examples were consistent in their ordering.

Finally, in the diagram, the axis=1 example applies the max operator, and the axis=0 example applies the mean operator, but in the code cells directly following the diagram, both examples apply the mean operator. If there were more parallelism between the diagram and the code, then the episode would be easier to learn.

djinnome avatar Jan 09 '17 22:01 djinnome

Yes, it will be great if those clarifications are added and the inconsistencies are eliminated. PR's welcome!

valentina-s avatar Oct 23 '17 08:10 valentina-s