Reputation: 21
I was using StandardScaler to scale my data as was shown in a tutorial. But its not working.
I tried copy the same code as was used in the tutorial but still error was displayed.
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(df.drop('TARGET CLASS',axis=1))
scaled_features = scaler.transform(df.drop('TARGET CLASS',axis=1))
The error is as follows:
TypeError: fit() missing 1 required positional argument: 'X'
Upvotes: 2
Views: 747
Reputation: 1809
By trying to recreate your problem, it seems that everything in the code is correct and being executed perfectly. Here is a stand-alone example I created in order to test your code:
import pandas as pd
from sklearn.datasets import load_iris
from sklearn.preprocessing import StandardScaler
data = load_iris()
df = pd.DataFrame(data.data, columns=['TARGET CLASS', 'a', 'b', 'c'])
scaler = StandardScaler()
scaler.fit(df.drop('TARGET CLASS', axis=1))
scaled_features = scaler.transform(df.drop('TARGET CLASS',axis=1))
I suggest you examine your variable df
by printing it. For instance, you could try to transform it into a NumPy array before passing it and print its contents:
import numpy as np
X = df.drop('TARGET CLASS',axis=1).values
print(X)
Upvotes: 1