TypeError: fit_transform() missing 1 required positional argument: 'X'












0















I am trying to do Feature Scaling in a dataset, but I get an error and have no idea how to proceed:



    > Traceback (most recent call last):
>
> File "<ipython-input-10-71bea414b4d0>", line 22, in <module>
> x_train = sc_X.fit_transform(x_train)
>
> TypeError: fit_transform() missing 1 required positional argument: 'X'


and here is my code:



import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
# Taking care of missing data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values="NaN", strategy="mean", axis=0)
imputer = Imputer.fit(imputer,X[:,1:3])
X[:, 1:3] = Imputer.transform(imputer,X[:, 1:3])

#Spliting the dataset into Training set and Test Set
from sklearn.cross_validation import train_test_split

x_train, x_test, y_train, y_test = train_test_split(X, y, test_size= 0.2, random_state= 0)

#Feature Scalling

from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler
x_train = sc_X.fit_transform(x_train)
x_test = sc_X.transform(x_test)









share|improve this question





























    0















    I am trying to do Feature Scaling in a dataset, but I get an error and have no idea how to proceed:



        > Traceback (most recent call last):
    >
    > File "<ipython-input-10-71bea414b4d0>", line 22, in <module>
    > x_train = sc_X.fit_transform(x_train)
    >
    > TypeError: fit_transform() missing 1 required positional argument: 'X'


    and here is my code:



    import pandas as pd

    # Importing the dataset
    dataset = pd.read_csv('Data.csv')
    X = dataset.iloc[:, :-1].values
    y = dataset.iloc[:, 3].values
    # Taking care of missing data
    from sklearn.preprocessing import Imputer
    imputer = Imputer(missing_values="NaN", strategy="mean", axis=0)
    imputer = Imputer.fit(imputer,X[:,1:3])
    X[:, 1:3] = Imputer.transform(imputer,X[:, 1:3])

    #Spliting the dataset into Training set and Test Set
    from sklearn.cross_validation import train_test_split

    x_train, x_test, y_train, y_test = train_test_split(X, y, test_size= 0.2, random_state= 0)

    #Feature Scalling

    from sklearn.preprocessing import StandardScaler
    sc_X = StandardScaler
    x_train = sc_X.fit_transform(x_train)
    x_test = sc_X.transform(x_test)









    share|improve this question



























      0












      0








      0








      I am trying to do Feature Scaling in a dataset, but I get an error and have no idea how to proceed:



          > Traceback (most recent call last):
      >
      > File "<ipython-input-10-71bea414b4d0>", line 22, in <module>
      > x_train = sc_X.fit_transform(x_train)
      >
      > TypeError: fit_transform() missing 1 required positional argument: 'X'


      and here is my code:



      import pandas as pd

      # Importing the dataset
      dataset = pd.read_csv('Data.csv')
      X = dataset.iloc[:, :-1].values
      y = dataset.iloc[:, 3].values
      # Taking care of missing data
      from sklearn.preprocessing import Imputer
      imputer = Imputer(missing_values="NaN", strategy="mean", axis=0)
      imputer = Imputer.fit(imputer,X[:,1:3])
      X[:, 1:3] = Imputer.transform(imputer,X[:, 1:3])

      #Spliting the dataset into Training set and Test Set
      from sklearn.cross_validation import train_test_split

      x_train, x_test, y_train, y_test = train_test_split(X, y, test_size= 0.2, random_state= 0)

      #Feature Scalling

      from sklearn.preprocessing import StandardScaler
      sc_X = StandardScaler
      x_train = sc_X.fit_transform(x_train)
      x_test = sc_X.transform(x_test)









      share|improve this question
















      I am trying to do Feature Scaling in a dataset, but I get an error and have no idea how to proceed:



          > Traceback (most recent call last):
      >
      > File "<ipython-input-10-71bea414b4d0>", line 22, in <module>
      > x_train = sc_X.fit_transform(x_train)
      >
      > TypeError: fit_transform() missing 1 required positional argument: 'X'


      and here is my code:



      import pandas as pd

      # Importing the dataset
      dataset = pd.read_csv('Data.csv')
      X = dataset.iloc[:, :-1].values
      y = dataset.iloc[:, 3].values
      # Taking care of missing data
      from sklearn.preprocessing import Imputer
      imputer = Imputer(missing_values="NaN", strategy="mean", axis=0)
      imputer = Imputer.fit(imputer,X[:,1:3])
      X[:, 1:3] = Imputer.transform(imputer,X[:, 1:3])

      #Spliting the dataset into Training set and Test Set
      from sklearn.cross_validation import train_test_split

      x_train, x_test, y_train, y_test = train_test_split(X, y, test_size= 0.2, random_state= 0)

      #Feature Scalling

      from sklearn.preprocessing import StandardScaler
      sc_X = StandardScaler
      x_train = sc_X.fit_transform(x_train)
      x_test = sc_X.transform(x_test)






      python python-3.x






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 1 '18 at 17:54









      Deduplicator

      34.4k64888




      34.4k64888










      asked Jul 1 '18 at 17:28









      danyialKhandanyialKhan

      724




      724
























          2 Answers
          2






          active

          oldest

          votes


















          2














          sc_X = StandardScaler


          should be:



          sc_X = StandardScaler()





          share|improve this answer































            0














            imputer is a method and Imputer is a class



            So, change the code as below, and other such occurrences in this code:



            imputer = imputer.fit(imputer,X[:,1:3])





            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              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
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51125475%2ftypeerror-fit-transform-missing-1-required-positional-argument-x%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              sc_X = StandardScaler


              should be:



              sc_X = StandardScaler()





              share|improve this answer




























                2














                sc_X = StandardScaler


                should be:



                sc_X = StandardScaler()





                share|improve this answer


























                  2












                  2








                  2







                  sc_X = StandardScaler


                  should be:



                  sc_X = StandardScaler()





                  share|improve this answer













                  sc_X = StandardScaler


                  should be:



                  sc_X = StandardScaler()






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 1 '18 at 17:57









                  Uku LoskitUku Loskit

                  30.4k86879




                  30.4k86879

























                      0














                      imputer is a method and Imputer is a class



                      So, change the code as below, and other such occurrences in this code:



                      imputer = imputer.fit(imputer,X[:,1:3])





                      share|improve this answer






























                        0














                        imputer is a method and Imputer is a class



                        So, change the code as below, and other such occurrences in this code:



                        imputer = imputer.fit(imputer,X[:,1:3])





                        share|improve this answer




























                          0












                          0








                          0







                          imputer is a method and Imputer is a class



                          So, change the code as below, and other such occurrences in this code:



                          imputer = imputer.fit(imputer,X[:,1:3])





                          share|improve this answer















                          imputer is a method and Imputer is a class



                          So, change the code as below, and other such occurrences in this code:



                          imputer = imputer.fit(imputer,X[:,1:3])






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 22 '18 at 23:56









                          vahdet

                          1,57931130




                          1,57931130










                          answered Nov 22 '18 at 19:06









                          Aakif Mairaj MuftiAakif Mairaj Mufti

                          1




                          1






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • 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.


                              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%2fstackoverflow.com%2fquestions%2f51125475%2ftypeerror-fit-transform-missing-1-required-positional-argument-x%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

                              404 Error Contact Form 7 ajax form submitting

                              How to know if a Active Directory user can login interactively