iita-python 1.2__tar.gz → 1.3__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.2/iita_python.egg-info → iita_python-1.3}/PKG-INFO +1 -1
- iita_python-1.3/iita_python/__init__.py +5 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python/_version.py +3 -3
- {iita_python-1.2 → iita_python-1.3}/iita_python/additional_ce.py +8 -10
- {iita_python-1.2 → iita_python-1.3}/iita_python/dataset.py +8 -8
- {iita_python-1.2 → iita_python-1.3}/iita_python/quasiorder.py +6 -17
- {iita_python-1.2 → iita_python-1.3/iita_python.egg-info}/PKG-INFO +1 -1
- iita_python-1.2/iita_python/__init__.py +0 -4
- {iita_python-1.2 → iita_python-1.3}/.github/workflows/release.yaml +0 -0
- {iita_python-1.2 → iita_python-1.3}/.gitignore +0 -0
- {iita_python-1.2 → iita_python-1.3}/README.md +0 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python/fit_metrics.py +0 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python/utils.py +0 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python.egg-info/SOURCES.txt +0 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python.egg-info/dependency_links.txt +0 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python.egg-info/requires.txt +0 -0
- {iita_python-1.2 → iita_python-1.3}/iita_python.egg-info/top_level.txt +0 -0
- {iita_python-1.2 → iita_python-1.3}/pyproject.toml +0 -0
- {iita_python-1.2 → iita_python-1.3}/setuf.cfg +0 -0
- {iita_python-1.2 → iita_python-1.3}/setup.cfg +0 -0
- {iita_python-1.2 → iita_python-1.3}/setup.py +0 -0
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '1.
|
|
32
|
-
__version_tuple__ = version_tuple = (1,
|
|
31
|
+
__version__ = version = '1.3'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 3)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g087a84930'
|
|
@@ -15,12 +15,12 @@ def pairwise_diff_ce(rp: pd.DataFrame) -> pd.DataFrame:
|
|
|
15
15
|
items = rp.shape[1]
|
|
16
16
|
subjects = rp.shape[0]
|
|
17
17
|
|
|
18
|
-
ce = pd.DataFrame(0, index=
|
|
18
|
+
ce = pd.DataFrame(0, index=rp.columns, columns=rp.columns)
|
|
19
19
|
for i in range(subjects):
|
|
20
20
|
# for subject i, if a < b, add b - a for all item pairs (a,b)
|
|
21
21
|
# this is equivalent to ce[a][b] += 1 if a=0 and b=1, but works for non-binary data as well
|
|
22
22
|
|
|
23
|
-
row = rp.
|
|
23
|
+
row = rp.iloc[i].to_numpy()
|
|
24
24
|
ce -= np.clip(row[:, None] - row[None, :], None, 0)
|
|
25
25
|
|
|
26
26
|
return ce
|
|
@@ -39,10 +39,10 @@ def missing_value_substitution_ce(rp: pd.DataFrame) -> pd.DataFrame:
|
|
|
39
39
|
|
|
40
40
|
for i in range(items):
|
|
41
41
|
# substitute missing values in item i with the mean of the item
|
|
42
|
-
col = rp1.
|
|
42
|
+
col = rp1.iloc[:, i].to_numpy()
|
|
43
43
|
mean_val = np.nanmean(col)
|
|
44
44
|
col = pd.Series(col).fillna(mean_val)
|
|
45
|
-
rp1.
|
|
45
|
+
rp1.iloc[:, i] = col
|
|
46
46
|
|
|
47
47
|
# then calculate pairwise difference counterexamples
|
|
48
48
|
return pairwise_diff_ce(rp1)
|
|
@@ -64,10 +64,10 @@ def relativify(calculator: callable):
|
|
|
64
64
|
items = rp.shape[1]
|
|
65
65
|
subjects = rp.shape[0]
|
|
66
66
|
|
|
67
|
-
valid_cases = pd.DataFrame(0, index=
|
|
67
|
+
valid_cases = pd.DataFrame(0, index=rp.columns, columns=rp.columns)
|
|
68
68
|
for i in range(subjects):
|
|
69
69
|
#for subject i, increment all cases where neither a nor b are NaN (valid case for counterexamples)
|
|
70
|
-
not_nan = np.logical_not(rp.
|
|
70
|
+
not_nan = np.logical_not(rp.iloc[i].isna())
|
|
71
71
|
valid_cases += np.outer(not_nan, not_nan).astype(int)
|
|
72
72
|
|
|
73
73
|
# avoid division by zero
|
|
@@ -90,12 +90,10 @@ class AdditionalCEDataset(Dataset):
|
|
|
90
90
|
"""
|
|
91
91
|
super().__init__(response_patterns)
|
|
92
92
|
|
|
93
|
-
self.pairwise_diff_ce = lambda
|
|
94
|
-
relativify(pairwise_diff_ce) if relative else pairwise_diff_ce
|
|
95
|
-
)(self.rp)
|
|
93
|
+
self.pairwise_diff_ce = lambda: pairwise_diff_ce(self.rp)
|
|
96
94
|
self.pairwise_diff_ce.__doc__ = pairwise_diff_ce.__doc__
|
|
97
95
|
|
|
98
|
-
self.missing_value_substitution_ce = lambda
|
|
96
|
+
self.missing_value_substitution_ce = lambda relative=False: (
|
|
99
97
|
relativify(missing_value_substitution_ce) if relative else missing_value_substitution_ce
|
|
100
98
|
)(self.rp)
|
|
101
99
|
self.missing_value_substitution_ce.__doc__ = missing_value_substitution_ce.__doc__
|
|
@@ -47,30 +47,30 @@ class Dataset():
|
|
|
47
47
|
Supports pandas dataframes, numpy arrays, and python lists\n
|
|
48
48
|
Rows represent the subjects, columns - the items\n
|
|
49
49
|
"""
|
|
50
|
-
self._rp = pd.DataFrame(response_patterns
|
|
50
|
+
self._rp = pd.DataFrame(response_patterns)
|
|
51
51
|
self._ce = None
|
|
52
52
|
self._eqe = None
|
|
53
53
|
|
|
54
54
|
#counterexamples computation
|
|
55
|
-
self.ce = pd.DataFrame(0, index=
|
|
55
|
+
self.ce = pd.DataFrame(0, index=self.rp.columns, columns=self.rp.columns)
|
|
56
56
|
|
|
57
57
|
for i in range(self.subjects):
|
|
58
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.
|
|
60
|
-
b = (self.rp.
|
|
59
|
+
not_a = (self.rp.iloc[i] == 0)
|
|
60
|
+
b = (self.rp.iloc[i] == 1)
|
|
61
61
|
self.ce.loc[not_a, b] += 1
|
|
62
62
|
|
|
63
63
|
#equivalence examples computation
|
|
64
|
-
self.eqe = pd.DataFrame(0, index=
|
|
64
|
+
self.eqe = pd.DataFrame(0, index=self.rp.columns, columns=self.rp.columns)
|
|
65
65
|
for i in range(self.subjects):
|
|
66
66
|
#for subject i, increment all cases where a=b (examples of equivalence of a and b)
|
|
67
|
-
row = self.rp.
|
|
67
|
+
row = self.rp.iloc[i].to_numpy()
|
|
68
68
|
self.eqe += np.equal.outer(row, row).astype(int)
|
|
69
69
|
|
|
70
|
-
self.valid_ce_cases = pd.DataFrame(0, index=
|
|
70
|
+
self.valid_ce_cases = pd.DataFrame(0, index=self.rp.columns, columns=self.rp.columns)
|
|
71
71
|
for i in range(self.subjects):
|
|
72
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.
|
|
73
|
+
not_nan = np.logical_not(self.rp.iloc[i].isna())
|
|
74
74
|
self.valid_ce_cases += np.outer(not_nan, not_nan).astype(int)
|
|
75
75
|
|
|
76
76
|
def add(self, dataset_to_add: Self):
|
|
@@ -20,31 +20,20 @@ class QuasiOrder:
|
|
|
20
20
|
if (self.full_matrix[i][j]):
|
|
21
21
|
edge_list.append([i+buff, j+buff])
|
|
22
22
|
|
|
23
|
-
return edge_list
|
|
23
|
+
return edge_list
|
|
24
24
|
|
|
25
|
-
def
|
|
26
|
-
matrix: pd.DataFrame
|
|
27
|
-
) -> npt.NDArray:
|
|
25
|
+
def ind_gen(counterexamples: pd.DataFrame, n: int) -> list[QuasiOrder]:
|
|
28
26
|
"""
|
|
29
|
-
|
|
30
|
-
a list of tuples of the form (x, [i, j]), where matrix[i, j] = x.\n
|
|
27
|
+
Inductively generates quasiorders from counterexample count DataFrame\n
|
|
31
28
|
"""
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
dfce = pd.DataFrame(counterexamples)
|
|
34
31
|
|
|
35
|
-
n =
|
|
32
|
+
n = dfce.shape[0]
|
|
36
33
|
pos = np.arange(n, dtype=np.int_)
|
|
37
34
|
i = np.repeat(pos, n)
|
|
38
35
|
j = np.tile(pos, n)
|
|
39
|
-
|
|
40
|
-
return res[res[:, 1] != res[:, 2]]
|
|
41
|
-
|
|
42
|
-
def ind_gen(counterexamples: npt.NDArray, n: int) -> list[QuasiOrder]:
|
|
43
|
-
"""
|
|
44
|
-
Inductively generates quasiorders from counterexample edge list\n
|
|
45
|
-
Counterexamples is expected to be of the form returned by unfold_examples (array of (x, i, j) tuples)\n
|
|
46
|
-
"""
|
|
47
|
-
ce = counterexamples
|
|
36
|
+
ce = np.array(list(zip(dfce.to_numpy()[i, j], i, j)))
|
|
48
37
|
|
|
49
38
|
if (len(ce) == 0): raise ValueError("Counterexamples can't be empty")
|
|
50
39
|
|
|
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
|