Skip to main content

HNET - Graphical Hypergeometric Networks

Python PyPI Version License Github Forks GitHub Open Issues Project Status Downloads Downloads Sphinx arXiv Medium Open In Colab BuyMeCoffee

Star it if you like it!

Read my blog about HNet at Medium

Summary

HNet stands for graphical Hypergeometric Networks, which is a method where associations across variables are tested for significance by statistical inference. The aim is to determine a network with significant associations that can shed light on the complex relationships across variables. Input datasets can range from generic dataframes to nested data structures with lists, missing values and enumerations.

Real-world data often contain measurements with both continuous and discrete values. Despite the availability of many libraries, data sets with mixed data types require intensive pre-processing steps, and it remains a challenge to describe the relationships between variables. The data understanding phase is crucial to the data-mining process, however, without making any assumptions on the data, the search space is super-exponential in the number of variables. A thorough data understanding phase is therefore not common practice.

Methods

We propose graphical hypergeometric networks (HNet), a method to test associations across variables for significance using statistical inference. The aim is to determine a network using only the significant associations in order to shed light on the complex relationships across variables. HNet processes raw unstructured data sets and outputs a network that consists of (partially) directed or undirected edges between the nodes (i.e., variables). To evaluate the accuracy of HNet, we used well known data sets and generated data sets with known ground truth. In addition, the performance of HNet is compared to Bayesian association learning.

Results

We demonstrate that HNet showed high accuracy and performance in the detection of node links. In the case of the Alarm data set we can demonstrate on average an MCC score of 0.33 + 0.0002 (P<1x10-6), whereas Bayesian association learning resulted in an average MCC score of 0.52 + 0.006 (P<1x10-11), and randomly assigning edges resulted in a MCC score of 0.004 + 0.0003 (P=0.49).

Conclusions

HNet overcomes processes raw unstructured data sets, it allows analysis of mixed data types, it easily scales up in number of variables, and allows detailed examination of the detected associations.

Documentation

Method overview

Installation

  • Install hnet from PyPI (recommended). Hnet is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows. It is distributed under the Apache 2.0 license.
pip install -U hnet
  • Simple example for the Titanic data set
# Initialize hnet with default settings
from hnet import hnet
# Load example dataset
df = hnet.import_example('titanic')
# Print to screen
print(df)
#      PassengerId  Survived  Pclass  ...     Fare Cabin  Embarked
# 0              1         0       3  ...   7.2500   NaN         S
# 1              2         1       1  ...  71.2833   C85         C
# 2              3         1       3  ...   7.9250   NaN         S
# 3              4         1       1  ...  53.1000  C123         S
# 4              5         0       3  ...   8.0500   NaN         S
# ..           ...       ...     ...  ...      ...   ...       ...
# 886          887         0       2  ...  13.0000   NaN         S
# 887          888         1       1  ...  30.0000   B42         S
# 888          889         0       3  ...  23.4500   NaN         S
# 889          890         1       1  ...  30.0000  C148         C
# 890          891         0       3  ...   7.7500   NaN         Q

Association learning on the titanic dataset.

from hnet import hnet
hn = hnet()
results = hn.association_learning(df)

# Plot static graph
G_static = hn.plot()

# Plot heatmap
P_heatmap = hn.heatmap(cluster=True)

# Plot dynamic graph
hn.d3graph()

# Plot dynamic graph
hn.d3heatmap()

Summarize results.

Networks can become giant hairballs and heatmaps unreadable. You may want to see the general associations between the categories, instead of the label-associations. With the summarize functionality, the results will be summarized towards categories.

# Import
from hnet import hnet

# Load example dataset
df = hnet.import_example('titanic')

# Initialize
hn = hnet()

# Association learning
results = hn.association_learning(df)

# Plot heatmap
hn.heatmap(summarize=True, cluster=True)
hn.d3heatmap(summarize=True)

# Plot static graph
hn.plot(summarize=True)
hn.d3graph(summarize=True, charge=1000)

Feature importance

# Plot feature importance
hn.plot_feat_importance(marker_size=50)

Performance

Citation

Please cite hnet in your publications if this is useful for your research! You can find it in the right panel.

Maintainer

Erdogan Taskesen, github: [erdogant](https://github.com/erdogant)
Contributions are welcome.

Star it if you like it!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hnet-1.1.10.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hnet-1.1.10-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file hnet-1.1.10.tar.gz.

File metadata

  • Download URL: hnet-1.1.10.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5

File hashes

Hashes for hnet-1.1.10.tar.gz
Algorithm Hash digest
SHA256 39656669111a0e9bc759fc9ab229217f3d2895c88dbe756e74e3d60ec8a5b1ce
MD5 b410599deb261315391d92674a10f0ed
BLAKE2b-256 68b453687468f3288a011d1187e3088bc9f4f74ca6b961ce7bebc935f29640a7

See more details on using hashes here.

File details

Details for the file hnet-1.1.10-py3-none-any.whl.

File metadata

  • Download URL: hnet-1.1.10-py3-none-any.whl
  • Upload date:
  • Size: 49.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5

File hashes

Hashes for hnet-1.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 00f0a711de03a65c0dc0f6727e04b9287195c4615b475de2251aa691c39aac02
MD5 34b2ee1a52903dccf9fde7ae9d568627
BLAKE2b-256 51a5c5048c8c138028d44628d15988ad398a25bc2c3459a4fbfbbd052ca03b9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page