I have scaled an original matrix A with sklearn's StandardScaler, resulting to a matrix S.

I then partitioned the result into an important and non-important part B and C, in a way that

B + C = S

I now want to inverse scale B and C separately.

However, when I try using inverse scaler the result is completely wrong. How would I go about doing this?

  • $\begingroup$ Can you explain a little bit better what the matrix names mean? For example I don't understand the relationship between S and A. $\endgroup$
    – liakoyras
    Nov 19, 2022 at 10:53
  • $\begingroup$ S is the scaled version of A - in this case scaled according to z scores, but it could be another scaler too like max absolute scaler $\endgroup$
    – ccccc
    Nov 19, 2022 at 17:53
  • $\begingroup$ And by inverse scaling you mean going from the two components B and C to b' and c' such as b' + c' = A? $\endgroup$
    – liakoyras
    Nov 19, 2022 at 19:04
  • $\begingroup$ Exactly, that's right. $\endgroup$
    – ccccc
    Nov 19, 2022 at 19:09

1 Answer 1


While I am not completely sure about your application and the process you are following, I am not sure what you describe is possible (at least not with the library functions).

Standard scaler works by subtracting the mean and dividing by std. To inverse this, you multiply by std and add mean to all samples.

This would work if you wanted to inverse the scaling of S to go back to A, but when you split it there are some problems.

Observe the following equation (m is a vector and s is a number):

If you want to find two matrices that add up to A, you multiply by s (this is the easy part) but then you have to somehow subtract m ONE time in total from TWO other matrices.

Obviously, this is not as simple as defining "the inverse scaling". It depends on how S was split into B and C in the first place. If for example B and C were equal, subtracting m/2 from both matrices should be fine. But with any other split, you would need to calculate what percentage of this -m that S has has gone into each of the two other matrices, in order to be able to reverse it properly. And if the split did not happen in such a simple way (for example, different rows of matrix S contain different percentages of C and B), then I frankly don't know how to calculate this or even if it is possible.

I am assuming that you simply called scaler.inverse_transform to both B and C and thus ended up adding 2m to the right hand side of the above equation, leading to the wrong results.

I don't know why you have to split the data after scaling, but, depending on the way you it is not as simple to reverse this. My suggestion would be to try and scale before splitting the data parts.

  • $\begingroup$ Thanks for answering! Yes, different rows (and items on rows) have different percentages of C and B. I'm scaling, then doing SVD - this way I get a better result than just doing SVD on the original. It's good to know that this is a genuinely hard thing to do and I haven't missed something obvious. $\endgroup$
    – ccccc
    Nov 20, 2022 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.