ã¹ã¯ã¬ã¤ãã³ã°ãã Web ãµã¤ããããã¼ã¸å ¨ä½ã®ã¹ã¯ãªã¼ã³ã·ã§ãããæ®å½±ãããæ©ä¼ããã£ãã ãã㧠Selenium ã® Python ãã¤ã³ãã£ã³ã°ã¨ Headless Chrome ã使ã£ãã¨ããå®ç¾ã§ããã®ã§ã¡ã¢ãã¦ããã ã¡ãªã¿ã«ããã¼ã¸å ¨ä½ã§ãªããã° Headless Chrome åä½ã§ãæ®ããã ãã®æ¹æ³ã«ã¤ãã¦ãæ«å°¾ã«è£è¶³ã¨ãã¦è¨è¼ãã¦ãããã 使ã£ãç°å¢ã¯æ¬¡ã®éãã $ sw_vers ProductName: Mac OS X ProductVersion: 10.13.5 BuildVersion: 17F77 $ python -V Python 3.6.5 $ pip list --format=columns | grep -i selenium selenium 3.13.0 $ chromedriver --version ChromeDriver 2.
(English article is here) ããã«ã¡ã¯ãå岡([twitter:@yoshiokatsuneo])ã§ãã Pythonã¯ãCSVãªã©ã®ãã¼ã¿å¦çãWebãµã¼ãã¹ã®éçºãã¹ã¯ã¬ã¤ãã³ã°ããããä½æãªã©å¹ åºãç®çã§ä½¿ããã¦ããããã°ã©ãã³ã°è¨èªã§ããç¹ã«æè¿ã¯ãæ©æ¢°å¦ç¿ã»AIã®ãªã©ã®éçºã«é©ããã©ã¤ãã©ãªãå å®ãã¦ãããã¨ããã£ã¦æ³¨ç®ãé«ã¾ã£ã¦ãã¾ãããã ãã ãPythonãåä½ã§ã¤ã³ã¹ãã¼ã«ãã¦ãã表ãã°ã©ããä½ã£ããããã¼ã¿ãªã©ãæ´çãããããæ©è½ã¯ããã¾ããã ããã§ãJupyter Notebookã¨ãããã¼ã«ãããã¾ãã Jupyter Notebookã使ãã¨ããã©ã¦ã¶ä¸ã§ç°¡åã«ããã°ã©ã ãå®è¡ã§ããããã表ãã°ã©ããªã©ã表示ã§ãã¾ãã ã¾ããMarkdownãªã©ã§æç« ãæ¸ãããããããã°ã©ã ã¨æç« ãããããããã¾ã¨ãããã¨ãã§ãã¾ãããã®ã¾ã¨ãããã¼ãã¯
ããã«ã¡ã¯ããããã§ããæè¿ãã£ãããã¥ã¼ã¹æ å½ã¨ãã¦å®çãã¦ãã¾ãã¾ãããã ä»åã¯google ãå ¬éããæè²ã¨ç 究ã®ããã®ç 究ãã¼ã«ã§ãã Colaboratory ã«ã¤ãã¦è§£èª¬ãã¦ããããã¨æãã¾ãã ãã£ã¨æ¤ç´¢ãã¦ã¿ãã¨ããè±èªçã§ããã¾ã è¨äºãåºã¦ããªãããã§ããã®ã§ãæ¥æ¬èªçæéã¨é¡ããã¦ããã ãã¾ããã ãã¥ã¼ã¹æ¦è¦ Colaboratoryã¯Jupyter notebookãåºç¤ã¨ãããªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ããç¾å¨ãColaboratoryã¯Chromeã®ãã¹ã¯ãããçã§ã®ã¿åä½ãããåªããã¦ã¼ã¶ã¼ã¨ã¯ã¹ããªã¨ã³ã¹ãæä¾ããããã«ãå½åã¯ãã¼ãããã¯ã®ä½æãç·¨éã¸ã®ã¢ã¯ã»ã¹ãå¶éãã¦ããããããããããã®ãããå©ç¨ããã«ã¯ç³ãè¾¼ã¿ãããªãã¦ã¯ãããªããColaboratoryãã¼ãããã¯ã¯ãã¹ã¦Googleãã©ã¤ãã«ä¿åããããæ¢åã®Jupyter / IPythonã
2. æ¬â½ã®å 容 læ©æ¢°å¦ç¿ lããã°ã©ãã³ã°â¾èªPython lPythonã§ã®æ©æ¢°å¦ç¿ lå種⼿æ³ã®â½è¼ lDeep Learningã®å©â½¤ (Chainer / Keras) lã¾ã¨ã ãµã³ãã«ã³ã¼ãã¯githubã«ããã¾ã https://github.com/yasutomo57jp/ssii2016_tutorial https://github.com/yasutomo57jp/deeplearning_samples 3. æ©æ¢°å¦ç¿ã¨ã¯ l ãã¼ã¿ããè¦åæ§ãç¥èãâ¾ã¤ããã㨠l åºæ¥ãã㨠à å帰 ²é¢æ°ã®ãã©ã¡ã¼ã¿ãæ¨å®ãã à ã¯ã©ã¹åé¡ Â²ã¯ã©ã¹ãåé¡ããåºæºï¼ã«ã¼ã«ãâ¾ã¤ãã à ã¯ã©ã¹ã¿ãªã³ã° ²ãã¼ã¿ãè¤æ°ã®éåã«åå²ããã«ã¼ã«ãâ¾ã¤ãã ãã¼ã¿ã«æ½ãè¦åæ§ ç¥èãçºâ¾ ⼤éã® ãã¼ã¿ æ©æ¢°å¦ç¿
ã©ãããã°PythonãJuliaã¨åããããéãåãããã®ãï¼ : æ§ã ãªããæ¹ã§è¨ç®ã®é«éåãå³ã Julia対Python ç§å¦æè¡è¨ç®ã«ã¯ãPythonãªã©ã®è¨èªãããJuliaã使ã£ãæ¹ãããã®ã§ããããï¼ http://julialang.org/ ã«è¼ã£ã¦ãããã³ããã¼ã¯ãè¦ãã¨ãã©ããã¦ããããªé¢¨ã«æã£ã¦ãã¾ãã¾ããã¨ããã®ããPythonãªã©ã®é«æ°´æºè¨èªã¯ãã¹ãã¼ãé¢ã§å¤§å¹ ã«å£ã£ã¦ããã®ã§ããããã©ããããã¯ç§ãæåã«æããçåã§ã¯ããã¾ãããç§ãæ°ã«ãªã£ãã®ã¯ããJuliaã®ãã¼ã ãæ¸ããPythonã®ãã³ããã¼ã¯ã¯ãPythonã«æé©ãªãã®ã ã£ãã®ãï¼ãã¨ãããã¨ã§ãã ãããã£ãå¤è¨èªã®æ¯è¼ã«ã¤ãã¦ãç§ã®èããè¿°ã¹ã¾ããããã¾ããã³ããã¼ã¯ã¨ããã®ã¯ãå®è¡ããã¿ã¹ã¯ã«ãã£ã¦å®ç¾©ããããã®ã§ãããã£ã¦ããã®ã¿ã¹ã¯ãå®è¡ããããã®æé©ãªã³ã¼ãããåè¨èªã«ç²¾éãã人ã ãæ
Pythonã§ã®ã°ã©ãæç» Pythonãã£ã¼ããæãå ´åã®å®çªã¯ãmatplotlibãã§ããããã®è¦ãç®ã®ããéæ®ã£ããæãã¨ã表è¨æ³ã®ããããããææããã¦ãã¾ãã ããã§ããã®è¨äºã§ã¯Matplotlibã®æ©è½ãããç¾ãããã¾ãããç°¡åã«å®ç¾ããããã®ã©ããã¼çåå¨ã§ããããSeabornãã®ä½¿ãæ¹ãåãä¸ãã¾ãã â Overview of Python Visualization Tools http://pbpython.com/visualization-tools-1.html ä¸è¨ã®è¨äºã§ã¯Matplotlibã¨Seabornã«ã¤ãã¦ä¸è¨ã®ããã«æ¸ããã¦ãã¾ãã matplotlibã«ã¤ã㦠Matplotlib is the grandfather of python visualization packages. It is extremely powerful b
ä»å¹´ã®7æã«éå¬ãããSciPy2015ã®è¬æ¼åç»ãEnthoughtã®ãã£ã³ãã«ã§å ¬éããã¦ãããä»å¹´ãé¢ç½ãè¬æ¼ãå¤ãã®ã§ãããããã§ãã¯ãã¦ããã ä»å¹´ã®ç®æ¨ï¼2015/1/11ï¼ã«Pythonã®æ©æ¢°å¦ç¿ã©ã¤ãã©ãªã§ããscikit-learnã使ãããªãã¨ããã®ãå ¥ã£ã¦ããã®ã§ãã¾ãã¯scikit-learnã®ãã¥ã¼ããªã¢ã«ãä¸éãè¦ããã¨ã«ããã Part Iã¨Part IIãåãããã¨6æé以ä¸ããé常ã«å å®ãã¦ãããIPython Notebookå½¢å¼ã®è³æããã¼ã¿ã¯ä¸è¨ã®GitHubã¢ã«ã¦ã³ãã§æä¾ããã¦ããããã¼ãããã¯ããã¦ã³ãã¼ãããå®éã«æãåãããªãããã¥ã¼ããªã¢ã«ãé²ããã¨ç解ãããé²ããããããªãã ãã¨ã§æ¯ãè¿ããããããã«å 容ãç°¡åã«ã¾ã¨ãã¦ããããã 1.1 Introduction to Machine Learning æ©æ¢°å¦ç¿ã·ã¹ãã ã®æµããæ師ã
Python å¯å¤é·å¼æ° ãå®ç¾©ããã¡ã½ãããå¼ã³åºãã¨ãã«æ°ãã¤ããã¹ããã¨ ï½ ã¢ã¹ã¿ãªã¹ã¯ï¼ã¤ã®å¯å¤å¼æ°ã¯ãããã¼ã¯ã¼ãæå®ããªãã§ä¸ããã / ãã¢ã¹ã¿ãªã¹ã¯ï¼ã¤ã®å¯å¤å¼æ°ã¯ããã¼ã¯ã¼ãæå®ãã¦ä¸ããã Pythonpython2.7å¯å¤é·å¼æ°ã¡ã½ããå®ç¾©å¼æ°
from datetime import datetime as dt tstr = '2012-12-29 13:49:37' tdatetime = dt.strptime(tstr, '%Y-%m-%d %H:%M:%S') strptimeã®ç¬¬äºå¼æ°ã¯ç¬¬ä¸å¼æ°ã®ãã©ã¼ãããã渡ãã ä¾ãã°ã tstr = '2012/12/29 13:49:37'ã ã£ãå ´åã dt.strptime(tstr, '%Y/%m/%d %H:%M:%S') æååããæ¥ä»(date) import datetime tstr = '2012-12-29 13:49:37' tdatetime = datetime.datetime.strptime(tstr, '%Y-%m-%d %H:%M:%S') tdate = datetime.date(tdatetime.year, tdatetime.mo
multiprocessing ã®åºæ¬Â¶ ãµãããã»ã¹ã使ç¨ããæãç°¡åãªæ¹æ³ã¯å¯¾è±¡é¢æ°ã¨å ±ã« Process ãªãã¸ã§ã¯ããã¤ã³ã¹ã¿ã³ã¹åãããã¨ã§ããã®å¦çãéå§ãããããã« start() ãå¼ã³åºãã¦ãã ããã import multiprocessing def worker(): """worker function""" print 'Worker' return if __name__ == '__main__': jobs = [] for i in range(5): p = multiprocessing.Process(target=worker) jobs.append(p) p.start()
åºæ¬çãªä½¿ãæ¹ åºæ¬çã«ã¯ä»¥ä¸ã®ããã«ä½¿ãã #!/usr/bin/env python # -*- coding: utf-8 -*- import logging if __name__ == '__main__': logging.basicConfig() logging.debug('this is debug message') logging.info('this is info message') logging.warning('this is warning message') logging.error('this is error message') logging.critical('this is critical message') å®è¡çµæã¯ä»¥ä¸ã WARNING:root:this is warning message ERROR:root:this is
HTML ã¨ãã¦æå³ãæã¤æåãã¨ã¹ã±ã¼ããã Pythonã¹ã¯ãªããã®ä¸ã«ç¾ããæååããã®ã¾ã¾HTMLã«åºåããã¨æå¾ éãã«è¡¨ç¤ºãããªããã¨ãããã¾ãã ããã¯ãhtmlã«å«ããããã«ã¯ã¨ã¹ã±ã¼ãããªãã¦ã¯ãªããªãæåãããããã§ãã HTMLã®ããã¹ãã¨ãã¦ã¨ã¹ã±ã¼ãããªãã¦ã¯ãªããªãæåã¯ãã<ãã>ãã&ãã®ï¼ã¤ã§ãã ã¾ããã¿ã°ã®å±æ§é¨åã«ç¾ããæåã®å ´åã¯ããããã®ï¼ã¤ã«å ãã¦ãã"ããã¨ã¹ã±ã¼ãããªãã¦ã¯ãªãã¾ããã ãããã¯ã ã&ã----& ã>ã----> ã<ã----< ã"ã----": ã¨ãªãã¾ãã xml.sax.saxutils ã¢ã¸ã¥ã¼ã«ã«ã¯ãããã®æåãã¨ã¹ã±ã¼ããã¦ããã escape, quoteattr é¢æ°ãç¨æããã¦ãã¾ãã escape é¢æ°ã¯æ¬æç¨ã§ã quoteattr ã¯ã¿ã°ã®å±æ§é¨åç¨ã§ãã >>> f
ããã«ã¡ã¯ã Pythonã§ããã°ã©ãã³ã°å§ãã¦ããæãããã¨ãªãã§ãããæè¿ã®CPUã¯è¤æ°ã³ã¢ãå½ããåã«ãªã£ã¦ãã¦éãããã°ã©ã ãæ¸ãã¦å®è¡ãã¦ãCPU使ç¨ç100%ã«ã§ããªãã¦é¢ç½ããªããã§ãããã ãã¡ã ã¨Core i7ãå ¥ã£ã¦ããã®ã§è¦ããä¸8CPUã®ãã¡1ã¤ã ãããã«ã«ä½¿ããã¦æ°åã§ã¯13%ã«ãããªãã¾ããã å¹çãæªãããã«æããã®ã¯ãã¡ããã§ãããããã§ã¯ããã°ã©ãã³ã°ã®ééå³ã§ããå¾ææãæ¯é æã13%ãã享åã§ãã¾ããã è¥ãããé ãææ¢ã«ãCããã°ã©ãã³ã°ã«ææ¦ãã(ããã¦æ«æãã)ãã®é ã¯1CPU1ã³ã¢ãããªãã£ãã®ã§éãããã°ã©ã ãæ¸ãã°100%ã§CPUãåãä»ã®åä½ãªã©ä¸ååãä»ããªããããªç¶æ ãä½ãã¦é常ã«è奮ãããã®ã§ãã ãããã幾年ãåã³ããã°ã©ãã³ã°ãå§ãã¦ãæè¡ã®é²åããããªã¨ãããããããã³ã奪ã£ãã®ãã¨æç¶ã¨ãã¾ããã ã§ããã ã¨ãããããCP
#! /usr/local/bin/python # -*- coding:utf-8 import multiprocessing def plus_data(num): return num+1 def multi_plus_one(before_list): pool = multiprocessing.Pool(processes=4) return pool.map(plus_data, before_list) if __name__ == "__main__": before_list = range(10) print before_list # ãªã¹ãã®è¦ç´ ã«ãã¹ã¦+1 print multi_plus_one(before_list) #! /usr/local/bin/python # -*- coding:utf-8 import multiprocessing d
æ½å¨ãã£ãªã¯ã¬é åæ³ (Latent Dirichlet Allocation) ã«ããææ¸éåã®ã¯ã©ã¹ã¿ãªã³ã°ã試ãã¦ã¿ã¾ããã LDA ã®å®è£ ã¯æ¢ãã°è²ã ã¨åºã¦ããã®ã§ãããä»å㯠plda ãå©ç¨ãã¦å®é¨ãã¾ããplda ã®ã½ã¼ã¹ã³ã¼ãã¯ä¸è¨ã® URL ãããã¦ã³ãã¼ãã§ãã¾ãã http://code.google.com/p/plda/ å®é¨ç¨ã®ã³ã¼ãã¹ã«ã¯ wikipedia ã®ãè¦ç´ãã使ãã¾ãããã¦ã³ãã¼ãããããã¼ã¿ã¯å·¨å¤§ãªã®ã§ãããããé©å½ã«éå¼ã㦠5000 è¨äºãå©ç¨ãã¾ããã¾ãã極端ã«çãè¨äºã¯ä½¿ããããªãã®ã§ãå 容ã 100 æåæªæºã®è¨äºã¯é¤å¤ãã¦ãã¾ãã $ wget http://dumps.wikimedia.org/jawiki/latest/jawiki-latest-abstract.xml $ grep '^<abstract>' jawiki-
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}