ValueError: could not convert string to float: 'False'
Hi sir, I have a trouble when run args.edges = edges
args.edges = get_edgelists('relation*', args.training_dir)
g, features, target_id_to_node, id_to_node = construct_graph(args.training_dir, args.edges, args.nodes, args.target_ntype)
mean, stdev, features = normalize(th.from_numpy(features))
print('feature mean shape:{}, std shape:{}'.format(mean.shape, stdev.shape))
The error is data in file features.csv, id35-id-38 use 'True', 'False' so it's cannot convert to float. Very appreciate if you answer me soon.
ValueError Traceback (most recent call last) Cell In[30], line 5 1 args.edges = edges 3 args.edges = get_edgelists('relation*', args.training_dir) ----> 5 g, features, target_id_to_node, id_to_node = construct_graph(args.training_dir, 6 args.edges, 7 args.nodes, 8 args.target_ntype) 10 mean, stdev, features = normalize(th.from_numpy(features)) 12 print('feature mean shape:{}, std shape:{}'.format(mean.shape, stdev.shape))
File /kaggle/working/graph-fraud-detection/gnn/graph_utils.py:262, in construct_graph(training_dir, edges, nodes, target_node_type) 259 print("Read edges for {} from edgelist: {}".format(src + '<' + dst + '>', os.path.join(training_dir, edge))) 261 # get features for target nodes --> 262 features, new_nodes = get_features(id_to_node[target_node_type], os.path.join(training_dir, nodes)) 263 print("Read in features for target nodes") 265 # add self relation
File /kaggle/working/graph-fraud-detection/gnn/graph_utils.py:31, in get_features(id_to_node, node_features) 29 node_feats = line.strip().split(",") 30 node_id = node_feats[0] ---> 31 feats = np.array(list(map(float, node_feats[1:]))) 32 features.append(feats) 33 if node_id not in id_to_node:
ValueError: could not convert string to float: 'False'
just change 10_data_loader as follows
features = pd.get_dummies(transaction_df[feature_cols], columns=cat_cols).fillna(0)
to
features = pd.get_dummies(transaction_df[feature_cols], columns=cat_cols, dtype=float).fillna(0)