iita-python 1.3__tar.gz → 1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {iita_python-1.3/iita_python.egg-info → iita_python-1.4}/PKG-INFO +1 -1
- iita_python-1.4/iita_python/_version.py +24 -0
- iita_python-1.4/iita_python/dataset.py +91 -0
- {iita_python-1.3 → iita_python-1.4/iita_python.egg-info}/PKG-INFO +1 -1
- iita_python-1.3/iita_python/_version.py +0 -34
- iita_python-1.3/iita_python/dataset.py +0 -95
- {iita_python-1.3 → iita_python-1.4}/.github/workflows/release.yaml +0 -0
- {iita_python-1.3 → iita_python-1.4}/.gitignore +0 -0
- {iita_python-1.3 → iita_python-1.4}/README.md +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python/__init__.py +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python/additional_ce.py +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python/fit_metrics.py +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python/quasiorder.py +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python/utils.py +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python.egg-info/SOURCES.txt +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python.egg-info/dependency_links.txt +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python.egg-info/requires.txt +0 -0
- {iita_python-1.3 → iita_python-1.4}/iita_python.egg-info/top_level.txt +0 -0
- {iita_python-1.3 → iita_python-1.4}/pyproject.toml +0 -0
- {iita_python-1.3 → iita_python-1.4}/setuf.cfg +0 -0
- {iita_python-1.3 → iita_python-1.4}/setup.cfg +0 -0
- {iita_python-1.3 → iita_python-1.4}/setup.py +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '1.4'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 4)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g8439da544'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import numpy.typing as npt
|
|
3
|
+
from typing import Self, List
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
class Dataset():
|
|
7
|
+
# full name aliases for response patterns, counterexamples and equivalence examples
|
|
8
|
+
@property
|
|
9
|
+
def response_patterns(self) -> pd.DataFrame:
|
|
10
|
+
return self.rp
|
|
11
|
+
@response_patterns.setter
|
|
12
|
+
def response_patterns(self, inp: pd.DataFrame) -> None:
|
|
13
|
+
self.rp = inp
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def counterexamples(self) -> pd.DataFrame:
|
|
17
|
+
return self.ce
|
|
18
|
+
@counterexamples.setter
|
|
19
|
+
def counterexamples(self, inp: pd.DataFrame) -> None:
|
|
20
|
+
self.ce = inp
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def equiv_examples(self) -> pd.DataFrame:
|
|
24
|
+
return self.eqe
|
|
25
|
+
@equiv_examples.setter
|
|
26
|
+
def equiv_examples(self, inp: pd.DataFrame) -> None:
|
|
27
|
+
self.eqe = inp
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def items(self):
|
|
31
|
+
return self.rp.shape[1]
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def subjects(self):
|
|
35
|
+
return self.rp.shape[0]
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def filled_vals(self):
|
|
39
|
+
return (np.logical_not(np.isnan(self.rp)).astype(int)).sum(axis=0)
|
|
40
|
+
|
|
41
|
+
def __init__(self, response_patterns: pd.DataFrame | npt.NDArray | List[List[int]]):
|
|
42
|
+
"""
|
|
43
|
+
Computes counterexamples, equivalence examples and valid CE cases from response patterns\n
|
|
44
|
+
Supports pandas dataframes, numpy arrays, and python lists\n
|
|
45
|
+
Rows represent the subjects, columns - the items\n
|
|
46
|
+
"""
|
|
47
|
+
self.rp = pd.DataFrame(response_patterns)
|
|
48
|
+
self.ce = None
|
|
49
|
+
self.eqe = None
|
|
50
|
+
|
|
51
|
+
rp_numpy = self.rp.to_numpy()
|
|
52
|
+
|
|
53
|
+
# setting missing values (NaN) to 0
|
|
54
|
+
rp_no_nan = np.nan_to_num(rp_numpy, 0) # NaN to 0
|
|
55
|
+
not_rp_no_nan = np.logical_not(np.nan_to_num(rp_numpy, 1)).astype(int) # NaN to 1, negated to 0
|
|
56
|
+
|
|
57
|
+
# counterexamples computation
|
|
58
|
+
# all cases where a=0 and b=1 (counterexamples to b->a or a <= b)
|
|
59
|
+
self.ce = pd.DataFrame(not_rp_no_nan.T @ rp_no_nan, index=self.rp.columns, columns=self.rp.columns)
|
|
60
|
+
|
|
61
|
+
# equivalence examples computation
|
|
62
|
+
# all cases where a=b, equivalent to ((a and b) or (~a and ~b))
|
|
63
|
+
a_and_b = rp_no_nan.T @ rp_no_nan
|
|
64
|
+
not_a_and_not_b = (not_rp_no_nan).T @ (not_rp_no_nan)
|
|
65
|
+
self.eqe = pd.DataFrame(a_and_b + not_a_and_not_b, index=self.rp.columns, columns=self.rp.columns)
|
|
66
|
+
|
|
67
|
+
# valid CE cases computation
|
|
68
|
+
rp_isnt_nan = np.logical_not(np.isnan(rp_numpy)).astype(int)
|
|
69
|
+
self.valid_ce_cases = pd.DataFrame(rp_isnt_nan.T @ rp_isnt_nan, index=self.rp.columns, columns=self.rp.columns)
|
|
70
|
+
|
|
71
|
+
def add(self, dataset_to_add: Self):
|
|
72
|
+
"""
|
|
73
|
+
Add a second IITA_Dataset: concatenate the response patterns, add CE, EQE and valid CE cases\n
|
|
74
|
+
Item amounts must match, else ValueError
|
|
75
|
+
"""
|
|
76
|
+
if (self.items != dataset_to_add.items):
|
|
77
|
+
raise ValueError('Item amounts must match')
|
|
78
|
+
|
|
79
|
+
self.rp = pd.concat(self.rp, dataset_to_add.rp)
|
|
80
|
+
self.ce = self.ce + dataset_to_add.ce
|
|
81
|
+
self.eqe = self.eqe + dataset_to_add.eqe
|
|
82
|
+
self.valid_ce_cases = self.valid_ce_cases + dataset_to_add.valid_ce_cases
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def relative_ce(self) -> pd.DataFrame:
|
|
86
|
+
"""
|
|
87
|
+
Returns the counterexamples matrix accounting for missing values
|
|
88
|
+
"""
|
|
89
|
+
return self.ce / self.valid_ce_cases
|
|
90
|
+
|
|
91
|
+
__iadd__ = add
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# file generated by setuptools-scm
|
|
2
|
-
# don't change, don't track in version control
|
|
3
|
-
|
|
4
|
-
__all__ = [
|
|
5
|
-
"__version__",
|
|
6
|
-
"__version_tuple__",
|
|
7
|
-
"version",
|
|
8
|
-
"version_tuple",
|
|
9
|
-
"__commit_id__",
|
|
10
|
-
"commit_id",
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
TYPE_CHECKING = False
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
from typing import Tuple
|
|
16
|
-
from typing import Union
|
|
17
|
-
|
|
18
|
-
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
-
COMMIT_ID = Union[str, None]
|
|
20
|
-
else:
|
|
21
|
-
VERSION_TUPLE = object
|
|
22
|
-
COMMIT_ID = object
|
|
23
|
-
|
|
24
|
-
version: str
|
|
25
|
-
__version__: str
|
|
26
|
-
__version_tuple__: VERSION_TUPLE
|
|
27
|
-
version_tuple: VERSION_TUPLE
|
|
28
|
-
commit_id: COMMIT_ID
|
|
29
|
-
__commit_id__: COMMIT_ID
|
|
30
|
-
|
|
31
|
-
__version__ = version = '1.3'
|
|
32
|
-
__version_tuple__ = version_tuple = (1, 3)
|
|
33
|
-
|
|
34
|
-
__commit_id__ = commit_id = 'g087a84930'
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
import numpy.typing as npt
|
|
3
|
-
from typing import Self, List
|
|
4
|
-
import pandas as pd
|
|
5
|
-
|
|
6
|
-
class Dataset():
|
|
7
|
-
#aliases for response_patterns, counterexamples, equiv_examples
|
|
8
|
-
@property
|
|
9
|
-
def rp(self) -> pd.DataFrame:
|
|
10
|
-
return self._rp
|
|
11
|
-
@rp.setter
|
|
12
|
-
def rp(self, inp: pd.DataFrame) -> None:
|
|
13
|
-
self._rp = inp
|
|
14
|
-
response_patterns = rp
|
|
15
|
-
|
|
16
|
-
@property
|
|
17
|
-
def ce(self) -> pd.DataFrame:
|
|
18
|
-
return self._ce
|
|
19
|
-
@ce.setter
|
|
20
|
-
def ce(self, inp: pd.DataFrame) -> None:
|
|
21
|
-
self._ce = inp
|
|
22
|
-
counterexamples = ce
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def eqe(self) -> pd.DataFrame:
|
|
26
|
-
return self._eqe
|
|
27
|
-
@eqe.setter
|
|
28
|
-
def eqe(self, inp: pd.DataFrame) -> None:
|
|
29
|
-
self._eqe = inp
|
|
30
|
-
equiv_examples = eqe
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def items(self):
|
|
34
|
-
return self.rp.shape[1]
|
|
35
|
-
|
|
36
|
-
@property
|
|
37
|
-
def subjects(self):
|
|
38
|
-
return self.rp.shape[0]
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def filled_vals(self):
|
|
42
|
-
return (~np.isnan(self.rp)).sum(axis=0)
|
|
43
|
-
|
|
44
|
-
def __init__(self, response_patterns: pd.DataFrame | npt.NDArray | List[List[int]]):
|
|
45
|
-
"""
|
|
46
|
-
Computes the counterexamples and equivalence examples from response patterns\n
|
|
47
|
-
Supports pandas dataframes, numpy arrays, and python lists\n
|
|
48
|
-
Rows represent the subjects, columns - the items\n
|
|
49
|
-
"""
|
|
50
|
-
self._rp = pd.DataFrame(response_patterns)
|
|
51
|
-
self._ce = None
|
|
52
|
-
self._eqe = None
|
|
53
|
-
|
|
54
|
-
#counterexamples computation
|
|
55
|
-
self.ce = pd.DataFrame(0, index=self.rp.columns, columns=self.rp.columns)
|
|
56
|
-
|
|
57
|
-
for i in range(self.subjects):
|
|
58
|
-
#for subject i, increment all cases where a=0 and b=1 (counterexamples to b->a or a <= b)
|
|
59
|
-
not_a = (self.rp.iloc[i] == 0)
|
|
60
|
-
b = (self.rp.iloc[i] == 1)
|
|
61
|
-
self.ce.loc[not_a, b] += 1
|
|
62
|
-
|
|
63
|
-
#equivalence examples computation
|
|
64
|
-
self.eqe = pd.DataFrame(0, index=self.rp.columns, columns=self.rp.columns)
|
|
65
|
-
for i in range(self.subjects):
|
|
66
|
-
#for subject i, increment all cases where a=b (examples of equivalence of a and b)
|
|
67
|
-
row = self.rp.iloc[i].to_numpy()
|
|
68
|
-
self.eqe += np.equal.outer(row, row).astype(int)
|
|
69
|
-
|
|
70
|
-
self.valid_ce_cases = pd.DataFrame(0, index=self.rp.columns, columns=self.rp.columns)
|
|
71
|
-
for i in range(self.subjects):
|
|
72
|
-
#for subject i, increment all cases where neither a nor b are NaN (valid case for counterexamples)
|
|
73
|
-
not_nan = np.logical_not(self.rp.iloc[i].isna())
|
|
74
|
-
self.valid_ce_cases += np.outer(not_nan, not_nan).astype(int)
|
|
75
|
-
|
|
76
|
-
def add(self, dataset_to_add: Self):
|
|
77
|
-
"""
|
|
78
|
-
Add a second IITA_Dataset: concatenate the response patterns, add counterexamples and equivalence examples\n
|
|
79
|
-
Item amounts must match, else ValueError
|
|
80
|
-
"""
|
|
81
|
-
if (self.items != dataset_to_add.items):
|
|
82
|
-
raise ValueError('Item amounts must match')
|
|
83
|
-
|
|
84
|
-
self.rp = pd.concat(self.rp, dataset_to_add.rp)
|
|
85
|
-
self.ce = self.ce + dataset_to_add.ce
|
|
86
|
-
self.eqe = self.eqe + dataset_to_add.eqe
|
|
87
|
-
|
|
88
|
-
@property
|
|
89
|
-
def relative_ce(self) -> pd.DataFrame:
|
|
90
|
-
"""
|
|
91
|
-
Returns the counterexamples matrix accounting for missing values
|
|
92
|
-
"""
|
|
93
|
-
return self.ce / self.valid_ce_cases
|
|
94
|
-
|
|
95
|
-
__iadd__ = add
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|