We select two rows from an array for a local transformation and subtract the mean of each column. The values look right. But when we return to the original features, the first two rows have changed there too. We meant to prepare a separate batch and ended up rewriting part of the source.
The array shape is correct, and the calculation raised no error. What we need to understand is who owns the data being changed. We'll work through four rows, make the copy boundary explicit, and check that behavior with tests.
Take two numeric features. From the first two rows, we want to subtract their column means: 15 and 150.
The batch has the expected values. The surprise is that those values now appear in features. If the next step expected the original features, it is already working with different data.
Source: DEV - machine learning — Read the full article on the original site ↗
