Convert matrix columns to z scores - notation












1












$begingroup$


I am doing a course on machine learning. In it I am asked to convert a matrix's columns to z-scores. It says:




Subtract the mean value of each feature from the dataset (columns of
X). After subtracting the mean, additionally scale (divide) the
feature values by their respective “standard deviations.”




This is not hard for me and I have written a little python function to this goal, but I was wondering what the vectorized version of this function would look like. So I set up some equations that I could then express in python, but I have done some unconventional things to achieve this and I would like to know what the conventional way would be.



Here is what I've got:



$$
z: R^{mtimes n}rightarrow R^{mtimes n}\
z( X) =left( X-1_{m} mu ( x)^{T}right) otimes 1_{m} sigma ( x)^{T}\
$$



Insecurities:




  • The circle operator in this equation is the hadamard product. Does this even have an official operator? Should I describe what is meant with that operator? Or is there some way around it?

  • I've added the function's mapping on top as is usual in certain programming languages like Haskell. I find this to be very handy in terms of doing linear algebra where you have to keep track of the dimensions of vectors and matrices. Is this common in expressing math as well?


Here are mu and sigma:



$$
mu :R^{mtimes n} rightarrow R^{n}\
mu ( X) =frac{1}{m} x^{T} 1_{m}\
$$



Same insecurities here.



$$
sigma : R^{mtimes n}rightarrow R^{n}\
sigma ( X) =frac{1}{m}sqrt{left(sumlimits ^{n}_{j=0}left( X-1_{m} mu ( x)^{T}right)^{2}_{ij}right)_{j}}\
$$



Insecurities:




  • I have to square each cell of the resulting matrix and sum the results in to a vector. I am using a fictional i index. How should I describe what i is?

  • I later have to square each element of the vector. Here I use j, but outside the summation. Again: how should I describe this?


Your insights are much appreciated as I would like to learn the right/conventional way of doing linear algebra and don't have access to a teacher. I am curious to know how would your solution would look like.










share|cite|improve this question











$endgroup$

















    1












    $begingroup$


    I am doing a course on machine learning. In it I am asked to convert a matrix's columns to z-scores. It says:




    Subtract the mean value of each feature from the dataset (columns of
    X). After subtracting the mean, additionally scale (divide) the
    feature values by their respective “standard deviations.”




    This is not hard for me and I have written a little python function to this goal, but I was wondering what the vectorized version of this function would look like. So I set up some equations that I could then express in python, but I have done some unconventional things to achieve this and I would like to know what the conventional way would be.



    Here is what I've got:



    $$
    z: R^{mtimes n}rightarrow R^{mtimes n}\
    z( X) =left( X-1_{m} mu ( x)^{T}right) otimes 1_{m} sigma ( x)^{T}\
    $$



    Insecurities:




    • The circle operator in this equation is the hadamard product. Does this even have an official operator? Should I describe what is meant with that operator? Or is there some way around it?

    • I've added the function's mapping on top as is usual in certain programming languages like Haskell. I find this to be very handy in terms of doing linear algebra where you have to keep track of the dimensions of vectors and matrices. Is this common in expressing math as well?


    Here are mu and sigma:



    $$
    mu :R^{mtimes n} rightarrow R^{n}\
    mu ( X) =frac{1}{m} x^{T} 1_{m}\
    $$



    Same insecurities here.



    $$
    sigma : R^{mtimes n}rightarrow R^{n}\
    sigma ( X) =frac{1}{m}sqrt{left(sumlimits ^{n}_{j=0}left( X-1_{m} mu ( x)^{T}right)^{2}_{ij}right)_{j}}\
    $$



    Insecurities:




    • I have to square each cell of the resulting matrix and sum the results in to a vector. I am using a fictional i index. How should I describe what i is?

    • I later have to square each element of the vector. Here I use j, but outside the summation. Again: how should I describe this?


    Your insights are much appreciated as I would like to learn the right/conventional way of doing linear algebra and don't have access to a teacher. I am curious to know how would your solution would look like.










    share|cite|improve this question











    $endgroup$















      1












      1








      1





      $begingroup$


      I am doing a course on machine learning. In it I am asked to convert a matrix's columns to z-scores. It says:




      Subtract the mean value of each feature from the dataset (columns of
      X). After subtracting the mean, additionally scale (divide) the
      feature values by their respective “standard deviations.”




      This is not hard for me and I have written a little python function to this goal, but I was wondering what the vectorized version of this function would look like. So I set up some equations that I could then express in python, but I have done some unconventional things to achieve this and I would like to know what the conventional way would be.



      Here is what I've got:



      $$
      z: R^{mtimes n}rightarrow R^{mtimes n}\
      z( X) =left( X-1_{m} mu ( x)^{T}right) otimes 1_{m} sigma ( x)^{T}\
      $$



      Insecurities:




      • The circle operator in this equation is the hadamard product. Does this even have an official operator? Should I describe what is meant with that operator? Or is there some way around it?

      • I've added the function's mapping on top as is usual in certain programming languages like Haskell. I find this to be very handy in terms of doing linear algebra where you have to keep track of the dimensions of vectors and matrices. Is this common in expressing math as well?


      Here are mu and sigma:



      $$
      mu :R^{mtimes n} rightarrow R^{n}\
      mu ( X) =frac{1}{m} x^{T} 1_{m}\
      $$



      Same insecurities here.



      $$
      sigma : R^{mtimes n}rightarrow R^{n}\
      sigma ( X) =frac{1}{m}sqrt{left(sumlimits ^{n}_{j=0}left( X-1_{m} mu ( x)^{T}right)^{2}_{ij}right)_{j}}\
      $$



      Insecurities:




      • I have to square each cell of the resulting matrix and sum the results in to a vector. I am using a fictional i index. How should I describe what i is?

      • I later have to square each element of the vector. Here I use j, but outside the summation. Again: how should I describe this?


      Your insights are much appreciated as I would like to learn the right/conventional way of doing linear algebra and don't have access to a teacher. I am curious to know how would your solution would look like.










      share|cite|improve this question











      $endgroup$




      I am doing a course on machine learning. In it I am asked to convert a matrix's columns to z-scores. It says:




      Subtract the mean value of each feature from the dataset (columns of
      X). After subtracting the mean, additionally scale (divide) the
      feature values by their respective “standard deviations.”




      This is not hard for me and I have written a little python function to this goal, but I was wondering what the vectorized version of this function would look like. So I set up some equations that I could then express in python, but I have done some unconventional things to achieve this and I would like to know what the conventional way would be.



      Here is what I've got:



      $$
      z: R^{mtimes n}rightarrow R^{mtimes n}\
      z( X) =left( X-1_{m} mu ( x)^{T}right) otimes 1_{m} sigma ( x)^{T}\
      $$



      Insecurities:




      • The circle operator in this equation is the hadamard product. Does this even have an official operator? Should I describe what is meant with that operator? Or is there some way around it?

      • I've added the function's mapping on top as is usual in certain programming languages like Haskell. I find this to be very handy in terms of doing linear algebra where you have to keep track of the dimensions of vectors and matrices. Is this common in expressing math as well?


      Here are mu and sigma:



      $$
      mu :R^{mtimes n} rightarrow R^{n}\
      mu ( X) =frac{1}{m} x^{T} 1_{m}\
      $$



      Same insecurities here.



      $$
      sigma : R^{mtimes n}rightarrow R^{n}\
      sigma ( X) =frac{1}{m}sqrt{left(sumlimits ^{n}_{j=0}left( X-1_{m} mu ( x)^{T}right)^{2}_{ij}right)_{j}}\
      $$



      Insecurities:




      • I have to square each cell of the resulting matrix and sum the results in to a vector. I am using a fictional i index. How should I describe what i is?

      • I later have to square each element of the vector. Here I use j, but outside the summation. Again: how should I describe this?


      Your insights are much appreciated as I would like to learn the right/conventional way of doing linear algebra and don't have access to a teacher. I am curious to know how would your solution would look like.







      linear-algebra






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Dec 30 '18 at 16:05







      beginnersmind3

















      asked Dec 30 '18 at 10:23









      beginnersmind3beginnersmind3

      62




      62






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          I find your question very interesting. Hopefully we can chat about it in greater detail.



          Is it the case that you feel comfortable programming a solution to this problem, but you are not confident is writing a mathematical exposition of the solution?



          Or is it that you want to refactor your code to make it more in line with "standard" mathematical steps?



          Cheers






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            I don't feel confident writing the mathematical exposition.
            $endgroup$
            – beginnersmind3
            Jan 7 at 18:18











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3056697%2fconvert-matrix-columns-to-z-scores-notation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0












          $begingroup$

          I find your question very interesting. Hopefully we can chat about it in greater detail.



          Is it the case that you feel comfortable programming a solution to this problem, but you are not confident is writing a mathematical exposition of the solution?



          Or is it that you want to refactor your code to make it more in line with "standard" mathematical steps?



          Cheers






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            I don't feel confident writing the mathematical exposition.
            $endgroup$
            – beginnersmind3
            Jan 7 at 18:18
















          0












          $begingroup$

          I find your question very interesting. Hopefully we can chat about it in greater detail.



          Is it the case that you feel comfortable programming a solution to this problem, but you are not confident is writing a mathematical exposition of the solution?



          Or is it that you want to refactor your code to make it more in line with "standard" mathematical steps?



          Cheers






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            I don't feel confident writing the mathematical exposition.
            $endgroup$
            – beginnersmind3
            Jan 7 at 18:18














          0












          0








          0





          $begingroup$

          I find your question very interesting. Hopefully we can chat about it in greater detail.



          Is it the case that you feel comfortable programming a solution to this problem, but you are not confident is writing a mathematical exposition of the solution?



          Or is it that you want to refactor your code to make it more in line with "standard" mathematical steps?



          Cheers






          share|cite|improve this answer









          $endgroup$



          I find your question very interesting. Hopefully we can chat about it in greater detail.



          Is it the case that you feel comfortable programming a solution to this problem, but you are not confident is writing a mathematical exposition of the solution?



          Or is it that you want to refactor your code to make it more in line with "standard" mathematical steps?



          Cheers







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Jan 3 at 23:47









          RichardRichard

          112




          112












          • $begingroup$
            I don't feel confident writing the mathematical exposition.
            $endgroup$
            – beginnersmind3
            Jan 7 at 18:18


















          • $begingroup$
            I don't feel confident writing the mathematical exposition.
            $endgroup$
            – beginnersmind3
            Jan 7 at 18:18
















          $begingroup$
          I don't feel confident writing the mathematical exposition.
          $endgroup$
          – beginnersmind3
          Jan 7 at 18:18




          $begingroup$
          I don't feel confident writing the mathematical exposition.
          $endgroup$
          – beginnersmind3
          Jan 7 at 18:18


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3056697%2fconvert-matrix-columns-to-z-scores-notation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]