Build knowledge graphs from scratch using Python Learn how to create knowledge graphs, analyze knowledge graphs, and train embedding models (tutorial includes source code)

image.png

Build a knowledge graph

The first step is to load our data. In this example, we will create a simple KG from scratch. Let's first create a data frame with the data we're interested in.

import pandas as pd

# Define the heads, relations, and tails
head = ['drugA', 'drugB', 'drugC', 'drugD', 'drugA', 'drugC', 'drugD', 'drugE', 'gene1', 'gene2','gene3', 'gene4', 'gene50', 'gene2', 'gene3', 'gene4']
relation = ['treats', 'treats', 'treats', 'treats', 'inhibits', 'inhibits', 'inhibits', 'inhibits', 'associated', 'associated', 'associated', 'associated', 'associated', 'interacts', 'interacts', 'interacts']
tail = ['fever', 'hepatitis&

Guess you like

Origin blog.csdn.net/iCloudEnd/article/details/132729621