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.from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
x = dataset.drop(columns=['type', 'nameOrig', 'nameDest', 'isFraud'])).astype(np.float32)
x_scale = scaler.fit_transform(x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.