pyENA 0.1.4 0.1.4.9000

Development build 0.1.4.9000, built from main: its README, dependencies and API documentation may describe changes that are not released. For the latest release, see pyENA 0.1.4.

pyENA has been renamed to qe-ena. The files below are kept so existing installs keep working; new projects should install qe-ena.

Python ENA (Epistemic Network Analysis) modeling — sister package to rENA

Python >=3.10 · Source code

Also available for R: rENA · npm: @qe-libs/rena-wasm · Julia: rENA · C++ (Conan): rENA

Install

Install qe-ena instead. Do not pip install pyENA — that name may resolve to an unrelated project on PyPI.

Versions

Links in the wheel columns are the Python versions each wheel supports; pip and uv pick the right file automatically.

VersionPublishedSourceWheel
all platforms
0.1.4.90002026-10-06.tar.gzpy3
0.1.42026-10-06.tar.gzpy3
0.1.32026-10-06.tar.gzpy3
0.1.2—.tar.gzpy3
0.1.1—.tar.gzpy3
0.1.0—.tar.gzpy3

Dependencies

For 0.1.4.9000.

Description

pyena

Python implementation of Epistemic Network Analysis (ENA) — sister package to rENA.

pyena delegates all core math to pylibqe, the shared C++ library that also powers rENA.


Installation

pyena requires pylibqe. Install both from the QE package index:

pip install pyENA \
  --index-url https://qe-libs.org/py/simple/ \
  --extra-index-url https://pypi.org/simple/

Development install

pip install pylibqe \
  --index-url https://qe-libs.org/py/simple/ \
  --extra-index-url https://pypi.org/simple/

pip install -e ".[dev]"   # from python/ directory

Quick Start

import pandas as pd
from pyena import ENA

rs = pd.read_csv("../inst/extdata/rs.data.csv")   # rENA's RS.data

CODES = ["Data", "Technical Constraints", "Performance Parameters",
         "Client and Consultant Requests", "Design Reasoning", "Collaboration"]

# Units and conversations as rENA's RS.data examples: units by Condition +
# UserName, conversations by Condition + GroupName.
rs["unit_key"]  = rs["Condition"] + "::" + rs["UserName"]
rs["convo_key"] = rs["Condition"] + "::" + rs["GroupName"]

model = ENA().fit(rs, "unit_key", "convo_key", CODES, window_size=4)

Plotting

pyENA models plot with qeviz, the interactive ENA / ONA network viewer used by rENA (pip install qeviz --index-url https://qe-libs.org/py/simple/). The two conditions compared — FirstGame − SecondGame, with each group's mean and 95% confidence interval:

import qeviz

p = (qeviz.from_pyena(model, group_col="Condition", title="FirstGame − SecondGame")
       .edges("FirstGame", compare="SecondGame", color_scale="plot", magnify=3)
       .group())
p                              # displays inline in Jupyter
p.export_html("rs-data.html")  # or a self-contained HTML file

FirstGame − SecondGame network subtraction of RS.data with both group means

Blue edges are stronger in FirstGame, red in SecondGame. magnify=3 widens the edges to make a subtraction's small differences readable (the plot says so). See the qeviz README for single-group networks, unit points, and networks or means from your own data.


Accessing Results

model.line_weights_           # normalised adjacency vectors  (n_units × n_connections)
model.row_connection_counts_  # row-level raw adjacency vectors (n_rows × n_connections)
model.points_                 # unit positions in ENA space   (n_units × dims)
model.centroids_              # network centroids             (n_units × dims)
model.rotation_nodes_         # code node positions           (n_codes × dims)
model.connection_counts_      # raw unit adjacency vectors    (n_units × n_connections)
model.unit_labels_            # unit labels in order
model.connection_names_       # e.g. ["Data & Technical Constraints", ...]
model.variance_               # variance explained per dimension (= rENA's model$variance)

Separate Accumulation

from pyena import ENA, accumulate

accum = accumulate(rs, "unit_key", "convo_key", CODES, window_size=4)

accum.connection_counts_      # raw unit co-occurrence matrix
accum.row_connection_counts_  # raw row co-occurrence matrix
accum.unit_labels_            # unit labels
accum.connection_names_       # connection labels
accum.meta                    # per-unit metadata DataFrame

# Reuse the same accumulation with different rotations
from pyena import mean_rotation, generalized_rotation

model_svd = ENA().fit(accum)
model_mr  = ENA().fit(accum, rotation=mean_rotation(g1_mask, g2_mask))
model_gmr = ENA().fit(accum, rotation=generalized_rotation(meta["Condition"]))

Rotation Methods

Rotation Argument
SVD (default) rotation=None
Means mean_rotation(g1, g2)
Generalised (GMR) generalized_rotation(x_var)
Regression (V ~ x) regression_rotation(x_var)
Regression (x ~ V) regression_rotation_2(x_var)
Custom matrix rotation=my_ndarray
from pyena import ENA, mean_rotation, generalized_rotation, regression_rotation

meta = (rs.drop_duplicates("unit_key")
          .set_index("unit_key")
          .reindex(model.unit_labels_)
          .reset_index())

# Means rotation
model_mr = ENA().accumulate(rs, "unit_key", "convo_key", CODES).fit(
    rotation=mean_rotation(
        meta["Condition"] == "FirstGame",
        meta["Condition"] == "SecondGame",
    )
)

# Generalised rotation
model_gmr = ENA().accumulate(rs, "unit_key", "convo_key", CODES).fit(
    rotation=generalized_rotation(meta["Condition"])
)

# Regression rotation
import numpy as np
condition_bin = (meta["Condition"] == "FirstGame").astype(float).to_numpy()
model_reg = ENA().accumulate(rs, "unit_key", "convo_key", CODES).fit(
    rotation=regression_rotation(condition_bin)
)

Window Options

Option Argument
Window back window_size=4
Window forward window_forward=2
Infinite window window_size=sys.maxsize
Binary co-occurrence binary=True
Weighted co-occurrence binary=False

Further Reading

All files and SHA-256 hashes (12)
FileSizeSHA-256
pyena-0.1.4.9000.tar.gz23.0 KBca3ecd0e6e4195a75e2408e7c7b43d2895e854b8707cc2ef84b688e4127f687d
pyena-0.1.4.9000-py3-none-any.whl17.4 KB31945d96a1a2958c33bf8ace25737f5f793c88d99eb9a21f6a14e87f007bf50e
pyena-0.1.4.tar.gz23.0 KBef736be5842bd449172b83542cf0ab10188e8d874b33eab5dea4385051574c9b
pyena-0.1.4-py3-none-any.whl17.4 KB9c6a6ad7e846c7fc694724c5afb0cce65b5f5ce8027ec4d2f247694552cdafc7
pyena-0.1.3.tar.gz22.4 KBe35aae1bac7e16ec84e61a046df7a9672e3e298e3cab8aed4c79ca46edf431a1
pyena-0.1.3-py3-none-any.whl15.5 KB2df2b3b81594d1b70d6023674c1a8cd57aa7312957746806572c660bdc5daa0a
pyena-0.1.2.tar.gz22.1 KB4d26427e5b27a614b69641ed26f2cc018b6886d102418417b674677a5d491226
pyena-0.1.2-py3-none-any.whl15.3 KB0393dd7cd2763da9eb75d0c51168ba08e85cb8a4cb2936b15df0f8c9b1fd05a1
pyena-0.1.1.tar.gz19.9 KB184072a6f3a3c43f7d9d6ae04ba428d67239758e7c3cfc01d2c18a9b7530f787
pyena-0.1.1-py3-none-any.whl13.9 KB57082758e52ac55ebdd0452ed8404e322faf51f4c784b4bba6fd3c262ef2ec62
pyena-0.1.0.tar.gz19.4 KBda809c0a04c7105088af863b1845d3c080d4c0df501dbf5e20c184182afef945
pyena-0.1.0-py3-none-any.whl13.7 KB420ce42d81a52b8a2307ce26dd4fb88429c2bff344b7377081aba84ded94eb1f