åæžã
ãã®èšäºã§ã¯ãæ Œåçè«ã«åºã¥ãæ©æ¢°åŠç¿ããã°ã©ã ã®æ°ããããŒãžã§ã³ã«ã€ããŠèª¬æããŸãããã®ããŒãžã§ã³ã®äž»ãªå©ç¹ã¯ãPythonããã°ã©ããŒãC ++ã§ããã°ã©ã ãããå¹ççãªã¢ã«ãŽãªãºã ã«ã€ã³ã¿ãŒãã§ãŒã¹ããããšã§ãã
ä»æ¥ãæ©æ¢°åŠç¿æé ïŒããã¿èŸŒã¿ãã¥ãŒã©ã«ãããã¯ãŒã¯ãã©ã³ãã ãã©ã¬ã¹ãããµããŒããã¯ã¿ãŒãã·ã³ãªã©ïŒã¯éåžžã«é«ãã¬ãã«ã«éããŠãããé³å£°ããããªãããã³ç»åã®èªèã«ãããŠäººéããã®ãã§ããŸãããããã圌ãã¯çµè«ã®æ£ããã蚌æããããã®è°è«ãæäŸããããšã¯ã§ããŸããã
äžæ¹ãæ©æ¢°åŠç¿ãžã®ã·ã³ããªãã¯ãªã¢ãããŒãïŒåž°çŽè«çããã°ã©ãã³ã°ãæŽæ°ããã°ã©ãã³ã°ã䜿çšããåŠç¿ã«ãã¬ããžïŒã¯ãèšç®ãéåžžã«è€éã§ãããæ¯èŒçå°ããªãµã€ãºã®ãµã³ãã«ã«ãå®éã«ã¯é©çšã§ããŸããã
ããã§èª¬æããã¢ãããŒãã¯ã確çè«çã¢ã«ãŽãªãºã ã䜿çšããŠãããã®åé¡ãåé¿ããŸãã ICFã®æ©æ¢°åŠç¿ææ³ã§ã¯ãçŸä»£ä»£æ°æ Œåçè«ïŒåœ¢åŒçæŠå¿µã®åæïŒãšç¢ºççè«ïŒç¹ã«ãã«ã³ãé£éïŒã®ææ³ã䜿çšããŸããããããICFã·ã¹ãã ã䜿çšããŠããã°ã©ã ã䜿çšããã³äœæããããã«ãé«åºŠãªæ°åŠã®ç¥èã¯å¿ èŠãããŸãããèè ã¯ãPythonããã°ã©ããŒãç解ã§ããã€ã³ã¿ãŒãã§ãŒã¹ãä»ããŠããã°ã©ã ãžã®ã¢ã¯ã»ã¹ãæäŸããã©ã€ãã©ãªãŒïŒWindowsã§ã¯vkf.cp38-win32.pydãŸãã¯Linuxã§ã¯vkf.cpython-38-x86_64-linux-gnu.soïŒãäœæããŸããã
説æãããŠããã¢ãããŒãã«é¢é£ããŠèŠªã®ã¢ãããŒãããããŸã-20äžçŽã®80幎代ã®åãã«çºæãããæè¡ç§åŠå士ãææãVKãèªå仮説çæã®ããã®Finn JSMã¡ãœãããããã¯ããã®äœæè ãèšãããã«ãç§åŠç 究ã®èªååããããµããŒãã®ããã®æ¹æ³ãžãšé²åããŸãããåŒæ°ã®ããžãã¯ã®æ¹æ³ã䜿çšããŠããã¬ãŒãã³ã°ã»ãããæ¡åŒµãããšãã«èŠã€ãã£ã仮説ã®å®å®æ§ããã§ãã¯ããJSMæšè«ã®ããŸããŸãªæŠç¥ã䜿çšããŠäºæž¬ã®çµæãçµã¿åãããããšãã§ããŸãã
æ®å¿µãªããããã®ããŒãã®èè ãšåœŒã®ååã¯ãJSMã¡ãœããã®ããã€ãã®çè«çãªæ¬ ç¹ãçºèŠããŠèª¿æ»ããŸããã
- ææªã®å Žåãçæãããé¡äŒŒæ§ã®æ°ã¯ãå ¥åããŒã¿ïŒãã¬ãŒãã³ã°ãµã³ãã«ïŒã®ãµã€ãºãšæ¯èŒããŠææ°é¢æ°çã«å€§ãããªãå¯èœæ§ããããŸãã
- (NP-).
- .
- «» , .
- .
èè ã®ç 究ã¯ã圌ã®è«æã®ç¬¬2ç« ã«ãŸãšããããŠããŸããæåŸã®ç¹ã¯èè ã«ãã£ãŠæè¿çºèŠãããŸãããã圌ã®æèŠã§ã¯ããµã³ãã«ã¢ãããŒãã®æ¡åŒµã«çµæ¢ç¬Šãæã¡ãŸãã
æåŸã«ãJSMã³ãã¥ããã£ã¯ããã®ã·ã¹ãã ã®ãœãŒã¹ã³ãŒããžã®ã¢ã¯ã»ã¹ãæäŸããŠããŸãããããã«ã䜿çšãããŠããããã°ã©ãã³ã°èšèªïŒFortããã³CïŒïŒã¯ãäžè¬ã®äººã ã«ãã䜿çšãèš±å¯ããŸãããèè ã«ç¥ãããŠããå¯äžã®ç¡æã®C ++ããŒãžã§ã³ã®JSMãœã«ããŒïŒT.A. VolkovaèïŒããããªãŒã¯ïŒã«ã¯ãèšç®ã®ç°åžžçµäºã«ã€ãªããããšãããè¿·æãªãšã©ãŒãå«ãŸããŠããŸãã
èè ã¯åœåãVKFæ¹åŒã·ã¹ãã çšã«éçºããããšã³ã³ãŒããJSMã³ãã¥ããã£ãšå ±æããããšãèšç»ããŠããŸããããããã£ãŠãJSMã·ã¹ãã ãšVKFã·ã¹ãã ã®äž¡æ¹ã«åæã«é©çšã§ãããã¹ãŠã®ã¢ã«ãŽãªãºã ãå¥ã®ã©ã€ãã©ãªïŒWindowsã§ã¯vkfencoder.cp38-win32.pydãLinuxã§ã¯vkfencoder.cpython-38-x86_64-linux-gnu.soïŒã«å ¥ããŸããã ... æ®å¿µãªããããããã®ã¢ã«ãŽãªãºã ã¯ãJSMã³ãã¥ããã£ããã¯èŠæ±ãããŠããŸãããVKFã©ã€ãã©ãªã¯ãããã®ã¢ã«ãŽãªãºã ïŒããšãã°ãvkf.FCAã¯ã©ã¹ïŒãå®è£ ããŠããŸããããã¡ã€ã«ããã§ã¯ãªããWebã€ã³ã¿ãŒãã§ãŒã¹ãä»ããŠçŽæ¥ããŒãã«ã«å ¥åããããšã«äŸåããŠããŸããããã§ã¯ãvkfencoderã©ã€ãã©ãªã䜿çšããŸãã
1åå¥æ©èœã®ã©ã€ãã©ãªã䜿çšããæé
èªè ãMariaDBãµãŒããŒ+ MariaDBã³ãã¯ã¿/ Cãã€ã³ã¹ããŒã«ããæ¹æ³ãç¥ã£ãŠãããšããŸãããïŒããã©ã«ãã§ã¯ãIPã¢ãã¬ã¹127.0.0.1:3306ãšãŠãŒã¶ãŒ 'root'ããã¹ã¯ãŒã 'toor'ã䜿çšããŸãïŒããŸããvkfencoderã©ã€ãã©ãªãšvkfã©ã€ãã©ãªããã¢ä»®æ³ç°å¢ã«ã€ã³ã¹ããŒã«ãããmushroomããšããååã®ç©ºã®MariaDBããŒã¿ããŒã¹ãäœæããŸãã
krrguest@amd2700vii:~/src$ python3 -m venv demo
krrguest@amd2700vii:~/src$ source demo/bin/activate
(demo) krrguest@amd2700vii:~/src$ cd vkfencoder
(demo) krrguest@amd2700vii:~/src/vkfencoder$ python3 ./setup.py build
(demo) krrguest@amd2700vii:~/src/vkfencoder$ python3 ./setup.py install
(demo) krrguest@amd2700vii:~/src/vkfencoder$ cd ../vkf
(demo) krrguest@amd2700vii:~/src/vkf$ python3 ./setup.py build
(demo) krrguest@amd2700vii:~/src/vkf$ python3 ./setup.py install
(demo) krrguest@amd2700vii:~/src/vkf$ cd ../demo
(demo) krrguest@amd2700vii:~/src/demo$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS mushroom;
MariaDB [(none)]> exit;
äœæ¥ã®çµæãšããŠãããŒã¿ããŒã¹ãmushroomã
ããã©ã«ããŒã/ src / demo / lib / python3.8 / site-packages / vkfencoder-1.0.3-py3.8-linux-x86_64.egg / ãã¡ã€ã«vkfencoder.cpython-38ã«è¡šç€ºãããŸã-x86_64-linux-gnu.soãããã³vkf.cpython
ãã¡ã€ã«ãã/ src / demo / lib / python3.8 / site-packages / vkf-2.0.1-py3.8-linux-x86_64.egg / ãã©ã«ããŒã«è¡šç€ºãããŸã38-x86_64-linux-gnu.so
Python3ãèµ·åããMushroomsã¢ã¬ã€ã§CCFå®éšãå®è¡ããŸãã ã/ src / demo / files /ãã©ã«ãïŒmushrooms.xmlãMUSHROOMS.trainãMUSHROOSS.restïŒã«3ã€ã®ãã¡ã€ã«ããããšæ³å®ãããŠããŸãããããã®ãã¡ã€ã«ã®æ§é ã«ã€ããŠã¯ã次ã®ã»ã¯ã·ã§ã³ã§èª¬æããŸããæåã®ãã¡ã€ã«ãmushrooms.xmlãã¯ãããã³ã説æããåå±æ§ã®å€ã«ããäžååã®æ Œåã®æ§é ãå®çŸ©ããŠããŸãã 2çªç®ãš3çªç®ã®ãã¡ã€ã«ã¯ãçŽååã®ãã¡ã€ã«ãagaricus-lepiota.dataãã§ããããã¯ã1981幎ã«ãã¥ãŒãšãŒã¯ã§çºè¡ãããããžã¿ã«åãããæ¬ãIdentifier of North American Mushroomsãã§ãã次ã®ååã¯ããšã³ã³ãŒããŒãããã©ãã¹ãããã¬ã€ã³ããšããã¹ããã¯ãããããããŒã¿ããŒã¹ã®ããã³ã®ããŒãã«ã®ååã§ãããããããããããå€ã®éšåæååã«ããç¹åŸŽå€ã®ãšã³ã³ãŒãã£ã³ã°ããããã®å€ã®åæ Œåå³ã®ã«ãã¬ããžé¢ä¿ããã¬ãŒãã³ã°ãšãã¹ãã®äŸã
(demo) krrguest@amd2700vii:~/src/demo$ Python3
>>> import vkfencoder
>>> xml = vkfencoder.XMLImport('./files/mushrooms.xml', 'encoder', 'lattices', 'mushroom', '127.0.0.1', 'root', 'toor')
>>> trn = vkfencoder.DataImport('./files/MUSHROOMS.train', 'e', 'encoder', 'trains', 'mushroom', '127.0.0.1', 'root', 'toor')
>>> tst = vkfencoder.DataImport('./files/MUSHROOMS.rest', 'e', 'encoder', 'tests', 'mushroom', '127.0.0.1', 'root', 'toor')
æåŸã®2è¡ã®ãeãã¯ãããã³ã®é£çšã«å¯Ÿå¿ããŠããŸãïŒããã¯ãã¿ãŒã²ããã®ç¹æ§ããã®é åã§ãšã³ã³ãŒããããæ¹æ³ã§ãïŒã
2ã€ã®ããŒãã«ããšã³ã³ãŒããŒããšãã©ãã¹ãããã®æ å ±ãxmlãã¡ã€ã«ã«ä¿åã§ããvkfencoder.XMLExportã¯ã©ã¹ããããå€æŽãå ããåŸãvkfencoder.XMLImportã¯ã©ã¹ã§å床åŠçã§ããããšã«æ³šæããŠãã ããã
次ã«ãå®éã®VKFå®éšã«ç§»ããŸãããšã³ã³ãŒããŒãæ¥ç¶ãã以åã«èšç®ããã仮説ïŒããå ŽåïŒãèªã¿èŸŒã¿ãè¿œå ã®æ°ïŒ100ïŒã®ä»®èª¬ãæå®ãããæ°ïŒ4ïŒã®ã¹ããªãŒã ã«èšç®ãããããã 'vkfhyps'ããŒãã«ã«ä¿åããŸãã
>>> enc = vkf.Encoder('encoder', 'mushroom', '127.0.0.1', 'root', 'toor')
>>> ind = vkf.Induction()
>>> ind.load_discrete_hypotheses(enc, 'trains', 'vkfhyps', 'mushroom', '127.0.0.1', 'root', 'toor')
>>> ind.add_hypotheses(100, 4)
>>> ind.save_discrete_hypotheses(enc, 'vkfhyps', 'mushroom', '127.0.0.1', 'root', 'toor')
ndxã§çªå·ä»ããããCCF仮説ã®ãã¹ãŠã®éèŠãªãã¢ïŒfeature_nameãfeature_valueïŒã®Pythonãªã¹ããååŸã§ããŸã
>>> ind.show_discrete_hypothesis(enc, ndx)
ããã³ã®é£çšã«ã€ããŠæ±ºå®ãäžãããã®ä»®èª¬ã®1ã€ã¯ã
[('gill_attachment', 'free'), ('gill_spacing', 'close'), ('gill_size', 'broad'), ('stalk_shape', 'enlarging'), ('stalk_surface_below_ring', 'scaly'), ('veil_type', 'partial'), ('veil_color', 'white'), ('ring_number', 'one'), ('ring_type', 'pendant')]
CCFã¡ãœããã®ã¢ã«ãŽãªãºã ã®ç¢ºçè«çãªæ§è³ªã®ãããçæãããªãå ŽåããããŸãããèè ã¯ãçæãããCCF仮説ãååã«å€ããšãéåžžã«ãã䌌ã仮説ãçºçããéèŠãªãã¹ãã±ãŒã¹ã®ã¿ãŒã²ããããããã£ãã»ãŒäºæž¬ã§ããããšã蚌æããŸããã詳现ã¯èè ã®è«æã®ç¬¬4ç« ã«ãããŸãã
æåŸã«ãäºæž¬ã«ã€ããŠèª¬æããŸããçæããã仮説ã®è³ªãè©äŸ¡ããåæã«ãã®èŠçŽ ã®ã¿ãŒã²ããããããã£ãäºæž¬ããããã®ãã¹ããµã³ãã«ãäœæããŸã
>>> tes = vkf.TestSample(enc, ind, 'tests', 'mushroom', '127.0.0.1', 'root', 'toor')
>>> tes.correct_positive_cases()
>>> tes.correct_negative_cases()
>>> exit()
2ããŒã¿æ§é ã®èª¬æ
2.1é¢æ£ãã£ãŒãã£ã®æ Œåæ§é
vkfencoder.XMLImportã¯ã©ã¹ã¯ããã£ãŒãã£å€éã®é åºãèšè¿°ããXMLãã¡ã€ã«ã解æãã2ã€ã®ããŒãã«ããšã³ã³ãŒããŒãïŒåå€ããããæååã«å€æïŒããã³ãã©ãã£ã¹ãïŒ1ã€ã®ãã£ãŒãã£ã®å€éã®é¢ä¿ãæ ŒçŽïŒãäœæããŠããŒã¿ãå ¥åããŸãã
å ¥åãã¡ã€ã«ã®æ§é ã¯æ¬¡ã®ããã«ãªããŸã
<?xml version="1.0"?>
<document name="mushrooms_db">
<attribute name="cap_color">
<vertices>
<node string="null" char='_'></node>
<node string="brown" char='n'></node>
<node string="buff" char='b'></node>
<node string="cinnamon" char='c'></node>
<node string="gray" char='g'></node>
<node string="green" char='r'></node>
<node string="pink" char='p'></node>
<node string="purple" char='u'></node>
<node string="red" char='e'></node>
<node string="white" char='w'></node>
<node string="yellow" char='y'></node>
</vertices>
<edges>
<arc source="brown" target="null"></arc>
<arc source="buff" target="brown"></arc>
<arc source="buff" target="yellow"></arc>
<arc source="cinnamon" target="brown"></arc>
<arc source="cinnamon" target="red"></arc>
<arc source="gray" target="null"></arc>
<arc source="green" target="null"></arc>
<arc source="pink" target="red"></arc>
<arc source="pink" target="white"></arc>
<arc source="purple" target="red"></arc>
<arc source="red" target="null"></arc>
<arc source="white" target="null"></arc>
<arc source="yellow" target="null"></arc>
</edges>
</attribute>
</document>
äžèšã®äŸã¯ãæ©æ¢°åŠç¿ããŒã¿ãªããžããªïŒã«ãªãã©ã«ãã¢å€§åŠã¢ãŒãã€ã³æ ¡ïŒã®Mushroomsé åã®3çªç®ã®ç¹æ§ãcap_colorãã®å€éã®é åºãè¡šããŠããŸããåãå±æ§ããã£ãŒã«ãã¯ã察å¿ããå±æ§ã®å€ã®æ Œåæ§é ãè¡šããŸãããã®äŸã§ã¯ãã°ã«ãŒãã¯é¢æ£å±æ§ãcap_colorãã«å¯Ÿå¿ããŠããŸãããã¹ãŠã®ç¹æ§å€ã®ãªã¹ãã¯ãµãã°ã«ãŒãã圢æããŸããäºçŽ°ãªïŒæ¬ ããŠããïŒé¡äŒŒæ§ã瀺ãå€ãè¿œå ããŸãããæ®ãã®å€ã¯ãæ·»ä»ãã¡ã€ã«ãagaricus-lepiota.namesãã®èª¬æã«å¯Ÿå¿ããŠããŸãã
ãããã®éã®é åºã¯ããµãã°ã«ãŒãã®å 容ã«ãã£ãŠè¡šãããŸããåé ç®ã¯ãç¹æ§å€ã®ãã¢éã®ããå ·äœç/ããäžè¬çãªé¢ä¿ã瀺ããŠããŸããããšãã°ãã¯ãã³ã¯ã®ããã³ãã£ãããèµ€ããã£ãããããå ·äœçã§ããããšãæå³ããŸãã
èè ã¯ãvkfencoder.XMLImportã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ãŒã«ãã£ãŠçæãããããšã³ã³ãŒããŒãããŒãã«ã«æ ŒçŽãããè¡šçŸã®æ£ç¢ºãã«é¢ããå®çã蚌æããŸããã圌ã®ã¢ã«ãŽãªãºã ãšæ£åœæ§ã®å®çã®èšŒæã§ã¯ã圢åŒçæŠå¿µåæãšããŠç¥ãããææ°ã®æ Œåçè«ã䜿çšããŠããŸãã詳现ã«ã€ããŠã¯ãèªè ã¯èè ã®è«æïŒç¬¬1ç« ïŒãåã³åç §ãããŸãã
2.2é¢æ£ç¹åŸŽã®ãµã³ãã«æ§é
ãŸã第äžã«ãèªè ã¯èªåã®ãã¬ãŒãã³ã°ãšãã¹ãã±ãŒã¹ããŒããŒãããŒã¿ããŒã¹ã«å®è£ ããããã©ã€ãã©ãªã§å©çšå¯èœãªvkfencoder.DataImportã¯ã©ã¹ã䜿çšã§ããããšã«æ³šæããŠãã ããã 2çªç®ã®ã±ãŒã¹ã§ã¯ããªãŒããŒã¯ã¿ãŒã²ãããã£ãŒãã£ãŒãæåã®äœçœ®ã«ããã1æåã§æ§æãããå¿ èŠãããããšãèæ ®ã«å ¥ããå¿ èŠããããŸãïŒããšãã°ãã+ã/ã-ããã1ã/ã0ããŸãã¯ãeã/ãpãïŒã
ãã¬ãŒãã³ã°ãµã³ãã«ã¯ããã¬ãŒãã³ã°ã®äŸãšã«ãŠã³ã¿ãŒã®äŸïŒã¿ãŒã²ããããããã£ããªãäŸïŒãèšè¿°ããCSVãã¡ã€ã«ïŒå€ã¯ã³ã³ãåºåãïŒã§ããå¿ èŠããããŸãã
å ¥åãã¡ã€ã«ã®æ§é ã¯æ¬¡ã®ããã«ãªããŸã
e,f,f,g,t,n,f,c,b,w,t,b,s,s,p,w,p,w,o,p,k,v,d
p,x,s,p,f,c,f,c,n,u,e,b,s,s,w,w,p,w,o,p,n,s,d
p,f,y,g,f,f,f,c,b,p,e,b,k,k,b,n,p,w,o,l,h,v,g
p,x,y,y,f,f,f,c,b,p,e,b,k,k,n,n,p,w,o,l,h,v,p
e,x,y,b,t,n,f,c,b,e,e,?,s,s,e,w,p,w,t,e,w,c,w
p,f,f,g,f,f,f,c,b,g,e,b,k,k,n,p,p,w,o,l,h,y,g
p,x,f,g,f,f,f,c,b,p,e,b,k,k,p,n,p,w,o,l,h,y,g
p,x,f,y,f,f,f,c,b,h,e,b,k,k,n,b,p,w,o,l,h,y,g
p,f,f,y,f,f,f,c,b,h,e,b,k,k,p,p,p,w,o,l,h,y,g
p,x,y,g,f,f,f,c,b,h,e,b,k,k,p,p,p,w,o,l,h,v,d
p,x,f,g,f,c,f,c,n,u,e,b,s,s,w,w,p,w,o,p,n,v,d
p,x,y,g,f,f,f,c,b,h,e,b,k,k,p,b,p,w,o,l,h,v,g
e,f,y,g,t,n,f,c,b,n,t,b,s,s,p,g,p,w,o,p,k,y,d
e,f,f,e,t,n,f,c,b,p,t,b,s,s,p,p,p,w,o,p,k,v,d
p,f,y,g,f,f,f,c,b,p,e,b,k,k,p,b,p,w,o,l,h,y,p
ããã®åè¡ã¯ã1ã€ã®ãã¬ãŒãã³ã°äŸã瀺ããŠããŸãã説æããããã³ã®é£çšæ§/æ¯æ§ã«å¿ããŠãæåã®äœçœ®ã«ãeããŸãã¯ãpããå«ãŸããŸããæ®ãã®äœçœ®ïŒã³ã³ãã§åºåãããŠããïŒã«ã¯ãæåïŒççž®åïŒãŸãã¯æååïŒå¯Ÿå¿ããå±æ§ã®å€ã®å®å šãªååïŒãå«ãŸããŠããŸããããšãã°ã4çªç®ã®äœçœ®ã¯å±æ§ãcup_colorããšäžèŽããŸãããgãããpãããyãããbãããeãã¯ãç°è²ããããã³ã¯ãããé»è²ãããç ãããèµ€ããè¡šããŸãããããããäžèšã®è¡šã®äžå€®ã«ããçå笊ã¯ãæ¬ æå€ã瀺ããŸãããã ããæ®ãã®ïŒéã¿ãŒã²ããïŒç¹æ§ã®å€ã¯æååã«ããããšãã§ããŸããããŒã¿ããŒã¹ã«ä¿åãããšãååã®ã¹ããŒã¹ãã_ãæåã«çœ®ãæããããããšã«æ³šæããŠãã ããã
ãã¹ãã±ãŒã¹ãå«ããã¡ã€ã«ã¯åãããã«èŠããŸãããã·ã¹ãã ã®ã¿ã«äŸã®å®éã®å åãéç¥ãããããã®äºæž¬ããããšæ¯èŒãããŠãçæããã仮説ã®è³ªãšãã®äºæž¬åãèšç®ãããŸãã
2.3é£ç¶ãã£ãŒãã£ã®ãµã³ãã«æ§é
ãã®å Žåãããªãã·ã§ã³ã¯å¯èœã§ãããªãŒããŒã¯ãç¬èªã®ãã¬ãŒããŒãšãã¹ãã±ãŒã¹ããŒããŒãããŒã¿ããŒã¹ã«å®è£ ããããã©ã€ãã©ãªã§äœ¿çšå¯èœãªvkfencoder.DataLoadã¯ã©ã¹ã䜿çšã§ããŸãã 2çªç®ã®ã±ãŒã¹ã§ã¯ãèªè ã¯ã¿ãŒã²ãããã£ãŒãã£ãæåã®äœçœ®ã«ãããèªç¶æ°ïŒããšãã°ã0ã7ã15ïŒã§æ§æãããå¿ èŠãããããšãèæ ®ã«å ¥ããå¿ èŠããããŸãã
ãã¬ãŒãã³ã°ãµã³ãã«ã¯ããã¬ãŒãã³ã°ã®äŸãšã«ãŠã³ã¿ãŒã®äŸïŒã¿ãŒã²ããããããã£ããªãäŸïŒãèšè¿°ããCSVãã¡ã€ã«ïŒããçš®ã®ã»ãã¬ãŒã¿ãŒã§å€ãåºåãããŠããïŒã§ããå¿ èŠããããŸãã
å ¥åãã¡ã€ã«ã®æ§é ã¯æ¬¡ã®ããã«ãªããŸã
"quality";"fixed acidity";"volatile acidity";"citric acid";"residual sugar";"chlorides";"free sulfur dioxide";"total sulfur dioxide";"density";"pH";"sulphates";"alcohol"
5;7.4;0.7;0;1.9;0.076;11;34;0.9978;3.51;0.56;9.4
5;7.8;0.88;0;2.6;0.098;25;67;0.9968;3.2;0.68;9.8
5;7.8;0.76;0.04;2.3;0.092;15;54;0.997;3.26;0.65;9.8
6;11.2;0.28;0.56;1.9;0.075;17;60;0.998;3.16;0.58;9.8
5;7.4;0.7;0;1.9;0.076;11;34;0.9978;3.51;0.56;9.4
5;7.4;0.66;0;1.8;0.075;13;40;0.9978;3.51;0.56;9.4
5;7.9;0.6;0.06;1.6;0.069;15;59;0.9964;3.3;0.46;9.4
7;7.3;0.65;0;1.2;0.065;15;21;0.9946;3.39;0.47;10
7;7.8;0.58;0.02;2;0.073;9;18;0.9968;3.36;0.57;9.5
ç§ãã¡ã®å Žåããããã¯æåŸã®åãæåã«äžŠã¹æ¿ããŠæ©æ¢°åŠç¿æé ããã¹ãããããã«ãUCIããŒã¿ãªããžããªã®Wine Qualityé åããèµ€ãã«ãã¬ã«ã¯ã€ã³ã®ãwinequality-red.csvããã¡ã€ã«ããçæããããvv_red.csvããã¡ã€ã«ã®æåã®æ°è¡ã§ããããŒã¿ããŒã¹ã«ä¿åãããšãååã®ã¹ããŒã¹ãã_ãæåã«çœ®ãæããããããšã«æ³šæããããšãéèŠã§ãã
3ç¶ç¶çãªæ©èœãæã€äŸã®CCFå®éš
以åã«æžããããã«ãUCIãªããžããªããã®Wine Qualityã¢ã¬ã€ã«é¢ããäœæ¥ã瀺ããŸããMariaDBã®äžã«ãred_wineããšããååã®ç©ºã®ããŒã¿ããŒã¹ãäœæããããšããå§ããŸãããã
(demo) krrguest@amd2700vii:~/src/demo$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS red_wine;
MariaDB [(none)]> exit;
äœæ¥ã®çµæããred_wineãããŒã¿ããŒã¹ã衚瀺ãããŸãã
Python3ãèµ·åããWine Qualityã¢ã¬ã€ã§VKFå®éšãè¡ããŸãã ã/ src / demo / files /ãã©ã«ããŒã«vv_red.csvãã¡ã€ã«ããããšæ³å®ãããŠããŸãããããã®ãã¡ã€ã«ã®æ§é ã¯ãåã®æ®µèœã§èª¬æãããŠããŸãã次ã®ååãvergesãããcomplexãããtrainsãããtestsãã¯ããããããred_wineãããŒã¿ããŒã¹å ã®ããŒãã«ã®ååã§ããããããå€ïŒåæå€ãšååž°ã«ãã£ãŠèšç®ãããæ©èœã®äž¡æ¹ïŒãéèŠãªããžã¹ãã£ãã¯ååž°ã®ä¿æ°æ©èœããã¬ãŒãã³ã°ããã¹ãã±ãŒã¹ã®ãã¢ã
(demo) krrguest@amd2700vii:~/src/demo$ Python3
>>> import vkfencoder
>>> nam = vkfencoder.DataLoad('./files/vv_red.csv', 7, 'verges', 'trains', 'red_wine', ';', '127.0.0.1', 'root', 'toor')
2çªç®ã®åŒæ°ã¯ããããå€ïŒãã®äŸã§ã¯7ïŒãèšå®ããŸãããããè¶ ãããšãäŸã¯æ£ãšå®£èšãããŸããåŒæ° ';' åºåãæåã«äžèŽããŸãïŒããã©ã«ã㯠'ã'ã§ãïŒãèè ã«ããåã®æ³šèšã§
瀺ããããã«ãæé ã¯é¢æ£ãã£ãŒãã£ãŒã®å Žåãšã¯ç°ãªããŸããæåã«ãvkf.Joinã¯ã©ã¹ã䜿çšããŠããžã¹ãã£ãã¯ååž°ãèšç®ããŸãããã®ä¿æ°ã¯ãcomplexãããŒãã«ã«æ ŒçŽãããŸãã
>>> join = vkf.Join('trains', 'red_wine', '127.0.0.1', 'root', 'toor')
>>> join.compute_save('complex', 'red_wine', '127.0.0.1', 'root', 'toor')
ããã§ãæ å ±çè«ã䜿çšããŠãvkf.Generatorã¯ã©ã¹ã䜿çšããŠãããå€ãèšç®ããŸããããã¯ãæ倧å€ãšæå°å€ãšãšãã«ããvergesãããŒãã«ã«æ ŒçŽãããŸãã
>>> gen = vkf.Generator('complex', 'trains', 'verges', 'red_wine', 7, '127.0.0.1', 'root', 'toor')
5çªç®ã®åŒæ°ã¯ãå ã®ãã£ãŒãã£ã®ãããå€ã®æ°ãèšå®ããŸããããã©ã«ãïŒããã³å€0ïŒã§ã¯ãç¹åŸŽã®æ°ã®å¯Ÿæ°ãšããŠèšç®ãããŸããååž°ã¯åäžã®ãããå€ãæ¢ããŸãã
次ã«ãå®éã®VKFå®éšã«ç§»ããŸãããšã³ã³ãŒããŒãæ¥ç¶ãã以åã«èšç®ããã仮説ïŒããå ŽåïŒãèªã¿èŸŒã¿ãæå®ãããæ°ïŒ8ïŒã®ã¹ããªãŒã ã§è¿œå ã®ä»®èª¬ïŒ300ïŒãèšç®ãããããããvkfhypsãããŒãã«ã«ä¿åããŸãã
>>> qual = vkf.Qualifier('verges', 'red_wine', '127.0.0.1', 'root', 'toor')
>>> beg = vkf.Beget('complex', 'red_wine', '127.0.0.1', 'root', 'toor')
>>> ind = vkf.Induction()
>>> ind.load_continuous_hypotheses(qual, beg, 'trains', 'vkfhyps', 'red_wine', '127.0.0.1', 'root', 'toor')
>>> ind.add_hypotheses(300, 8)
>>> ind.save_continuous_hypotheses(qual, 'vkfhyps', 'red_wine', '127.0.0.1', 'root', 'toor')
ndxãšçªå·ãä»ããããCCF仮説ã®ããªãã«ïŒfeature_nameãïŒlower_boundãupper_boundïŒïŒã®Pythonãªã¹ããååŸã§ããŸã
>>> ind.show_continuous_hypothesis(enc, ndx)
æåŸã«ãäºæž¬ã«ã€ããŠèª¬æããŸããçæããã仮説ã®è³ªãè©äŸ¡ããåæã«ãã®èŠçŽ ã®ã¿ãŒã²ããããããã£ãäºæž¬ããããã®ãã¹ããµã³ãã«ãäœæããŸã
>>> tes = vkf.TestSample(qual, ind, beg, 'trains', 'red_wine', '127.0.0.1', 'root', 'toor')
>>> tes.correct_positive_cases()
>>> tes.correct_negative_cases()
>>> exit()
ãã¡ã€ã«ã1ã€ãããªããããããã§ã¯ãã¹ãã»ãããšããŠãã¬ãŒãã³ã°ã»ããã䜿çšããŸããã
4.ãã¡ã€ã«ã®ã¢ããããŒãã«é¢ãã泚æ
aiofilesã©ã€ãã©ãªã䜿çšããŠããã¡ã€ã«ïŒ 'mushrooms.xml'ãªã©ïŒãWebãµãŒããŒã«ã¢ããããŒãããŸãããããã«ããªãã圹ç«ã€ãããããªãã³ãŒãã®äžéšããããŸã
import aiofiles
import os
import vkfencoder
async def write_file(path, body):
async with aiofiles.open(path, 'wb') as file_write:
await file_write.write(body)
file_write.close()
async def xml_upload(request):
#determine names of tables
encoder_table_name = request.form.get('encoder_table_name')
lattices_table_name = request.form.get('lattices_table_name')
#Create upload folder if doesn't exist
if not os.path.exists(Settings.UPLOAD_DIR):
os.makedirs(Settings.UPLOAD_DIR)
#Ensure a file was sent
upload_file = request.files.get('file_name')
if not upload_file:
return response.redirect("/?error=no_file")
#write the file to disk and redirect back to main
short_name = upload_file.name.split('/')[-1]
full_path = f"{Settings.UPLOAD_DIR}/{short_name}"
try:
await write_file(full_path, upload_file.body)
except Exception as exc:
return response.redirect('/?error='+ str(exc))
return response.redirect('/ask_data')
çµè«
vkf.cpython-38-x86_64-linux-gnu.soã©ã€ãã©ãªã«ã¯ãå€ãã®é衚瀺ã®ã¯ã©ã¹ãšã¢ã«ãŽãªãºã ãå«ãŸããŠããŸãã圌ãã¯ãã¯ããŒãºããã€æäœãé 延è©äŸ¡ããã«ã³ãé£éã®ãã¢ããã«ã³ãé£éã®éæž¡ç¶æ ãç·å€åã®ã¡ããªãã¯ãªã©ã®é«åºŠãªæ°åŠçæŠå¿µã䜿çšããŠããŸãã
å®éã«ã¯ãæ©æ¢°åŠç¿çšã®ããŒã¿ãªããžããªã®é åã䜿ã£ãå®éšïŒã«ãªãã©ã«ãã¢å€§åŠã¢ãŒãã€ã³æ ¡ïŒ ïŒã¯ãC ++ 'VKFã¡ãœãã'ããã°ã©ã ãäžèŠæš¡ã®ããŒã¿ã«å®éã«é©çšã§ããããšã瀺ããŠããŸãïŒAdulté åã«ã¯32560ãã¬ãŒãã³ã°ãš16280ãã¹ãã±ãŒã¹ãå«ãŸããŠããŸãïŒã
'VKFã¡ãœãã'ã·ã¹ãã ã¯ãSPECTã¢ã¬ã€ã§CLIP3ïŒæŽæ°ããã°ã©ãã³ã°ã«ãã¬ããžã©ãŒãã³ã°v.3ïŒã·ã¹ãã ãããïŒäºæž¬ç²ŸåºŠã®ç¹ã§ïŒããã©ãŒãã³ã¹ãåªããŠããŸããCLIP3ã¯ãSPECTã¢ã¬ã€ã®äœæè ãäœæããããã°ã©ã ã§ããããã³é åïŒãã¬ãŒãã³ã°ãµã³ãã«ãšãã¹ããµã³ãã«ã«ã©ã³ãã ã«åå²ïŒã§ã¯ããVKFã¡ãœãããã·ã¹ãã ã¯100ïŒ ã®ç²ŸåºŠã瀺ããŸããïŒããã³ã®æ¯æ§ã®åºæºãšé£çšã®åºæºã®äž¡æ¹ã«é¢ããŠïŒããã®ããã°ã©ã ã¯ãAdultã¢ã¬ã€ã«ãé©çšããã100äžãè¶ ãã仮説ïŒã°ãªãããªãïŒãçæããŸããã
vkf CPythonã©ã€ãã©ãªã®ãœãŒã¹ã³ãŒãã¯ãsavannah.nongnu.orgã§äºåã«ã¢ãã¬ãŒããããŠããŸãã vkfencoderè£å©ã©ã€ãã©ãªã®ã³ãŒãã¯ãBitbucketããå ¥æã§ããŸãã
èè ã¯ã圌ã®ååãšåŠçïŒD. A. AnokhinãEãD. BaranovaãIãV. NikulinãEãYuãSidorovaãLãA. YakimovaïŒã®ãµããŒããæçšãªè°è«ãããã³å ±åç 究ã«æè¬ããŸãããã ãããã€ãã®ããã«ãäœè ã¯ãã¹ãŠã®æ¢åã®æ¬ ç¹ã«å¯ŸããŠåç¬ã§è²¬ä»»ããããŸãã