Skip to main content

IITA algorithm in python

Project description

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 correct
  • eqe: equivalence examples - pairs (i, j) where subject answered items i and j identically
  • items: number of items
  • subjects: number of subjects
  • filled_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:

  1. Estimates an error rate from counterexamples on edges in the quasi-order
  2. Predicts expected counterexamples for all item pairs under the quasi-order
  3. Computes mean squared error between observed and expected counterexamples

Returns: float (MSE, lower is better)

Requirements

  • Python >= 3.8
  • numpy
  • pandas

Testing

See the testing branch. 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

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)

Project details


Download files

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

Source Distribution

iita_python-1.3.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

iita_python-1.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file iita_python-1.3.tar.gz.

File metadata

  • Download URL: iita_python-1.3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iita_python-1.3.tar.gz
Algorithm Hash digest
SHA256 30d744c912caf431cb9ee244740073281312a1ea752c741a91a1c1c5713f223b
MD5 91fed2f1bd79667f749bc9b6d92c261c
BLAKE2b-256 752f11aee9e3a49f154c56fbd41fd9af999c0e71110f8c7823c0ca2b8e4f9687

See more details on using hashes here.

Provenance

The following attestation bundles were made for iita_python-1.3.tar.gz:

Publisher: release.yaml on Alexe1900/iita_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iita_python-1.3-py3-none-any.whl.

File metadata

  • Download URL: iita_python-1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iita_python-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 17ed1ce04bb3b6e092d9ddbb9f462e7c63a708dbf14506fc22ade9eb79f12388
MD5 23c0bce979f5ec45f5faae48fd599fad
BLAKE2b-256 a1bbfd3ea2fe39a5f6ead9a9fcd0640c714cebf16c582ecb9adb54e8290b99a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for iita_python-1.3-py3-none-any.whl:

Publisher: release.yaml on Alexe1900/iita_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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