Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tokyo webmining 2017-10-28

6,255 views

Published on

Presented at Tokyo Web Mining

Published in: Technology
  • Be the first to comment

Tokyo webmining 2017-10-28

  1. 1. 2017 10 28 Web
  2. 2. Twitter: @hamukazu Python 5
  3. 3. EC ASP
  4. 4. • Scipy/Numpy • • • •
  5. 5. • • •
  6. 6. scikit-learn TensorFlow • • • • •
  7. 7. Python • Numpy • Cython
  8. 8. s = 0 for i in range(1, 100000001): s += i print(s) 1 1
  9. 9. s = sum(range(1, 100000001)) print(s)
  10. 10. import numpy as np a = np.arange(1, 100000001, dtype=np.int64) print(a.sum())
  11. 11. s = 0 for i in range(1, 100000001): s += i print(s) s = sum(range(1, 100000001)) print(s) import numpy as np a = np.arange(1, 100000001, dtype=np.int64) print(a.sum()) 30.21 12.33 0.38
  12. 12. Numpy • Numpy • Numpy •
  13. 13. Cython • Python C • • Numpy
  14. 14. Cython def prime(n): p = [True] * (n + 1) m = 2 while m < n + 1: if p[m]: i = m * 2 while i < n + 1: p[i] = False i += m m += 1 i = n while not p[i]: i -= 1 return i n p(10000000) Python 4.75 Cython 3.04
  15. 15. def prime(n): p = [True] * (n + 1) m = 2 while m < n + 1: if p[m]: i = m * 2 while i < n + 1: p[i] = False i += m m += 1 i = n while not p[i]: i -= 1 return i def prime(int n): cdef int i, m p = [True] * (n + 1) m = 2 while m < n + 1: if p[m]: i = m * 2 while i < n + 1: p[i] = False i += m m += 1 i = n while not p[i]: i -= 1 return i 3.04 3.04
  16. 16. def prime(int n): cdef int m, i cdef int * p = <int * >malloc((n + 1) * sizeof(int)) for i in range(n + 1): p[i] = 1 m = 2 while m < n + 1: if p[m]: i = m * 2 while i < n + 1: p[i] = 0 i += m m += 1 i = n while not p[i]: i -= 1 free(p) return i 3.04 0.17 C
  17. 17. Cython • • •
  18. 18. http://bit.ly/kimikazu20140913 http://bit.ly/kimikazu20160204 Python PyCon JP 2014 2016
  19. 19. … • •
  20. 20. Premature optimization is the root of all evil. — Donald Knuth
  21. 21. • • • • XP •
  22. 22. • • •
  23. 23. • • •
  24. 24. XP • • ☓ ○ • • •
  25. 25. • • • • • •
  26. 26. Scikit-learn SpectralClustering
  27. 27. • • • •
  28. 28. XT X
  29. 29. • • • • • • • •
  30. 30. x Softplus f(x) = log(1 + ex ) f(x) ⇡ x f(1000)
  31. 31. • • • • •
  32. 32. • Python • • • • •

×