Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can node2vec be used in Chinese? A data format similar to my following? #106

Open
HJW3536 opened this issue Dec 1, 2020 · 1 comment
Open

Comments

@HJW3536
Copy link

HJW3536 commented Dec 1, 2020

image
Chinese characters represent nodes, and numbers represent weights.Has anyone done a similar experiment? Ask for advice

@shoegazerstella
Copy link

shoegazerstella commented Mar 8, 2021

My advice is to encode the text with a label encoder like this:

le = LabelEncoder()
le.fit(df.stack().unique())

# save label encoder
np.save('label_encoder.npy', le)

df['source'] = le.transform(df['source'])
df['destination'] = le.transform(df['destination'])

then

le = np.load('label_encoder.npy', allow_pickle=True).tolist()

# get node_id
le.transform([node_name])[0]

# get node name
le.inverse_transform([node_id])[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants