|
133 | 133 | "output_type": "stream", |
134 | 134 | "name": "stdout", |
135 | 135 | "text": [ |
136 | | - "\nTraining started for batch: 1\n- number of soft clauses: 93\n- number of Boolean variables: 157\n- number of hard and soft clauses: 863\n\n\nBatch tarining complete\n- number of literals in the rule: 2\n- number of training errors: 3 out of 49\n\nTraining started for batch: 2\n- number of soft clauses: 95\n- number of Boolean variables: 161\n- number of hard and soft clauses: 890\n\n\nBatch tarining complete\n- number of literals in the rule: 4\n- number of training errors: 1 out of 51\n" |
| 136 | + "(100, 11)\n\nTraining started for batch: 1\n- number of soft clauses: 93\n- number of Boolean variables: 157\n- number of hard and soft clauses: 863\n\n\nBatch tarining complete\n- number of literals in the rule: 2\n- number of training errors: 3 out of 49\n\nTraining started for batch: 2\n- number of soft clauses: 95\n- number of Boolean variables: 161\n- number of hard and soft clauses: 890\n\n\nBatch tarining complete\n- number of literals in the rule: 4\n- number of training errors: 1 out of 51\n(100, 11)\n" |
137 | 137 | ] |
138 | 138 | } |
139 | 139 | ], |
|
150 | 150 | }, |
151 | 151 | { |
152 | 152 | "cell_type": "code", |
153 | | - "execution_count": 6, |
| 153 | + "execution_count": 8, |
154 | 154 | "metadata": { |
155 | 155 | "tags": [] |
156 | 156 | }, |
|
168 | 168 | "print(classification_report(y_train, model.predict(X_train), target_names=['0','1']))\n", |
169 | 169 | "print()\n", |
170 | 170 | "print(\"test report: \")\n", |
171 | | - "print(classification_report(y_test, model.predict(X_test), target_names=['0','1']))\n", |
172 | | - "\n" |
| 171 | + "print(classification_report(y_test, model.predict(X_test), target_names=['0','1']))\n" |
173 | 172 | ] |
174 | 173 | }, |
175 | 174 | { |
|
181 | 180 | }, |
182 | 181 | { |
183 | 182 | "cell_type": "code", |
184 | | - "execution_count": 7, |
| 183 | + "execution_count": 9, |
185 | 184 | "metadata": { |
186 | 185 | "tags": [] |
187 | 186 | }, |
|
212 | 211 | }, |
213 | 212 | { |
214 | 213 | "cell_type": "code", |
215 | | - "execution_count": 8, |
| 214 | + "execution_count": 10, |
216 | 215 | "metadata": { |
217 | 216 | "tags": [] |
218 | 217 | }, |
|
223 | 222 | }, |
224 | 223 | { |
225 | 224 | "cell_type": "code", |
226 | | - "execution_count": 9, |
| 225 | + "execution_count": 13, |
227 | 226 | "metadata": { |
228 | 227 | "tags": [] |
229 | 228 | }, |
|
232 | 231 | "output_type": "stream", |
233 | 232 | "name": "stdout", |
234 | 233 | "text": [ |
235 | | - "training report: \n precision recall f1-score support\n\n 0 0.93 0.98 0.96 65\n 1 0.97 0.86 0.91 35\n\n accuracy 0.94 100\n macro avg 0.95 0.92 0.93 100\nweighted avg 0.94 0.94 0.94 100\n\n\ntest report: \n precision recall f1-score support\n\n 0 0.97 1.00 0.99 35\n 1 1.00 0.93 0.97 15\n\n accuracy 0.98 50\n macro avg 0.99 0.97 0.98 50\nweighted avg 0.98 0.98 0.98 50\n\n\n( not sepal length >= 7.05 AND petal width = (0.8 - 1.75) ) OR \n( petal length = (2.45 - 4.75))\n\n[[-2, 9], [6]]\n" |
| 234 | + "training report: \n precision recall f1-score support\n\n 0 0.93 0.98 0.96 65\n 1 0.97 0.86 0.91 35\n\n accuracy 0.94 100\n macro avg 0.95 0.92 0.93 100\nweighted avg 0.94 0.94 0.94 100\n\n\ntest report: \n precision recall f1-score support\n\n 0 0.97 1.00 0.99 35\n 1 1.00 0.93 0.97 15\n\n accuracy 0.98 50\n macro avg 0.99 0.97 0.98 50\nweighted avg 0.98 0.98 0.98 50\n\n\nRule:->\n( not sepal length >= 7.05 AND petal width = (0.8 - 1.75) ) OR \n( petal length = (2.45 - 4.75))\n\nOriginal features:\n['sepal length < 5.45', 'sepal length = (5.45 - 7.05)', 'sepal length >= 7.05', 'sepal width < 2.95', 'sepal width >= 2.95', 'petal length < 2.45', 'petal length = (2.45 - 4.75)', 'petal length >= 4.75', 'petal width < 0.8', 'petal width = (0.8 - 1.75)', 'petal width >= 1.75']\n\nIn the learned rule, show original index in the feature list with phase (1: original, -1: complemented)\n[[(2, -1), (9, 1)], [(6, 1)]]\n" |
236 | 235 | ] |
237 | 236 | } |
238 | 237 | ], |
|
246 | 245 | "print(\"test report: \")\n", |
247 | 246 | "print(classification_report(y_test, model.predict(X_test), target_names=['0','1']))\n", |
248 | 247 | "\n", |
249 | | - "print()\n", |
| 248 | + "print(\"\\nRule:->\")\n", |
250 | 249 | "print(model.get_rule(features))\n", |
251 | | - "print()\n", |
| 250 | + "print(\"\\nOriginal features:\")\n", |
| 251 | + "print(features)\n", |
| 252 | + "print(\"\\nIn the learned rule, show original index in the feature list with phase (1: original, -1: complemented)\")\n", |
252 | 253 | "print(model.get_selected_column_index())" |
253 | 254 | ] |
254 | 255 | }, |
|
266 | 267 | }, |
267 | 268 | { |
268 | 269 | "cell_type": "code", |
269 | | - "execution_count": 10, |
| 270 | + "execution_count": 14, |
270 | 271 | "metadata": {}, |
271 | 272 | "outputs": [], |
272 | 273 | "source": [ |
|
275 | 276 | }, |
276 | 277 | { |
277 | 278 | "cell_type": "code", |
278 | | - "execution_count": 11, |
| 279 | + "execution_count": 15, |
279 | 280 | "metadata": { |
280 | 281 | "tags": [] |
281 | 282 | }, |
|
284 | 285 | "output_type": "stream", |
285 | 286 | "name": "stdout", |
286 | 287 | "text": [ |
287 | | - "training report: \n precision recall f1-score support\n\n 0 0.96 0.98 0.97 65\n 1 0.97 0.91 0.94 35\n\n accuracy 0.96 100\n macro avg 0.96 0.95 0.96 100\nweighted avg 0.96 0.96 0.96 100\n\n\ntest report: \n precision recall f1-score support\n\n 0 0.97 1.00 0.99 35\n 1 1.00 0.93 0.97 15\n\n accuracy 0.98 50\n macro avg 0.99 0.97 0.98 50\nweighted avg 0.98 0.98 0.98 50\n\n" |
| 288 | + "training report: \n precision recall f1-score support\n\n 0 0.91 0.31 0.46 65\n 1 0.42 0.94 0.58 35\n\n accuracy 0.53 100\n macro avg 0.67 0.63 0.52 100\nweighted avg 0.74 0.53 0.50 100\n\n\ntest report: \n precision recall f1-score support\n\n 0 0.90 0.26 0.40 35\n 1 0.35 0.93 0.51 15\n\n accuracy 0.46 50\n macro avg 0.62 0.60 0.45 50\nweighted avg 0.73 0.46 0.43 50\n\n" |
288 | 289 | ] |
289 | 290 | } |
290 | 291 | ], |
|
310 | 311 | }, |
311 | 312 | { |
312 | 313 | "cell_type": "code", |
313 | | - "execution_count": 12, |
| 314 | + "execution_count": 16, |
314 | 315 | "metadata": { |
315 | 316 | "tags": [] |
316 | 317 | }, |
|
319 | 320 | "output_type": "stream", |
320 | 321 | "name": "stdout", |
321 | 322 | "text": [ |
322 | | - "Learned rule is: \n\nAn Iris flower is predicted as Iris Versicolor if\n[ ( sepal width >= 2.95 + petal length = (2.45 - 4.75) + petal width = (0.8 - 1.75) + not sepal length >= 7.05 )>= 3 ] +\n[ ( )>= 0 ] >= 2\n\nThrehosld on clause: 2\nThreshold on literals: (this is a list where the entries denote threholds on literals on all clauses)\n[3, 0]\n" |
| 323 | + "Learned rule is: \n\nAn Iris flower is predicted as Iris Versicolor if\n[ ( petal width = (0.8 - 1.75) + not sepal length >= 7.05 )>= 1 ] +\n[ ( sepal width >= 2.95 + petal length = (2.45 - 4.75) )>= 1 ] >= 2\n\nThrehosld on clause: 2\nThreshold on literals: (this is a list where the entries denote threholds on literals on all clauses)\n[1, 1]\n" |
323 | 324 | ] |
324 | 325 | } |
325 | 326 | ], |
|
329 | 330 | "print(\"An Iris flower is predicted as Iris Versicolor if\")\n", |
330 | 331 | "print(rule)\n", |
331 | 332 | "print(\"\\nThrehosld on clause:\", model.get_threshold_clause())\n", |
332 | | - "print(\"Threshold on literals: (this is a list where the entries denote threholds on literals on all clauses)\")\n", |
| 333 | + "print(\"Threshold on literals: (this is a list where entries denote threholds on literals on all clauses)\")\n", |
333 | 334 | "print(model.get_threshold_literal())" |
334 | 335 | ] |
335 | 336 | }, |
|
0 commit comments