Skip to content

Commit 130591f

Browse files
committed
updated showcase
1 parent 6fd271d commit 130591f

File tree

1 file changed

+120
-120
lines changed

1 file changed

+120
-120
lines changed

docs/Showcase.ipynb

Lines changed: 120 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
"execution_count": 1,
3636
"metadata": {
3737
"execution": {
38-
"iopub.execute_input": "2021-05-27T14:56:48.993849Z",
39-
"iopub.status.busy": "2021-05-27T14:56:48.993352Z",
40-
"iopub.status.idle": "2021-05-27T14:56:49.558972Z",
41-
"shell.execute_reply": "2021-05-27T14:56:49.557533Z",
42-
"shell.execute_reply.started": "2021-05-27T14:56:48.993760Z"
38+
"iopub.execute_input": "2021-10-01T10:36:19.231413Z",
39+
"iopub.status.busy": "2021-10-01T10:36:19.230773Z",
40+
"iopub.status.idle": "2021-10-01T10:36:19.879217Z",
41+
"shell.execute_reply": "2021-10-01T10:36:19.878124Z",
42+
"shell.execute_reply.started": "2021-10-01T10:36:19.231299Z"
4343
}
4444
},
4545
"outputs": [],
@@ -53,11 +53,11 @@
5353
"execution_count": 2,
5454
"metadata": {
5555
"execution": {
56-
"iopub.execute_input": "2021-05-27T14:56:49.561643Z",
57-
"iopub.status.busy": "2021-05-27T14:56:49.561210Z",
58-
"iopub.status.idle": "2021-05-27T14:56:49.612156Z",
59-
"shell.execute_reply": "2021-05-27T14:56:49.611219Z",
60-
"shell.execute_reply.started": "2021-05-27T14:56:49.561598Z"
56+
"iopub.execute_input": "2021-10-01T10:36:19.882154Z",
57+
"iopub.status.busy": "2021-10-01T10:36:19.881726Z",
58+
"iopub.status.idle": "2021-10-01T10:36:19.935280Z",
59+
"shell.execute_reply": "2021-10-01T10:36:19.933350Z",
60+
"shell.execute_reply.started": "2021-10-01T10:36:19.882116Z"
6161
}
6262
},
6363
"outputs": [],
@@ -73,11 +73,11 @@
7373
"execution_count": 3,
7474
"metadata": {
7575
"execution": {
76-
"iopub.execute_input": "2021-05-27T14:56:49.614455Z",
77-
"iopub.status.busy": "2021-05-27T14:56:49.614049Z",
78-
"iopub.status.idle": "2021-05-27T14:56:49.957067Z",
79-
"shell.execute_reply": "2021-05-27T14:56:49.956067Z",
80-
"shell.execute_reply.started": "2021-05-27T14:56:49.614419Z"
76+
"iopub.execute_input": "2021-10-01T10:36:19.937487Z",
77+
"iopub.status.busy": "2021-10-01T10:36:19.937069Z",
78+
"iopub.status.idle": "2021-10-01T10:36:20.284153Z",
79+
"shell.execute_reply": "2021-10-01T10:36:20.282776Z",
80+
"shell.execute_reply.started": "2021-10-01T10:36:19.937450Z"
8181
}
8282
},
8383
"outputs": [
@@ -104,11 +104,11 @@
104104
"execution_count": 4,
105105
"metadata": {
106106
"execution": {
107-
"iopub.execute_input": "2021-05-27T14:56:49.959238Z",
108-
"iopub.status.busy": "2021-05-27T14:56:49.958579Z",
109-
"iopub.status.idle": "2021-05-27T14:56:50.276226Z",
110-
"shell.execute_reply": "2021-05-27T14:56:50.275260Z",
111-
"shell.execute_reply.started": "2021-05-27T14:56:49.959200Z"
107+
"iopub.execute_input": "2021-10-01T10:36:20.285515Z",
108+
"iopub.status.busy": "2021-10-01T10:36:20.285239Z",
109+
"iopub.status.idle": "2021-10-01T10:36:20.653086Z",
110+
"shell.execute_reply": "2021-10-01T10:36:20.652340Z",
111+
"shell.execute_reply.started": "2021-10-01T10:36:20.285460Z"
112112
}
113113
},
114114
"outputs": [
@@ -135,11 +135,11 @@
135135
"execution_count": 5,
136136
"metadata": {
137137
"execution": {
138-
"iopub.execute_input": "2021-05-27T14:56:50.278680Z",
139-
"iopub.status.busy": "2021-05-27T14:56:50.278011Z",
140-
"iopub.status.idle": "2021-05-27T14:56:50.584819Z",
141-
"shell.execute_reply": "2021-05-27T14:56:50.583904Z",
142-
"shell.execute_reply.started": "2021-05-27T14:56:50.278641Z"
138+
"iopub.execute_input": "2021-10-01T10:36:20.654937Z",
139+
"iopub.status.busy": "2021-10-01T10:36:20.654490Z",
140+
"iopub.status.idle": "2021-10-01T10:36:20.989101Z",
141+
"shell.execute_reply": "2021-10-01T10:36:20.987471Z",
142+
"shell.execute_reply.started": "2021-10-01T10:36:20.654868Z"
143143
}
144144
},
145145
"outputs": [
@@ -166,11 +166,11 @@
166166
"execution_count": 6,
167167
"metadata": {
168168
"execution": {
169-
"iopub.execute_input": "2021-05-27T14:56:50.587353Z",
170-
"iopub.status.busy": "2021-05-27T14:56:50.586633Z",
171-
"iopub.status.idle": "2021-05-27T14:56:50.907252Z",
172-
"shell.execute_reply": "2021-05-27T14:56:50.906427Z",
173-
"shell.execute_reply.started": "2021-05-27T14:56:50.587296Z"
169+
"iopub.execute_input": "2021-10-01T10:36:20.991516Z",
170+
"iopub.status.busy": "2021-10-01T10:36:20.990949Z",
171+
"iopub.status.idle": "2021-10-01T10:36:21.304548Z",
172+
"shell.execute_reply": "2021-10-01T10:36:21.303396Z",
173+
"shell.execute_reply.started": "2021-10-01T10:36:20.991474Z"
174174
}
175175
},
176176
"outputs": [
@@ -204,11 +204,11 @@
204204
"execution_count": 7,
205205
"metadata": {
206206
"execution": {
207-
"iopub.execute_input": "2021-05-27T14:56:50.908724Z",
208-
"iopub.status.busy": "2021-05-27T14:56:50.908235Z",
209-
"iopub.status.idle": "2021-05-27T14:56:51.275802Z",
210-
"shell.execute_reply": "2021-05-27T14:56:51.275036Z",
211-
"shell.execute_reply.started": "2021-05-27T14:56:50.908689Z"
207+
"iopub.execute_input": "2021-10-01T10:36:21.306689Z",
208+
"iopub.status.busy": "2021-10-01T10:36:21.306247Z",
209+
"iopub.status.idle": "2021-10-01T10:36:21.710470Z",
210+
"shell.execute_reply": "2021-10-01T10:36:21.709625Z",
211+
"shell.execute_reply.started": "2021-10-01T10:36:21.306651Z"
212212
}
213213
},
214214
"outputs": [
@@ -255,20 +255,20 @@
255255
"execution_count": 8,
256256
"metadata": {
257257
"execution": {
258-
"iopub.execute_input": "2021-05-27T14:56:51.279550Z",
259-
"iopub.status.busy": "2021-05-27T14:56:51.279090Z",
260-
"iopub.status.idle": "2021-05-27T14:56:51.633098Z",
261-
"shell.execute_reply": "2021-05-27T14:56:51.632281Z",
262-
"shell.execute_reply.started": "2021-05-27T14:56:51.279513Z"
258+
"iopub.execute_input": "2021-10-01T10:36:21.713997Z",
259+
"iopub.status.busy": "2021-10-01T10:36:21.713580Z",
260+
"iopub.status.idle": "2021-10-01T10:36:22.072858Z",
261+
"shell.execute_reply": "2021-10-01T10:36:22.070921Z",
262+
"shell.execute_reply.started": "2021-10-01T10:36:21.713959Z"
263263
}
264264
},
265265
"outputs": [
266266
{
267267
"data": {
268268
"text/plain": [
269-
"{Set(<function minus.<locals>.f at 0x7fde4c9209d0>): 0.5443310539518174,\n",
270-
" Set(<function very.<locals>.f at 0x7fde4c920e50>): 0.6400000000000001,\n",
271-
" Set(<function bounded_sum.<locals>.f at 0x7fde4c86a160>): 0.8359591794226543}"
269+
"{Set(<function minus.<locals>.f at 0x7f694c4409d0>): 0.5443310539518174,\n",
270+
" Set(<function very.<locals>.f at 0x7f694c440b80>): 0.6400000000000001,\n",
271+
" Set(<function bounded_sum.<locals>.f at 0x7f694c145160>): 0.8359591794226543}"
272272
]
273273
},
274274
"execution_count": 8,
@@ -314,20 +314,20 @@
314314
"execution_count": 9,
315315
"metadata": {
316316
"execution": {
317-
"iopub.execute_input": "2021-05-27T14:56:51.635339Z",
318-
"iopub.status.busy": "2021-05-27T14:56:51.634964Z",
319-
"iopub.status.idle": "2021-05-27T14:56:51.976381Z",
320-
"shell.execute_reply": "2021-05-27T14:56:51.975588Z",
321-
"shell.execute_reply.started": "2021-05-27T14:56:51.635303Z"
317+
"iopub.execute_input": "2021-10-01T10:36:22.076128Z",
318+
"iopub.status.busy": "2021-10-01T10:36:22.074937Z",
319+
"iopub.status.idle": "2021-10-01T10:36:22.426783Z",
320+
"shell.execute_reply": "2021-10-01T10:36:22.425941Z",
321+
"shell.execute_reply.started": "2021-10-01T10:36:22.076070Z"
322322
}
323323
},
324324
"outputs": [
325325
{
326326
"data": {
327327
"text/plain": [
328-
"{Set(<function bounded_sigmoid.<locals>.f at 0x7fde74c77430>): 0.5,\n",
329-
" Set(<function bounded_sigmoid.<locals>.f at 0x7fde4c604a60>): 0.012195121951219511,\n",
330-
" Set(<function MIN.<locals>.F at 0x7fde4c6540d0>): 0.5}"
328+
"{Set(<function bounded_sigmoid.<locals>.f at 0x7f694c4ff940>): 0.5,\n",
329+
" Set(<function bounded_sigmoid.<locals>.f at 0x7f694c12f940>): 0.012195121951219511,\n",
330+
" Set(<function MIN.<locals>.F at 0x7f694c12ff70>): 0.5}"
331331
]
332332
},
333333
"execution_count": 9,
@@ -370,14 +370,14 @@
370370
},
371371
{
372372
"cell_type": "code",
373-
"execution_count": 14,
373+
"execution_count": 10,
374374
"metadata": {
375375
"execution": {
376-
"iopub.execute_input": "2021-05-27T14:58:57.947805Z",
377-
"iopub.status.busy": "2021-05-27T14:58:57.947298Z",
378-
"iopub.status.idle": "2021-05-27T14:58:58.287383Z",
379-
"shell.execute_reply": "2021-05-27T14:58:58.286371Z",
380-
"shell.execute_reply.started": "2021-05-27T14:58:57.947764Z"
376+
"iopub.execute_input": "2021-10-01T10:36:22.429229Z",
377+
"iopub.status.busy": "2021-10-01T10:36:22.428589Z",
378+
"iopub.status.idle": "2021-10-01T10:36:22.811294Z",
379+
"shell.execute_reply": "2021-10-01T10:36:22.810245Z",
380+
"shell.execute_reply.started": "2021-10-01T10:36:22.429173Z"
381381
}
382382
},
383383
"outputs": [
@@ -416,62 +416,6 @@
416416
"***(A AND B) OR NOT(A AND TRUE)***. This may look straight forward for boolean logic, but since we are not just dealing with True and False, there are a number of ways in fuzzy logic to actually implement this."
417417
]
418418
},
419-
{
420-
"cell_type": "markdown",
421-
"metadata": {},
422-
"source": [
423-
"Oftentimes \"real\" logical conclusion isn't actually what you need, instead you might want to build something like a weighted decision tree, which is very easy to do.\n",
424-
"Let's see how to rate a meal as an example.\n",
425-
"Just keep in mind that rule functions take a dict of membership values as single argument once parametrized. So, in this case, the ratings dict either needs to be sanitized before passed into the rule or constructed from the beginning (which I've done here) in the appropriate way."
426-
]
427-
},
428-
{
429-
"cell_type": "code",
430-
"execution_count": 11,
431-
"metadata": {
432-
"execution": {
433-
"iopub.execute_input": "2021-05-27T14:56:52.315828Z",
434-
"iopub.status.busy": "2021-05-27T14:56:52.315307Z",
435-
"iopub.status.idle": "2021-05-27T14:56:52.337700Z",
436-
"shell.execute_reply": "2021-05-27T14:56:52.336500Z",
437-
"shell.execute_reply.started": "2021-05-27T14:56:52.315792Z"
438-
}
439-
},
440-
"outputs": [
441-
{
442-
"data": {
443-
"text/plain": [
444-
"6.9"
445-
]
446-
},
447-
"execution_count": 11,
448-
"metadata": {},
449-
"output_type": "execute_result"
450-
}
451-
],
452-
"source": [
453-
"from fuzzylogic.classes import Domain\n",
454-
"from fuzzylogic.functions import bounded_linear\n",
455-
"from fuzzylogic.rules import weighted_sum\n",
456-
"\n",
457-
"rating = Domain(\"rating\", 1, 10, res=0.1)\n",
458-
"rating.norm = bounded_linear(1, 10)\n",
459-
"weights = {\"beverage\": 0.3, \n",
460-
" \"atmosphere\": 0.2, \n",
461-
" \"looks\":0.2,\n",
462-
" \"taste\": 0.3}\n",
463-
"\n",
464-
"w_func = weighted_sum(weights=weights, target_d=rating) \n",
465-
"\n",
466-
"# we've rated beverage etc. on a scale from 1 to 10 separately\n",
467-
"ratings = {\"beverage\": rating.min(9),\n",
468-
" \"atmosphere\": rating.min(5),\n",
469-
" \"looks\": rating.min(4),\n",
470-
" \"taste\": rating.min(8)}\n",
471-
"\n",
472-
"w_func(ratings)"
473-
]
474-
},
475419
{
476420
"cell_type": "markdown",
477421
"metadata": {},
@@ -483,22 +427,22 @@
483427
},
484428
{
485429
"cell_type": "code",
486-
"execution_count": 12,
430+
"execution_count": 11,
487431
"metadata": {
488432
"execution": {
489-
"iopub.execute_input": "2021-05-27T14:56:52.339867Z",
490-
"iopub.status.busy": "2021-05-27T14:56:52.339354Z",
491-
"iopub.status.idle": "2021-05-27T14:56:52.442277Z",
492-
"shell.execute_reply": "2021-05-27T14:56:52.441129Z",
493-
"shell.execute_reply.started": "2021-05-27T14:56:52.339828Z"
433+
"iopub.execute_input": "2021-10-01T10:36:22.813724Z",
434+
"iopub.status.busy": "2021-10-01T10:36:22.813152Z",
435+
"iopub.status.idle": "2021-10-01T10:36:22.903082Z",
436+
"shell.execute_reply": "2021-10-01T10:36:22.901761Z",
437+
"shell.execute_reply.started": "2021-10-01T10:36:22.813660Z"
494438
}
495439
},
496440
"outputs": [
497441
{
498442
"name": "stdout",
499443
"output_type": "stream",
500444
"text": [
501-
"1611.3704197201866 None 1656.5076659966692 None => 1633.939042858428\n"
445+
"1610.5651371516108 None 1655.6798260836274 None => 1633.122481617619\n"
502446
]
503447
}
504448
],
@@ -545,6 +489,62 @@
545489
"If a rule has zero weight - in this example a temp of 22 results in cold weighted with S(0,20) as 0 - the Rule returns None, which makes sure this condition is ignored in subsequent calculations. Also you might notice that the result is a value of 1633, which is way more than motor.fast with R(1000,1500) would suggest. However, since the domain motor is defined between 0 and 2000, the center of gravity method used for evaluation takes many of the values between 1500 and 2000 weighted with 1 into account, giving this slightly unexpected result."
546490
]
547491
},
492+
{
493+
"cell_type": "markdown",
494+
"metadata": {},
495+
"source": [
496+
"Oftentimes \"real\" logical conclusion isn't actually what you need, instead you might want to build something like a weighted decision tree, which is very easy to do.\n",
497+
"Let's see how to rate a meal as an example.\n",
498+
"Just keep in mind that rule functions take a dict of membership values as single argument once parametrized. So, in this case, the ratings dict either needs to be sanitized before passed into the rule or constructed from the beginning (which I've done here) in the appropriate way."
499+
]
500+
},
501+
{
502+
"cell_type": "code",
503+
"execution_count": 12,
504+
"metadata": {
505+
"execution": {
506+
"iopub.execute_input": "2021-10-01T10:36:22.904794Z",
507+
"iopub.status.busy": "2021-10-01T10:36:22.904407Z",
508+
"iopub.status.idle": "2021-10-01T10:36:22.919102Z",
509+
"shell.execute_reply": "2021-10-01T10:36:22.918106Z",
510+
"shell.execute_reply.started": "2021-10-01T10:36:22.904758Z"
511+
}
512+
},
513+
"outputs": [
514+
{
515+
"data": {
516+
"text/plain": [
517+
"6.9"
518+
]
519+
},
520+
"execution_count": 12,
521+
"metadata": {},
522+
"output_type": "execute_result"
523+
}
524+
],
525+
"source": [
526+
"from fuzzylogic.classes import Domain\n",
527+
"from fuzzylogic.functions import bounded_linear\n",
528+
"from fuzzylogic.rules import weighted_sum\n",
529+
"\n",
530+
"rating = Domain(\"rating\", 1, 10, res=0.1)\n",
531+
"rating.norm = bounded_linear(1, 10)\n",
532+
"weights = {\"beverage\": 0.3, \n",
533+
" \"atmosphere\": 0.2, \n",
534+
" \"looks\":0.2,\n",
535+
" \"taste\": 0.3}\n",
536+
"\n",
537+
"w_func = weighted_sum(weights=weights, target_d=rating) \n",
538+
"\n",
539+
"# we've rated beverage etc. on a scale from 1 to 10 separately\n",
540+
"ratings = {\"beverage\": rating.min(9),\n",
541+
" \"atmosphere\": rating.min(5),\n",
542+
" \"looks\": rating.min(4),\n",
543+
" \"taste\": rating.min(8)}\n",
544+
"\n",
545+
"w_func(ratings)"
546+
]
547+
},
548548
{
549549
"cell_type": "markdown",
550550
"metadata": {},

0 commit comments

Comments
 (0)