TypeError: fit_transform() missing 1 required positional argument: 'X'
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
add a comment |
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
add a comment |
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
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
python python-3.x
edited Jul 1 '18 at 17:54
Deduplicator
34.4k64888
34.4k64888
asked Jul 1 '18 at 17:28
danyialKhandanyialKhan
724
724
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
sc_X = StandardScaler
should be:
sc_X = StandardScaler()
add a comment |
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])
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
sc_X = StandardScaler
should be:
sc_X = StandardScaler()
add a comment |
sc_X = StandardScaler
should be:
sc_X = StandardScaler()
add a comment |
sc_X = StandardScaler
should be:
sc_X = StandardScaler()
sc_X = StandardScaler
should be:
sc_X = StandardScaler()
answered Jul 1 '18 at 17:57
Uku LoskitUku Loskit
30.4k86879
30.4k86879
add a comment |
add a comment |
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])
add a comment |
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])
add a comment |
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])
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])
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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