A Python package for Knowledge Space Theory
Project description
kstpy
General package informaation
Remarks
- Please note that is an early stage package.
- Especially the functions in the
kstpy.basicsmodule may be rather inefficient.
Installation from PyPI
$ pip install kstpy
License
kstpy was created by Cord Hockemeyer. It is licensed under the terms of the GNU General Public License v3.0 license.
Credits
- The
graphicxmodule is a copy of Simon Hegele'shasseNetworkxmodule from GitHub. I opted for this way because I did not find any comparable Python package. kstpywas created withcookiecutterand thepy-pkgs-cookiecuttertemplate.
Modules and functions overview
Gwenerally, knowledge spaces and structures are stored as sets of kstFrozensets (see below).
Module kstpy.helpers
This module provides several small functions and some classes to be used by the other modules.
A core element is the kstFrozenset class, a derivative of the builtin frozenset class. The diference is just the way of printing: the 'frozenset' is omitted and kstFroszensets are printed like normal sets.
The functions of this module are
itemname: Produce an itemname corresponding to a number. We start with single lowercase letter ('a' to 'z'), then two-letter string ('aa' to 'zz') and finally three-letter strings ('aaa' to 'zzz'). This gives a some 18,000 different item names---and that should suffice.nitemnames: Produce a list ofcountitem names.domain: Determine the domain of a knowledge structure or data set, i.e. the union of allkstF>rozensets in a given set or list.srdomain: Determine the domain of a surmise relation, i.e. all elements in a set of 2-tuples.reduceSR: DSelete transitivities from a relation.powerset: Produce the power set for a given domain.vector2kstFrozenset: ThekstFrozensetfor a set specified as binary vector. This is used for reading structure files.kstFrozenset2vecrtor: A Binary vector corresponding to akstFrozenset. This is used for writing structure files.
Module kstpy.basics
The basicsmodule focuses on functions working with the different represenatations of knowledge spaces.
constr: Closing a knowledge structure und union, i.e. computing the corresponding knowledge space.basis: The counterpart computing the basis for a knowledge space (or structure).surmiserelation: Compiutes the surmise relation for a knowledge structure. (Surmise) relations are stored as sets of 2-tuples.sr2basis: Determine the basis of the knowledge space corresponding to a giben surmise relation.neighbourhood: The neighbourhood is the set of neighbouring knowledge states within a knowledge structure.fringe: The fringe is the set of items by which a knowledge ste differs from its neighbours. We distinguish the inner fringe, i.e. the set of items distinguishing a state from its smaller neighbours, and the outer fringe, i.e. the set of items distinguishing a state from its larger neighbours.equivalence: Determine the equivalence classes of items for a knowledge structure, i.e. the groups of items which are exactly in the same knowledge states.gradationsandlearningpaths: A gradation is a path from a smaller state s1 to a larger state s2 where each step means adding exactly one item. Learning paths are gradations from the empty set to the full set.trace: The trace of a knowledge structure/space is its reduction to a subset of items.
Module kstpy.graphics
Most parts of this module were taken from teh internet (see Credits above). The following functions are meant for the end user:
hassedraws a Hasse diagram for a knowledge structure/space.sr_hassedoes the same for a surmise relation.
Module kstpy.io
Functions for reading and writing KST files.
The classical format starts with a line cotaining the number of items and a line with the number of states/patterns. Then there follows a binary matrix describing the structure/data with columns for items and rows for states/patterns. This matrix does not contain any spaces.
The reading functions also accept a leading line starting with a hash sign ('#') thus allowing for the SRBT file formats.
readPatterns: Read a data file. Data are internally stored as lists ofkstFrozensets.readstructure: Read a knowledge structure or basis (more generally, any family of sets)writekst: Write a structure of data file.
Module kstpy.simulation
This module contains functions for BLIM--based (Basic Local Independence Model) simulations.
simpleSimulation: Simulate with a beta and an eta value equal for all itemssimulation: Simulate with beta and eta values different for each item.
Module kstpy.validation
distvec: Compute a list of distances between the response patterns and the knowledge structuredifreq: Determine the frequency distribution within the distance vectordi: Compute the Discrepancy Index between data set and knowledge structure.da: Compute the Distance Agreement Coefficient between data set and knowledge structure.
Usage
from kstpy.data import xpl_base
from kstpy.basics import constr
print(constr(xpl_base))
For further information, please have a look at the API reference.
print(constr(xpl_base))
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kstpy-1.0.0.tar.gz.
File metadata
- Download URL: kstpy-1.0.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.8 Linux/4.18.0-553.47.1.el8_10.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baa8415543148a6d171b69183f07667532c88af647f74fa35db781f74cee5653
|
|
| MD5 |
ea9bd2e977d1fb10a2669b3739afdf86
|
|
| BLAKE2b-256 |
0edc6007122536f7ede3326c9c0c57dcf9774a8c447712545f07a1a49b1a564d
|
File details
Details for the file kstpy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kstpy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.8 Linux/4.18.0-553.47.1.el8_10.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a871c2ce9a034b2abb4a6a4b882b65fd904a2b372e7c11063b5230e4110830aa
|
|
| MD5 |
034607bef1b5dc9f470627dfeb1ab507
|
|
| BLAKE2b-256 |
bdaf3e31b340492503c0e371572ccf460cebc320d62868f8a1a885e75ec65712
|