Skip to main content

license PyPI version PyPI downloads Build Status Open Source Love

regrank implements a collection of regularized, convex models (+solvers) that allow the inference of hierarchical structure in a directed network, which exists due to dominance, social status, or prestige. Specifically, this work leverages the time-varying structure and/or the node metadata present in the data set.

This is the software repository behind the paper:

  • Tzu-Chi Yen and Stephen Becker, Regularized methods for efficient ranking in networks, in preparation.
  • For full documentation, please visit this site.
  • General Q&A, ideas, or other things, please visit Discussions.
  • Software-related bugs, issues, or suggestions, please use Issues.

Installation

regrank is available on PyPI. It also depends on graph-tool. We recommend using conda to manage packages.

conda create --name regrank-dev -c conda-forge graph-tool
conda activate regrank-dev
pip install regrank

Example

# Import the library
import regrank as rr

# Load a data set
g = rr.datasets.us_air_traffic()

# Create a model
model = rr.optimize.regrank(method="annotated")

# Fit the model: We decided to analyze the `state_abr` nodal metadata,
# We may inspect `g.list_properties()` for other metadata to analyze.
result = model.fit(g, alpha=1, lambd=0.5, goi="state_abr")

# Now, result["primal"] should have the rankings. We can compute a summary.
summary = rr.compute_summary(g, "state_abr", primal_s=result["primal"])

Let's plot the rankings, via rr.plot_hist(summary). Note that most of the node categories are regularized to have the same mean ranking.

A histogram of four ranking groups, where most of the metadata share the same mean ranking.

We provided a summary via rr.print_summary_table(summary).

  +-------+-------+--------+-----------------------------------------+--------+---------+
  | Group | #Tags | #Nodes | Members                                 |   Mean |     Std |
  +-------+-------+--------+-----------------------------------------+--------+---------+
  | 1     |     5 |    825 | CA, WA, OR, TT, AK                      |  0.047 | 1.1e-02 |
  | 2     |     4 |    206 | TX, MT, PA, ID                          | -0.006 | 4.2e-03 |
  | 3     |    43 |   1243 | MI, IN, TN, NC, VA, IL, CO, WV, MA, WI, | -0.035 | 4.3e-03 |
  |       |       |        | SC, KY, MO, MD, AZ, PR, LA, UT, MN, GA, |        |         |
  |       |       |        | MS, HI, DE, NM, ME, NJ, NE, VT, CT, SD, |        |         |
  |       |       |        | IA, NV, ND, AL, OK, AR, NH, RI, OH, FL, |        |         |
  |       |       |        | KS, NY, WY                              |        |         |
  | 4     |     1 |      4 | VI                                      | -0.072 | 0.0e+00 |
  +-------+-------+--------+-----------------------------------------+--------+---------+

The result suggests that states such as CA, WA, or AK are significantly more popular than other states.

Data sets

We have a companion repo—regrank-data—for data sets used in the paper. Which are:

In addendum, we have provided the regrank.datasets submodule to load data sets hosted by other repositories, such as the Netzschleuder. See the docs for more information.

Development

The library uses pytest to ensure correctness. The test suite depends on mosek and gurobi.

License

regrank is open-source and licensed under the GNU Lesser General Public License v3.0.

Metadata

Release files for regrank 0.2.30

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regrank 0.2.30
File Size Uploaded
regrank-0.2.30.tar.gz 39.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for regrank 0.2.30
File Interpreter ABI Platform
regrank-0.2.30-py3-none-any.whl Python 3 none any Details

Total release size: 86.5 kB

Release files / regrank-0.2.30.tar.gz

Download URL regrank-0.2.30.tar.gz
Size 39.7 kB
Tags Source
SHA-256 checksum
How to use checksums
186ce19428760770b4bf5439377b8c6606bd768efed5d9c8717c530b067a68b6
BLAKE2b-256 checksum
How to use checksums
054a2da9badb5a1043fa2ed6b5497ec3eb2f601e5df8518795d91d48295bfd5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / regrank-0.2.30-py3-none-any.whl

Download URL regrank-0.2.30-py3-none-any.whl
Size 46.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55b31849d2dae3cc91f2ab9429cc9c0482c537588f3a8fd602e5eaedb2272221
BLAKE2b-256 checksum
How to use checksums
ab92a876db404cb8f8299abe1ab90269e73ac2869fa50d8cc0ce53459c1b12a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.30 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page