Blog‎ > ‎

Python API for NOESIS now available!

posted Mar 27, 2018, 2:30 AM by Víctor Martínez   [ updated Mar 27, 2018, 2:55 AM ]
Python logo


The NOESIS team have just released the official Python API for NOESIS, which provides simple and unified interfaces for most of the techniques implemented in NOESIS. You can find the source code at https://github.com/fvictor/noesis-python, where you can obtain more information about how to install the API from the source code or from the Python Package Index. The up-to-date API documentation can be found at http://noesis-python.readthedocs.io.

When designing the API, we focused on simplicity and usability. The large collection of algorithms included in NOESIS can be called from Python with only a few lines of code. For example, the following code loads a network from a GML file and detects its communities using the Kernighan–Lin algorithm:

from noesis import Noesis

ns = Noesis()

network_reader = ns.create_network_reader('GML')
network = network_reader.read('my_network.gml')

community_detector = ns.create_community_detector('KernighanLin')
communities = community_detector.compute(network)

for node in range(network.nodes()):
	print('Node {} belongs to community {}'.format(node, communities[node]))

ns.end()

Please note that the used algorithm could be easily changed by replacing the 'KernighanLin' argument with a valid name of other community detection algorithm (see documentation for more details), such as ‘NewmanGirvan’ or ‘BigClam’, to mention some examples.

In this other example a network of 20 nodes and 100 links is generated using the Erdös–Rényi model and the PageRank score of each node is computed:

from noesis import Noesis

ns = Noesis()

network = ns.create_network_from_model('ErdosRenyi', 20, 100)

pagerank_scorer = ns.create_node_scorer('PageRank', 0.9)
scores = pagerank_scorer.compute(network)

for node in range(network.nodes()):
	print('Node {} has a PageRank score of {}'.format(node, scores[node]))

ns.end()

We hope this Python API will be very useful in the analysis of networks and would like it to become part of the toolkit of many data scientists.
Comments