iita-python 1.0.2__tar.gz → 1.1__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.0.2/iita_python.egg-info → iita_python-1.1}/PKG-INFO +1 -1
- {iita_python-1.0.2 → iita_python-1.1}/iita_python/_version.py +3 -3
- {iita_python-1.0.2 → iita_python-1.1}/iita_python/dataset.py +14 -1
- {iita_python-1.0.2 → iita_python-1.1}/iita_python/quasiorder.py +3 -13
- {iita_python-1.0.2 → iita_python-1.1/iita_python.egg-info}/PKG-INFO +1 -1
- {iita_python-1.0.2 → iita_python-1.1}/iita_python.egg-info/SOURCES.txt +1 -5
- iita_python-1.0.2/test_ipynbs/fit_metrics.ipynb +0 -235
- iita_python-1.0.2/test_ipynbs/pisa.csv +0 -340
- iita_python-1.0.2/test_ipynbs/quasi-order-gen.ipynb +0 -219
- iita_python-1.0.2/test_ipynbs/sim_missing_data.ipynb +0 -176
- {iita_python-1.0.2 → iita_python-1.1}/.github/workflows/release.yaml +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/.gitignore +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/README.md +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/iita_python/__init__.py +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/iita_python/fit_metrics.py +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/iita_python/utils.py +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/iita_python.egg-info/dependency_links.txt +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/iita_python.egg-info/requires.txt +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/iita_python.egg-info/top_level.txt +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/pyproject.toml +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/setuf.cfg +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/setup.cfg +0 -0
- {iita_python-1.0.2 → iita_python-1.1}/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.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 1)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g0c3bef126'
|
|
@@ -55,7 +55,7 @@ class Dataset():
|
|
|
55
55
|
self.ce = pd.DataFrame(0, index=np.arange(self.rp.shape[1]), columns=np.arange(self.rp.shape[1]))
|
|
56
56
|
|
|
57
57
|
for i in range(len(self.rp)):
|
|
58
|
-
#for subject i,
|
|
58
|
+
#for subject i, increment all cases where a=0 and b=1 (counterexamples to b->a or a <= b)
|
|
59
59
|
not_a = (self.rp.loc[i] == 0)
|
|
60
60
|
b = (self.rp.loc[i] == 1)
|
|
61
61
|
self.ce.loc[not_a, b] += 1
|
|
@@ -66,6 +66,12 @@ class Dataset():
|
|
|
66
66
|
#for subject i, increment all cases where a=b (examples of equivalence of a and b)
|
|
67
67
|
row = self.rp.loc[i].to_numpy()
|
|
68
68
|
self.eqe += np.equal.outer(row, row).astype(int)
|
|
69
|
+
|
|
70
|
+
self.valid_ce_cases = pd.DataFrame(0, index=np.arange(self.rp.shape[1]), columns=np.arange(self.rp.shape[1]))
|
|
71
|
+
for i in range(len(self.rp)):
|
|
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.loc[i].isna())
|
|
74
|
+
self.valid_ce_cases += np.outer(not_nan, not_nan).astype(int)
|
|
69
75
|
|
|
70
76
|
def add(self, dataset_to_add: Self):
|
|
71
77
|
"""
|
|
@@ -78,5 +84,12 @@ class Dataset():
|
|
|
78
84
|
self.rp = pd.concat(self.rp, dataset_to_add.rp)
|
|
79
85
|
self.ce = self.ce + dataset_to_add.ce
|
|
80
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
|
|
81
94
|
|
|
82
95
|
__iadd__ = add
|
|
@@ -23,30 +23,20 @@ class QuasiOrder:
|
|
|
23
23
|
return edge_list
|
|
24
24
|
|
|
25
25
|
def unfold_examples(
|
|
26
|
-
matrix: pd.DataFrame
|
|
27
|
-
relativity: npt.NDArray | None = None,
|
|
28
|
-
dtype=np.float32
|
|
26
|
+
matrix: pd.DataFrame
|
|
29
27
|
) -> npt.NDArray:
|
|
30
28
|
"""
|
|
31
29
|
Turns an item/item metric DataFrame into
|
|
32
30
|
a list of tuples of the form (x, [i, j]), where matrix[i, j] = x.\n
|
|
33
|
-
Can input a relativity matrix, then exery x gets divided by relativity[i, j].
|
|
34
|
-
This can be used to account for missing values
|
|
35
31
|
"""
|
|
36
32
|
|
|
37
|
-
dfmatrix = pd.DataFrame(matrix)
|
|
38
|
-
|
|
39
|
-
rel = relativity
|
|
40
|
-
if (rel is None):
|
|
41
|
-
rel = np.ones(dfmatrix.shape, dtype=int)
|
|
42
|
-
|
|
43
|
-
dfmatrix = dfmatrix / rel
|
|
33
|
+
dfmatrix = pd.DataFrame(matrix)
|
|
44
34
|
|
|
45
35
|
n = dfmatrix.shape[0]
|
|
46
36
|
pos = np.arange(n, dtype=np.int_)
|
|
47
37
|
i = np.repeat(pos, n)
|
|
48
38
|
j = np.tile(pos, n)
|
|
49
|
-
res = np.array(list(zip(dfmatrix.to_numpy()[i, j], i, j))
|
|
39
|
+
res = np.array(list(zip(dfmatrix.to_numpy()[i, j], i, j)))
|
|
50
40
|
return res[res[:, 1] != res[:, 2]]
|
|
51
41
|
|
|
52
42
|
def ind_gen(counterexamples: npt.NDArray, n: int) -> list[QuasiOrder]:
|
|
@@ -14,8 +14,4 @@ iita_python.egg-info/PKG-INFO
|
|
|
14
14
|
iita_python.egg-info/SOURCES.txt
|
|
15
15
|
iita_python.egg-info/dependency_links.txt
|
|
16
16
|
iita_python.egg-info/requires.txt
|
|
17
|
-
iita_python.egg-info/top_level.txt
|
|
18
|
-
test_ipynbs/fit_metrics.ipynb
|
|
19
|
-
test_ipynbs/pisa.csv
|
|
20
|
-
test_ipynbs/quasi-order-gen.ipynb
|
|
21
|
-
test_ipynbs/sim_missing_data.ipynb
|
|
17
|
+
iita_python.egg-info/top_level.txt
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cells": [
|
|
3
|
-
{
|
|
4
|
-
"cell_type": "markdown",
|
|
5
|
-
"id": "aefc5a77",
|
|
6
|
-
"metadata": {
|
|
7
|
-
"id": "aefc5a77"
|
|
8
|
-
},
|
|
9
|
-
"source": [
|
|
10
|
-
"# Testing the fit metric calculation on the PISA dataset, comparing to the KST library by Milan Segedinac"
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"cell_type": "markdown",
|
|
15
|
-
"source": [
|
|
16
|
-
"1. Imporitng both libraries and requirements"
|
|
17
|
-
],
|
|
18
|
-
"metadata": {
|
|
19
|
-
"id": "dzpt8hYXs7kO"
|
|
20
|
-
},
|
|
21
|
-
"id": "dzpt8hYXs7kO"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"cell_type": "code",
|
|
25
|
-
"source": [
|
|
26
|
-
"!git clone https://github.com/Alexe1900/iita_python.git\n",
|
|
27
|
-
"!git clone https://github.com/milansegedinac/kst.git\n",
|
|
28
|
-
"!pip install numpy\n",
|
|
29
|
-
"!pip install pandas\n",
|
|
30
|
-
"import sys\n",
|
|
31
|
-
"sys.path.append(\"/content/iita_python\")\n",
|
|
32
|
-
"sys.path.append(\"/content/kst\")\n",
|
|
33
|
-
"import numpy as np\n",
|
|
34
|
-
"import pandas as pd\n",
|
|
35
|
-
"import iita_python as test_iita\n",
|
|
36
|
-
"import learning_spaces.kst as kst"
|
|
37
|
-
],
|
|
38
|
-
"metadata": {
|
|
39
|
-
"id": "s4P_gsz7tDlG",
|
|
40
|
-
"outputId": "03b37282-44e0-43f1-996e-ba3de8248eab",
|
|
41
|
-
"colab": {
|
|
42
|
-
"base_uri": "https://localhost:8080/"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"id": "s4P_gsz7tDlG",
|
|
46
|
-
"execution_count": 1,
|
|
47
|
-
"outputs": [
|
|
48
|
-
{
|
|
49
|
-
"output_type": "stream",
|
|
50
|
-
"name": "stdout",
|
|
51
|
-
"text": [
|
|
52
|
-
"fatal: destination path 'iita_python' already exists and is not an empty directory.\n",
|
|
53
|
-
"fatal: destination path 'kst' already exists and is not an empty directory.\n",
|
|
54
|
-
"Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (2.0.2)\n",
|
|
55
|
-
"Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (2.2.2)\n",
|
|
56
|
-
"Requirement already satisfied: numpy>=1.26.0 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.0.2)\n",
|
|
57
|
-
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.9.0.post0)\n",
|
|
58
|
-
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
|
|
59
|
-
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
|
|
60
|
-
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"cell_type": "markdown",
|
|
67
|
-
"source": [
|
|
68
|
-
"2. Importing the dataset, generating quasi-orders"
|
|
69
|
-
],
|
|
70
|
-
"metadata": {
|
|
71
|
-
"id": "Wwxr0c_rtSMN"
|
|
72
|
-
},
|
|
73
|
-
"id": "Wwxr0c_rtSMN"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"cell_type": "code",
|
|
77
|
-
"source": [
|
|
78
|
-
"from iita_python.utils import read_rp\n",
|
|
79
|
-
"\n",
|
|
80
|
-
"data_raw = read_rp(\"iita_python/test_ipynbs/pisa.csv\")\n",
|
|
81
|
-
"data = test_iita.Dataset(data_raw)\n",
|
|
82
|
-
"\n",
|
|
83
|
-
"unfolded_ce = test_iita.unfold_examples(data.counterexamples)\n",
|
|
84
|
-
"qos = test_iita.ind_gen(unfolded_ce, data.items)"
|
|
85
|
-
],
|
|
86
|
-
"metadata": {
|
|
87
|
-
"id": "7CZKj4kktWg6"
|
|
88
|
-
},
|
|
89
|
-
"id": "7CZKj4kktWg6",
|
|
90
|
-
"execution_count": 2,
|
|
91
|
-
"outputs": []
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"cell_type": "markdown",
|
|
95
|
-
"source": [
|
|
96
|
-
"3. Testing the fit metrics"
|
|
97
|
-
],
|
|
98
|
-
"metadata": {
|
|
99
|
-
"id": "t-RqTjTEuBUo"
|
|
100
|
-
},
|
|
101
|
-
"id": "t-RqTjTEuBUo"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"cell_type": "markdown",
|
|
105
|
-
"source": [
|
|
106
|
-
"3.1. Original IITA fit metric"
|
|
107
|
-
],
|
|
108
|
-
"metadata": {
|
|
109
|
-
"id": "oXyUJR12jT22"
|
|
110
|
-
},
|
|
111
|
-
"id": "oXyUJR12jT22"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"cell_type": "code",
|
|
115
|
-
"source": [
|
|
116
|
-
"import iita_python.fit_metrics as test_fit\n",
|
|
117
|
-
"corrects = kst.iita(data.response_patterns, 3)['diff']\n",
|
|
118
|
-
"\n",
|
|
119
|
-
"for i, qo in enumerate(qos):\n",
|
|
120
|
-
" test_metric = round(test_fit.orig_iita_fit(data, qo), 3)\n",
|
|
121
|
-
" corr_metric = round(corrects[i], 3)\n",
|
|
122
|
-
"\n",
|
|
123
|
-
" try:\n",
|
|
124
|
-
" assert (test_metric == corr_metric)\n",
|
|
125
|
-
" print(f'Fit metric {i}/{len(qos)} correct ✅')\n",
|
|
126
|
-
" except AssertionError:\n",
|
|
127
|
-
" print(f'Fit metric {i}/{len(qos)} incorrect ❌')\n",
|
|
128
|
-
" print(f'Test: {test_metric}')\n",
|
|
129
|
-
" print(f'Correct: {corr_metric}')"
|
|
130
|
-
],
|
|
131
|
-
"metadata": {
|
|
132
|
-
"id": "a5IvxR1I7-BG",
|
|
133
|
-
"outputId": "abc3c1be-79b3-4721-9c7c-a6e0e6669ba7",
|
|
134
|
-
"colab": {
|
|
135
|
-
"base_uri": "https://localhost:8080/"
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
"id": "a5IvxR1I7-BG",
|
|
139
|
-
"execution_count": 8,
|
|
140
|
-
"outputs": [
|
|
141
|
-
{
|
|
142
|
-
"output_type": "stream",
|
|
143
|
-
"name": "stdout",
|
|
144
|
-
"text": [
|
|
145
|
-
"Fit metric 0/13 correct ✅\n",
|
|
146
|
-
"Fit metric 1/13 correct ✅\n",
|
|
147
|
-
"Fit metric 2/13 correct ✅\n",
|
|
148
|
-
"Fit metric 3/13 correct ✅\n",
|
|
149
|
-
"Fit metric 4/13 correct ✅\n",
|
|
150
|
-
"Fit metric 5/13 correct ✅\n",
|
|
151
|
-
"Fit metric 6/13 correct ✅\n",
|
|
152
|
-
"Fit metric 7/13 correct ✅\n",
|
|
153
|
-
"Fit metric 8/13 correct ✅\n",
|
|
154
|
-
"Fit metric 9/13 correct ✅\n",
|
|
155
|
-
"Fit metric 10/13 correct ✅\n",
|
|
156
|
-
"Fit metric 11/13 correct ✅\n",
|
|
157
|
-
"Fit metric 12/13 correct ✅\n"
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"cell_type": "markdown",
|
|
164
|
-
"source": [
|
|
165
|
-
"3.2. Corrected fit metric"
|
|
166
|
-
],
|
|
167
|
-
"metadata": {
|
|
168
|
-
"id": "VIPtCas5jXP3"
|
|
169
|
-
},
|
|
170
|
-
"id": "VIPtCas5jXP3"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"cell_type": "code",
|
|
174
|
-
"source": [
|
|
175
|
-
"corrects = kst.iita(data.response_patterns, 2)['diff']\n",
|
|
176
|
-
"\n",
|
|
177
|
-
"for i, qo in enumerate(qos):\n",
|
|
178
|
-
" test_metric = round(test_fit.corr_iita_fit(data, qo), 3)\n",
|
|
179
|
-
" corr_metric = round(corrects[i], 3)\n",
|
|
180
|
-
"\n",
|
|
181
|
-
" try:\n",
|
|
182
|
-
" assert (test_metric == corr_metric)\n",
|
|
183
|
-
" print(f'Fit metric {i}/{len(qos)} correct ✅')\n",
|
|
184
|
-
" except AssertionError:\n",
|
|
185
|
-
" print(f'Fit metric {i}/{len(qos)} incorrect ❌')\n",
|
|
186
|
-
" print(f'Test: {test_metric}')\n",
|
|
187
|
-
" print(f'Correct: {corr_metric}')"
|
|
188
|
-
],
|
|
189
|
-
"metadata": {
|
|
190
|
-
"id": "j1LoyigWjc5t",
|
|
191
|
-
"outputId": "bd2ca738-1a94-4ce8-b507-325a1acdf9e1",
|
|
192
|
-
"colab": {
|
|
193
|
-
"base_uri": "https://localhost:8080/"
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
"id": "j1LoyigWjc5t",
|
|
197
|
-
"execution_count": 9,
|
|
198
|
-
"outputs": [
|
|
199
|
-
{
|
|
200
|
-
"output_type": "stream",
|
|
201
|
-
"name": "stdout",
|
|
202
|
-
"text": [
|
|
203
|
-
"Fit metric 0/13 correct ✅\n",
|
|
204
|
-
"Fit metric 1/13 correct ✅\n",
|
|
205
|
-
"Fit metric 2/13 correct ✅\n",
|
|
206
|
-
"Fit metric 3/13 correct ✅\n",
|
|
207
|
-
"Fit metric 4/13 correct ✅\n",
|
|
208
|
-
"Fit metric 5/13 correct ✅\n",
|
|
209
|
-
"Fit metric 6/13 correct ✅\n",
|
|
210
|
-
"Fit metric 7/13 correct ✅\n",
|
|
211
|
-
"Fit metric 8/13 correct ✅\n",
|
|
212
|
-
"Fit metric 9/13 correct ✅\n",
|
|
213
|
-
"Fit metric 10/13 correct ✅\n",
|
|
214
|
-
"Fit metric 11/13 correct ✅\n",
|
|
215
|
-
"Fit metric 12/13 correct ✅\n"
|
|
216
|
-
]
|
|
217
|
-
}
|
|
218
|
-
]
|
|
219
|
-
}
|
|
220
|
-
],
|
|
221
|
-
"metadata": {
|
|
222
|
-
"language_info": {
|
|
223
|
-
"name": "python"
|
|
224
|
-
},
|
|
225
|
-
"colab": {
|
|
226
|
-
"provenance": []
|
|
227
|
-
},
|
|
228
|
-
"kernelspec": {
|
|
229
|
-
"name": "python3",
|
|
230
|
-
"display_name": "Python 3"
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
"nbformat": 4,
|
|
234
|
-
"nbformat_minor": 5
|
|
235
|
-
}
|
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
1,0,0,0,0
|
|
2
|
-
0,0,0,0,0
|
|
3
|
-
1,0,0,0,0
|
|
4
|
-
1,0,0,0,0
|
|
5
|
-
0,1,0,0,0
|
|
6
|
-
1,1,0,0,0
|
|
7
|
-
0,0,0,0,0
|
|
8
|
-
1,1,0,0,1
|
|
9
|
-
1,1,0,0,0
|
|
10
|
-
1,1,0,0,0
|
|
11
|
-
1,0,0,0,0
|
|
12
|
-
1,1,0,0,0
|
|
13
|
-
0,0,0,0,0
|
|
14
|
-
1,0,0,0,0
|
|
15
|
-
1,0,0,0,0
|
|
16
|
-
1,0,0,0,0
|
|
17
|
-
0,0,0,0,0
|
|
18
|
-
1,1,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|
121
|
-
1,1,0,0,0
|
|
122
|
-
1,1,0,0,0
|
|
123
|
-
1,1,0,0,0
|
|
124
|
-
0,0,0,1,0
|
|
125
|
-
0,0,0,0,0
|
|
126
|
-
1,0,0,0,0
|
|
127
|
-
1,0,0,0,0
|
|
128
|
-
0,0,0,0,0
|
|
129
|
-
0,1,0,0,0
|
|
130
|
-
0,0,0,0,0
|
|
131
|
-
1,0,0,0,0
|
|
132
|
-
0,1,0,0,0
|
|
133
|
-
1,1,0,0,0
|
|
134
|
-
0,0,0,0,0
|
|
135
|
-
1,1,0,0,0
|
|
136
|
-
1,1,0,0,0
|
|
137
|
-
1,0,0,1,0
|
|
138
|
-
0,0,0,0,0
|
|
139
|
-
0,1,0,0,0
|
|
140
|
-
0,1,0,0,0
|
|
141
|
-
1,1,0,0,0
|
|
142
|
-
1,0,0,0,0
|
|
143
|
-
1,1,0,0,0
|
|
144
|
-
1,1,0,0,0
|
|
145
|
-
1,0,0,0,0
|
|
146
|
-
0,1,0,0,1
|
|
147
|
-
1,1,0,0,0
|
|
148
|
-
1,1,0,1,0
|
|
149
|
-
1,0,0,0,0
|
|
150
|
-
0,1,0,0,1
|
|
151
|
-
1,0,0,0,0
|
|
152
|
-
1,1,0,0,0
|
|
153
|
-
0,0,0,0,0
|
|
154
|
-
0,0,0,0,0
|
|
155
|
-
1,1,0,0,0
|
|
156
|
-
0,1,0,0,0
|
|
157
|
-
0,0,0,0,0
|
|
158
|
-
0,0,0,0,0
|
|
159
|
-
0,0,0,0,0
|
|
160
|
-
1,0,0,0,0
|
|
161
|
-
0,1,1,0,0
|
|
162
|
-
1,1,1,0,0
|
|
163
|
-
1,0,1,0,0
|
|
164
|
-
1,1,1,0,0
|
|
165
|
-
0,1,1,1,0
|
|
166
|
-
1,1,1,1,0
|
|
167
|
-
1,1,1,1,1
|
|
168
|
-
1,1,1,0,0
|
|
169
|
-
0,0,1,0,0
|
|
170
|
-
1,1,1,1,1
|
|
171
|
-
1,1,1,0,0
|
|
172
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0
|
|
326
|
-
1,1,1,0,0
|
|
327
|
-
1,1,1,1,0
|
|
328
|
-
0,1,1,0,0
|
|
329
|
-
1,0,1,1,0
|
|
330
|
-
1,1,1,0,0
|
|
331
|
-
1,0,1,0,0
|
|
332
|
-
0,0,1,0,0
|
|
333
|
-
0,0,1,0,0
|
|
334
|
-
0,1,0,0,0
|
|
335
|
-
0,1,0,0,0
|
|
336
|
-
0,1,0,0,0
|
|
337
|
-
1,0,0,0,0
|
|
338
|
-
1,0,0,0,0
|
|
339
|
-
0,0,0,0,0
|
|
340
|
-
0,0,0,0,0
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cells": [
|
|
3
|
-
{
|
|
4
|
-
"cell_type": "markdown",
|
|
5
|
-
"metadata": {
|
|
6
|
-
"id": "cw9gSDCONN4s"
|
|
7
|
-
},
|
|
8
|
-
"source": [
|
|
9
|
-
"# Testing the quasi-order generation on the PISA dataset, comparing to the KST library by Milan Segedinac"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"cell_type": "markdown",
|
|
14
|
-
"metadata": {
|
|
15
|
-
"id": "gH1gF08aNy22"
|
|
16
|
-
},
|
|
17
|
-
"source": [
|
|
18
|
-
"1. Importing both libraries and requirements"
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"cell_type": "code",
|
|
23
|
-
"execution_count": null,
|
|
24
|
-
"metadata": {
|
|
25
|
-
"colab": {
|
|
26
|
-
"base_uri": "https://localhost:8080/"
|
|
27
|
-
},
|
|
28
|
-
"id": "bvA-pXFUN36a",
|
|
29
|
-
"outputId": "fefbb9ca-5eb1-41ec-da36-fc31f7de1093"
|
|
30
|
-
},
|
|
31
|
-
"outputs": [
|
|
32
|
-
{
|
|
33
|
-
"name": "stdout",
|
|
34
|
-
"output_type": "stream",
|
|
35
|
-
"text": [
|
|
36
|
-
"fatal: destination path 'iita_python' already exists and is not an empty directory.\n",
|
|
37
|
-
"fatal: destination path 'kst' already exists and is not an empty directory.\n",
|
|
38
|
-
"Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (2.0.2)\n",
|
|
39
|
-
"Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (2.2.2)\n",
|
|
40
|
-
"Requirement already satisfied: numpy>=1.26.0 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.0.2)\n",
|
|
41
|
-
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.9.0.post0)\n",
|
|
42
|
-
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
|
|
43
|
-
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
|
|
44
|
-
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n"
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
"source": [
|
|
49
|
-
"!git clone https://github.com/Alexe1900/iita_python.git\n",
|
|
50
|
-
"!git clone https://github.com/milansegedinac/kst.git\n",
|
|
51
|
-
"!pip install numpy\n",
|
|
52
|
-
"!pip install pandas\n",
|
|
53
|
-
"import sys\n",
|
|
54
|
-
"sys.path.append(\"/content/iita_python\")\n",
|
|
55
|
-
"sys.path.append(\"/content/kst\")\n",
|
|
56
|
-
"import numpy as np\n",
|
|
57
|
-
"import pandas as pd\n",
|
|
58
|
-
"import iita_python as iita\n",
|
|
59
|
-
"import learning_spaces.kst as kst"
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"cell_type": "markdown",
|
|
64
|
-
"metadata": {
|
|
65
|
-
"id": "CwlVMK3MO3QJ"
|
|
66
|
-
},
|
|
67
|
-
"source": [
|
|
68
|
-
"2. Importing the dataset"
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"cell_type": "code",
|
|
73
|
-
"execution_count": 3,
|
|
74
|
-
"metadata": {
|
|
75
|
-
"colab": {
|
|
76
|
-
"base_uri": "https://localhost:8080/"
|
|
77
|
-
},
|
|
78
|
-
"id": "FvSAv-4cOWQp",
|
|
79
|
-
"outputId": "4d1adf29-3d0c-40cf-d79d-9a8df3d9f945"
|
|
80
|
-
},
|
|
81
|
-
"outputs": [
|
|
82
|
-
{
|
|
83
|
-
"name": "stdout",
|
|
84
|
-
"output_type": "stream",
|
|
85
|
-
"text": [
|
|
86
|
-
"Data imported successfully ✅\n"
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
"source": [
|
|
91
|
-
"from iita_python.utils import read_rp\n",
|
|
92
|
-
"\n",
|
|
93
|
-
"data_raw = read_rp(\"iita_python/test_ipynbs/pisa.csv\")\n",
|
|
94
|
-
"assert not data_raw.empty\n",
|
|
95
|
-
"print(\"Data imported successfully ✅\")"
|
|
96
|
-
]
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"cell_type": "markdown",
|
|
100
|
-
"metadata": {
|
|
101
|
-
"id": "UVRNzocZTCZC"
|
|
102
|
-
},
|
|
103
|
-
"source": [
|
|
104
|
-
"3. Counting the counterexamples"
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"cell_type": "code",
|
|
109
|
-
"execution_count": 6,
|
|
110
|
-
"metadata": {
|
|
111
|
-
"colab": {
|
|
112
|
-
"base_uri": "https://localhost:8080/"
|
|
113
|
-
},
|
|
114
|
-
"id": "lWysv1UsTGPf",
|
|
115
|
-
"outputId": "d24fc04a-e60d-45c6-ce95-c77f859df45e"
|
|
116
|
-
},
|
|
117
|
-
"outputs": [
|
|
118
|
-
{
|
|
119
|
-
"name": "stdout",
|
|
120
|
-
"output_type": "stream",
|
|
121
|
-
"text": [
|
|
122
|
-
"Counterexamples computed correctly ✅\n"
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
|
-
"source": [
|
|
127
|
-
"data = iita.Dataset(data_raw)\n",
|
|
128
|
-
"\n",
|
|
129
|
-
"correct_ce = kst.ob_counter(data_raw)\n",
|
|
130
|
-
"\n",
|
|
131
|
-
"try:\n",
|
|
132
|
-
" assert (correct_ce == data.counterexamples.to_numpy()).all()\n",
|
|
133
|
-
" print(\"Counterexamples computed correctly ✅\")\n",
|
|
134
|
-
"except AssertionError:\n",
|
|
135
|
-
" print(\"Counterexamples computed incorrectly ❌\")\n"
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"cell_type": "markdown",
|
|
140
|
-
"metadata": {
|
|
141
|
-
"id": "H7X3tEf7bGdt"
|
|
142
|
-
},
|
|
143
|
-
"source": [
|
|
144
|
-
"4. Generating the quasi-orders"
|
|
145
|
-
]
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"cell_type": "code",
|
|
149
|
-
"execution_count": null,
|
|
150
|
-
"metadata": {
|
|
151
|
-
"colab": {
|
|
152
|
-
"base_uri": "https://localhost:8080/"
|
|
153
|
-
},
|
|
154
|
-
"id": "Ywvri9o8bGA0",
|
|
155
|
-
"outputId": "438b2adf-3bb1-4784-cab7-ff32228d5eab"
|
|
156
|
-
},
|
|
157
|
-
"outputs": [
|
|
158
|
-
{
|
|
159
|
-
"name": "stdout",
|
|
160
|
-
"output_type": "stream",
|
|
161
|
-
"text": [
|
|
162
|
-
"Correct number of quasi-orders ✅\n",
|
|
163
|
-
"Quasi-order 0/13 correct ✅\n",
|
|
164
|
-
"Quasi-order 1/13 correct ✅\n",
|
|
165
|
-
"Quasi-order 2/13 correct ✅\n",
|
|
166
|
-
"Quasi-order 3/13 correct ✅\n",
|
|
167
|
-
"Quasi-order 4/13 correct ✅\n",
|
|
168
|
-
"Quasi-order 5/13 correct ✅\n",
|
|
169
|
-
"Quasi-order 6/13 correct ✅\n",
|
|
170
|
-
"Quasi-order 7/13 correct ✅\n",
|
|
171
|
-
"Quasi-order 8/13 correct ✅\n",
|
|
172
|
-
"Quasi-order 9/13 correct ✅\n",
|
|
173
|
-
"Quasi-order 10/13 correct ✅\n",
|
|
174
|
-
"Quasi-order 11/13 correct ✅\n",
|
|
175
|
-
"Quasi-order 12/13 correct ✅\n"
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
],
|
|
179
|
-
"source": [
|
|
180
|
-
"correct_qos = kst.ind_gen(correct_ce)\n",
|
|
181
|
-
"\n",
|
|
182
|
-
"unfolded_ce = iita.unfold_examples(data.counterexamples)\n",
|
|
183
|
-
"test_qos = iita.ind_gen(unfolded_ce, data.items)\n",
|
|
184
|
-
"test_qos = [sorted([(int(a), int(b)) for a, b in qo.get_edge_list()]) for qo in test_qos]\n",
|
|
185
|
-
"\n",
|
|
186
|
-
"try:\n",
|
|
187
|
-
" assert len(correct_qos) == len(test_qos)\n",
|
|
188
|
-
" print(f'Correct number of quasi-orders ✅')\n",
|
|
189
|
-
"except AssertionError:\n",
|
|
190
|
-
" print(f'Wrong number of quasi-orders ❌')\n",
|
|
191
|
-
" quit()\n",
|
|
192
|
-
"\n",
|
|
193
|
-
"for i, (corr_qo, test_qo) in enumerate(zip(correct_qos, test_qos)):\n",
|
|
194
|
-
" corr_qo = sorted(corr_qo)\n",
|
|
195
|
-
" try:\n",
|
|
196
|
-
" assert corr_qo == test_qo\n",
|
|
197
|
-
" print(f'Quasi-order {i}/{len(correct_qos)} correct ✅')\n",
|
|
198
|
-
" except AssertionError:\n",
|
|
199
|
-
" print(f'Quasi-order {i}/{len(correct_qos)} incorrect ❌')\n",
|
|
200
|
-
" print(f'Test: {test_qo}')\n",
|
|
201
|
-
" print(f'Correct: {corr_qo}')"
|
|
202
|
-
]
|
|
203
|
-
}
|
|
204
|
-
],
|
|
205
|
-
"metadata": {
|
|
206
|
-
"colab": {
|
|
207
|
-
"provenance": []
|
|
208
|
-
},
|
|
209
|
-
"kernelspec": {
|
|
210
|
-
"display_name": "Python 3",
|
|
211
|
-
"name": "python3"
|
|
212
|
-
},
|
|
213
|
-
"language_info": {
|
|
214
|
-
"name": "python"
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
"nbformat": 4,
|
|
218
|
-
"nbformat_minor": 0
|
|
219
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cells": [
|
|
3
|
-
{
|
|
4
|
-
"cell_type": "markdown",
|
|
5
|
-
"id": "c534cd3f",
|
|
6
|
-
"metadata": {
|
|
7
|
-
"id": "c534cd3f"
|
|
8
|
-
},
|
|
9
|
-
"source": [
|
|
10
|
-
"# Testing on PISA dataset with randomized missing data"
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"cell_type": "markdown",
|
|
15
|
-
"source": [
|
|
16
|
-
"1. Importing package and dataset"
|
|
17
|
-
],
|
|
18
|
-
"metadata": {
|
|
19
|
-
"id": "1nLTjppYSRTe"
|
|
20
|
-
},
|
|
21
|
-
"id": "1nLTjppYSRTe"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"cell_type": "code",
|
|
25
|
-
"source": [
|
|
26
|
-
"!pip install iita_python\n",
|
|
27
|
-
"!git clone https://gist.github.com/717f0147675b0c8ed25e50d583c943bf.git\n",
|
|
28
|
-
"\n",
|
|
29
|
-
"import numpy as np\n",
|
|
30
|
-
"import iita_python as iita\n",
|
|
31
|
-
"import iita_python.fit_metrics as iita_fm\n",
|
|
32
|
-
"from iita_python.utils import read_rp\n",
|
|
33
|
-
"from random import randint\n",
|
|
34
|
-
"\n",
|
|
35
|
-
"data = read_rp('./717f0147675b0c8ed25e50d583c943bf/pisa.csv')"
|
|
36
|
-
],
|
|
37
|
-
"metadata": {
|
|
38
|
-
"id": "SlEiX6B1SSsU",
|
|
39
|
-
"outputId": "55bf001f-aba5-493c-a3a6-77da399684c0",
|
|
40
|
-
"colab": {
|
|
41
|
-
"base_uri": "https://localhost:8080/"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"id": "SlEiX6B1SSsU",
|
|
45
|
-
"execution_count": 8,
|
|
46
|
-
"outputs": [
|
|
47
|
-
{
|
|
48
|
-
"output_type": "stream",
|
|
49
|
-
"name": "stdout",
|
|
50
|
-
"text": [
|
|
51
|
-
"Requirement already satisfied: iita_python in /usr/local/lib/python3.12/dist-packages (0.0.post42)\n",
|
|
52
|
-
"Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (from iita_python) (2.0.2)\n",
|
|
53
|
-
"Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (from iita_python) (2.2.2)\n",
|
|
54
|
-
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas->iita_python) (2.9.0.post0)\n",
|
|
55
|
-
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas->iita_python) (2025.2)\n",
|
|
56
|
-
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas->iita_python) (2025.2)\n",
|
|
57
|
-
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas->iita_python) (1.17.0)\n",
|
|
58
|
-
"fatal: destination path '717f0147675b0c8ed25e50d583c943bf' already exists and is not an empty directory.\n"
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"cell_type": "markdown",
|
|
65
|
-
"source": [
|
|
66
|
-
"2. Testing function"
|
|
67
|
-
],
|
|
68
|
-
"metadata": {
|
|
69
|
-
"id": "jlvoh1yOata0"
|
|
70
|
-
},
|
|
71
|
-
"id": "jlvoh1yOata0"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"cell_type": "code",
|
|
75
|
-
"source": [
|
|
76
|
-
"def test(metric):\n",
|
|
77
|
-
" correct = True\n",
|
|
78
|
-
" correct_qo = None\n",
|
|
79
|
-
" correct_count = 0\n",
|
|
80
|
-
"\n",
|
|
81
|
-
" while (correct and correct_count < data.shape[0]*data.shape[1]):\n",
|
|
82
|
-
" print(f'doing {correct_count}')\n",
|
|
83
|
-
" test_dataset = iita.Dataset(data)\n",
|
|
84
|
-
" unfolded_ce = iita.unfold_examples(test_dataset.ce)\n",
|
|
85
|
-
" qos = iita.ind_gen(unfolded_ce, test_dataset.items)\n",
|
|
86
|
-
"\n",
|
|
87
|
-
" best_qo_id = -1\n",
|
|
88
|
-
" best_qo_diff = float('inf')\n",
|
|
89
|
-
" for i, qo in enumerate(qos):\n",
|
|
90
|
-
" qo_diff = metric(test_dataset, qo)\n",
|
|
91
|
-
" if (qo_diff < best_qo_diff):\n",
|
|
92
|
-
" best_qo_diff = qo_diff\n",
|
|
93
|
-
" best_qo_id = i\n",
|
|
94
|
-
"\n",
|
|
95
|
-
" best_qo = sorted([(int(a), int(b)) for a, b in qos[best_qo_id].get_edge_list()])\n",
|
|
96
|
-
" if (correct_qo is None):\n",
|
|
97
|
-
" correct_count += 1\n",
|
|
98
|
-
" correct_qo = best_qo\n",
|
|
99
|
-
" elif (best_qo != correct_qo):\n",
|
|
100
|
-
" correct = False\n",
|
|
101
|
-
" else:\n",
|
|
102
|
-
" correct_count += 1\n",
|
|
103
|
-
"\n",
|
|
104
|
-
" while (True):\n",
|
|
105
|
-
" a = randint(0, test_dataset.items - 1)\n",
|
|
106
|
-
" b = randint(0, test_dataset.subjects - 1)\n",
|
|
107
|
-
" if (not np.isnan(data[a][b])):\n",
|
|
108
|
-
" break;\n",
|
|
109
|
-
" data.loc[b, a] = np.nan\n",
|
|
110
|
-
"\n",
|
|
111
|
-
" return correct_count"
|
|
112
|
-
],
|
|
113
|
-
"metadata": {
|
|
114
|
-
"id": "ok9yLOnsTOU7"
|
|
115
|
-
},
|
|
116
|
-
"id": "ok9yLOnsTOU7",
|
|
117
|
-
"execution_count": 21,
|
|
118
|
-
"outputs": []
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"cell_type": "code",
|
|
122
|
-
"source": [
|
|
123
|
-
"res = test(iita_fm.orig_iita_fit)"
|
|
124
|
-
],
|
|
125
|
-
"metadata": {
|
|
126
|
-
"id": "giLvbXdtX4uc"
|
|
127
|
-
},
|
|
128
|
-
"id": "giLvbXdtX4uc",
|
|
129
|
-
"execution_count": null,
|
|
130
|
-
"outputs": []
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"cell_type": "code",
|
|
134
|
-
"source": [
|
|
135
|
-
"res"
|
|
136
|
-
],
|
|
137
|
-
"metadata": {
|
|
138
|
-
"id": "N2K347pebF9u",
|
|
139
|
-
"outputId": "b603f637-7b16-4161-eb18-4cf5ea12d989",
|
|
140
|
-
"colab": {
|
|
141
|
-
"base_uri": "https://localhost:8080/"
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"id": "N2K347pebF9u",
|
|
145
|
-
"execution_count": 23,
|
|
146
|
-
"outputs": [
|
|
147
|
-
{
|
|
148
|
-
"output_type": "execute_result",
|
|
149
|
-
"data": {
|
|
150
|
-
"text/plain": [
|
|
151
|
-
"525"
|
|
152
|
-
]
|
|
153
|
-
},
|
|
154
|
-
"metadata": {},
|
|
155
|
-
"execution_count": 23
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
}
|
|
159
|
-
],
|
|
160
|
-
"metadata": {
|
|
161
|
-
"kernelspec": {
|
|
162
|
-
"display_name": "iita",
|
|
163
|
-
"language": "python",
|
|
164
|
-
"name": "python3"
|
|
165
|
-
},
|
|
166
|
-
"language_info": {
|
|
167
|
-
"name": "python",
|
|
168
|
-
"version": "3.12.11"
|
|
169
|
-
},
|
|
170
|
-
"colab": {
|
|
171
|
-
"provenance": []
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
"nbformat": 4,
|
|
175
|
-
"nbformat_minor": 5
|
|
176
|
-
}
|
|
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
|