Current location - Education and Training Encyclopedia - Graduation thesis - Can the knowledge spectrum be built in python?
Can the knowledge spectrum be built in python?
Can the knowledge map be built in python?

The answer is of course yes! ! !

So how do you build it in python?

What is a knowledge map?

From Google search, to chat bots, financial risk control, Internet of Things scenarios, intelligent medical care, adaptive education, and recommendation systems, all of them are related to knowledge maps. Its popularity in the technical field is also increasing year by year.

The ultimate form of the Internet is the Internet of Everything, and the ultimate goal of search is the direct search of everything. Traditional search engines rely on hyperlinks between web pages to search for web pages, while semantic search directly searches for things, such as people, institutions and places. These things may come from text, pictures, videos, audio, Internet of Things devices and other information resources. Knowledge map and semantic technology provide descriptions about the classification, attributes and relationships of these things, so that search engines can directly index and search things.

Knowledge map is a new concept put forward by Google in 20 12. From an academic point of view, we can give the definition of knowledge map: "Knowledge map is essentially the knowledge base of semantic network". But this is a bit abstract, so from another angle, from the perspective of practical application, we can simply understand the knowledge map as a multi-relationship diagram.

So what is a multivariate diagram? Anyone who has studied data structure should know what a graph is. Graphs consist of vertices and edges, but these graphs usually contain only one type of nodes and edges. On the contrary, multi-relational graphs generally contain many types of nodes and many types of edges.

In this project, pandas is used to extract data from excel and load them into the secondary database in the form of triples, so as to construct related knowledge maps.

Runtime environment

Based on quadratic, it is easy to construct knowledge map. In addition to using cypher that comes with Secondary, it also supports Python package py2neo to create nodes and relationships and build knowledge maps. Based on the invoice information, this project abstracts the structured data in the invoice data into triples, and creates nodes and relationships respectively, thus constructing a knowledge map.

Please refer to the requirements.txt file for specific package dependencies.

neo4j-driver = = 1.6 . 2 numpy = = 1. 15.3 pandas = = 0.23 . 4 parso = = 0.3. 1 pickle share = = 0.7 . 5 pluggy = = 0.8 . 0 prompt-toolkit = = 1.0. 15py = = 1.7 . 0 py 2 neo = .

Install the required dependencies into pyton: pipininstall-rrequirements.txt.

Panda extracts excel data

Pandas in python is very suitable for data analysis and processing. Excel files can be converted into Dataframe format, similar to the dataframe structure in Spark, and data can be processed in a form similar to sql.

The data structure of Excel is as follows

The node data and contact data needed to construct knowledge map are extracted by function data extraction and function relationship extraction respectively, and the triple is constructed.

Data extraction mainly uses pandas to convert excel data into dataframe type.

invoice_neo4j.py

Nodes and relational data needed to build knowledge map

DataToNeo4jClass.py

Please go to GitHub to download the specific code.

Please go to github to download the details, and the project name is secondary-python-panda-py2neo-v3.

For more Python knowledge, please pay attention to: Python self-study network! !