[英]Value Error on preprocessing.MinMaxScaler().fit_transform()
Help me understand what i am doing wrong here帮助我了解我在这里做错了什么
# Read Data
dataset = pd.read_csv("PS_20174392719_1491204439457_log.csv")
dataset = dataset.iloc[1:50000]
print (dataset.head())
Output for above code,上述代码的输出,
step type amount nameOrig oldbalanceOrg newbalanceOrig \
1 1 PAYMENT 1864.28 C1666544295 21249.0 19384.72
2 1 TRANSFER 181.00 C1305486145 181.0 0.00
3 1 CASH_OUT 181.00 C840083671 181.0 0.00
4 1 PAYMENT 11668.14 C2048537720 41554.0 29885.86
5 1 PAYMENT 7817.71 C90045638 53860.0 46042.29
nameDest oldbalanceDest newbalanceDest isFraud isFlaggedFraud
1 M2044282225 0.0 0.0 0 0
2 C553264065 0.0 0.0 1 0
3 C38997010 21182.0 0.0 1 0
4 M1230701703 0.0 0.0 0 0
5 M573487274 0.0 0.0 0 0
When i run below code, i get a value error当我运行下面的代码时,我得到一个值错误
# Scale dataset and split into fraud and non-fraud instances
x = dataset.drop(["isFraud"], axis=1)
y = dataset["isFraud"].values
x_scale = preprocessing.MinMaxScaler().fit_transform(x.values)
x_norm, x_fraud = x_scale[y == 0], x_scale[y == 1]
ValueError: could not convert string to float: 'PAYMENT'
What exactly am i doing wrong?我到底做错了什么?
Try this:尝试这个:
string
in the .csv
file..csv
文件中保存为string
。from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
x = dataset.drop(columns=['type', 'nameOrig', 'nameDest', 'isFraud'])).astype(np.float32)
x_scale = scaler.fit_transform(x)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.