IITA_Python
A Python implementation of the Inductive ITem Tree Analysis (IITA) algorithm for analyzing and validating quasi-orderings in psychometric data.
Intended to replicate the functionality DAKS package from R, with an OOP-style interface for simpler functionality expansion
Installation
From PyPI
pip install iita_python
Quick Start
from iita_python import Dataset, ind_gen, unfold_examples, orig_iita_fit
import iita_python.utils as utils
# Load response patterns from CSV
response_patterns = utils.read_rp('data.csv')
# Create Dataset: computes counterexamples and equivalence examples
data = Dataset(response_patterns)
# Extract counterexamples and generate quasi-orderings
ce = unfold_examples(data.ce)
qos = ind_gen(ce, data.items)
# Evaluate fit for each quasi-order
for i, qo in enumerate(qos):
fit = orig_iita_fit(data, qo)
print(f"Quasi-order {i}: fit = {fit:.2f}")
Data Format
Input: Response Patterns
Response patterns should be a 2D array where:
- Rows represent subjects (respondents)
- Columns represent items (questions/tasks)
- Values are 0 (incorrect) or 1 (correct), with NaN for missing responses
Example (CSV):
1,0,1,0,1
0,0,1,0,1
1,1,1,1,1
When reading from a file with utils.read_rp(), missing data can be specified via the nan_vals parameter.
Core Modules
dataset.py
Dataset class
Stores response patterns and computes derived metrics:
rp: response patterns (DataFrame)ce: counterexamples - pairs (i, j) where subject has item i incorrect but item j correcteqe: equivalence examples - pairs (i, j) where subject answered items i and j identicallyitems: number of itemssubjects: number of subjectsfilled_vals: number of non-missing responses per item
quasiorder.py
unfold_examples(matrix, relativity=None, dtype=np.float32)
Converts a 2D matrix (e.g., counterexamples or equivalence examples) into a list of (value, i, j) tuples, excluding diagonal entries. Optionally normalizes by a relativity matrix.
ind_gen(counterexamples, n)
Generates candidate quasi-orderings from counterexample data. Returns a list of quasi-order matrices (numpy arrays) that progressively include edges.
get_edge_list(qo_matrix, buff=0)
Extracts the edge list from a quasi-order matrix as a list of (i, j) pairs.
fit_metrics.py
orig_iita_fit(data, qo)
Computes the fit of a quasi-order to observed data using Schrepp's method:
- Estimates an error rate from counterexamples on edges in the quasi-order
- Predicts expected counterexamples for all item pairs under the quasi-order
- Computes mean squared error between observed and expected counterexamples
Returns: float (MSE, lower is better)
Requirements
- Python >= 3.8
- numpy
- pandas
Testing
See the test_ipynbs folder. You can open the Jupyter notebooks in Google Colab and run all cells to see test results.
I am comparing my results on the PISA dataset to those of Milan Segedinac (his implementation)
Please report any test failures in an issue
Contributing
Pull requests and issues are welcome. For major changes, please open an issue first to discuss.
IITA Overview
Schrepp (1999, 2003) developed IITA (Inductive itemm Tree Analysis) as a means to derive a surmise relation from dichotomous response patterns. Sargin and Ünlü (2009; Ünlü & Sargin, 2010) implemented two advanced versions of that procedure.
The three inductive item tree analysis algorithms are exploratory methods for extracting quasi orders (surmise relations) from data. In each algorithm, competing binary relations are generated (in the same way for all three versions), and a fit measure (differing from version to version) is computed for every relation of the selection set in order to find the quasi order that fits the data best. In all three algorithms, the idea is to estimate the numbers of counterexamples for each quasi order, and to find, over all competing quasi orders, the minimum value for the discrepancy between the observed and expected numbers of counterexamples.
The three data analysis methods differ in their choices of estimates for the expected numbers of counterexamples. (For an item pair (i,j), the number of subjects solving item j but failing to solve item i, is the corresponding number of counterexamples. Their response patterns contradict the interpretation of (i,j) as `mastering item j implies mastering item i.')
References
- Schrepp, M. (2001). IITA: A program for the analysis of individual item and step matrices. Unpublished technical report.
- Knowledge Space Theory: https://en.wikipedia.org/wiki/Knowledge_space
Author
Alexe1900, mentored and supervised by Peter Steiner from PHSG St. Gallen
Roadmap
- Full DAKS functionality
- Performance optimizations for large datasets
- Visualization tools for quasi-orderings
- Comprehensive test suite (unit + integration)
Metadata
Release files for iita-python 0.0.post42
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| iita_python-0.0.post42.tar.gz | 11.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| iita_python-0.0.post42-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / iita_python-0.0.post42.tar.gz
| Download URL | iita_python-0.0.post42.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
584a3436ac994f18e9fdc1f8531a8f0e7b207bf71e543497a5ccc52dc5c211c3
|
|
BLAKE2b-256 checksum How to use checksums |
42061e5d551ea8084420c327c5cee3da426f5ef05a67229fecf313b099d20bd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 14, 2025.
Transparency logRelease files / iita_python-0.0.post42-py3-none-any.whl
| Download URL | iita_python-0.0.post42-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11c40d2e902fdee23be25abcca2b10a4bfbc531cbaa92553e1070ba7feb84c75
|
|
BLAKE2b-256 checksum How to use checksums |
810ed13351588c76cdcb8125458feca9fd81bcb81de0213d30973c2446764291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 14, 2025.
Transparency logSecurity for iita-python 0.0.post42
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for iita_python-0.0.post42.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 14, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.