181129_BPStudy.pdf

2d809ee0ed9c9c3a33e93486be7d8cf4?s=47 Saito Tsutomu
November 29, 2018
300

 181129_BPStudy.pdf

2d809ee0ed9c9c3a33e93486be7d8cf4?s=128

Saito Tsutomu

November 29, 2018
Tweet

Transcript

  1. ਺ཧ࠷దԽΛ࢖ͬͨ ໰୊ղܾͷ͢͢Ί ʢגʣϏʔϓϥ΢υ ࡈ౻ ౒ 11/29 BPStudy#135ʙΤϯδχΞͷ஌తੜ࢈ज़

  2. BeProudͷαʔϏε • connpass ΤϯδχΞΛͭͳ͙ITษڧձࢧԉ ϓϥοτϑΥʔϜ • PyQ ຊؾͰϓϩάϥϛϯάΛֶͼ͍ͨਓͷ PythonΦϯϥΠϯֶशαʔϏε •

    TRACERY • γεςϜ։ൃνʔϜ޲͚஌ࣝڞ༗αʔϏε
  3. ͓લ୭Αʢ1/2ʣ • PyQʢֶशαʔϏεʣͷ໰୊࡞੒͍ͯ͠·͢ • ਺ֶͱΞϧΰϦζϜ • Pythonσʔλॲཧதڃ • NumPyσʔλॲཧ •

    Python౷ܭ෼ੳ • Pythonػցֶशதڃ • ਺ཧతΞϓϩʔνʹΑΔ໰୊ղܾ
  4. ͓લ୭Αʢ1/2ʣ • ਺ཧ࠷దԽɺΦϖϨʔγϣϯζɾϦαʔνͷઐ໳Ոʢ↓ग़൛ॻ੶ʣ • ࠓ೔͔Β࢖͑Δ!૊߹ͤ࠷దԽ • PythonݴޠʹΑΔϏδωεΞφϦςΟΫε - ࣮຿ՈͷͨΊͷ࠷దԽɾ౷ܭղੳɾػցֶश -

    • ϞσϦϯάͷॾ૬ (γϦʔζ:࠷దԽϞσϦϯά) • ϚωʔδϯάɾβɾαϓϥΠɾνΣΠϯ • σʔλ෼ੳϥΠϒϥϦʔΛ༻͍ͨ࠷దԽϞσϧͷ࡞Γํ
  5. ਺ཧ࠷దԽͱ͸ ਺ཧ࠷దԽͱ͸ɺ໰୊ղܾͷख๏Ͱ͢ɻ ՝୊Λ਺ཧϞσϧͱͯ͠ͱΒ͑ɺ࠷దղʢ࠷΋ྑ͍౴͑ʣΛٻΊ·͢ɻ ͜͜Ͱ͸࠷దղΛ1͚ͭͩٻΊΔ͜ͱΛߟ͑·͢ɻ ਺ཧϞσϧ͸ɺʮม਺ɺ੍໿৚݅ɺ໨తؔ਺ʯͰߏ੒͞Ε·͢ɻ ɾม਺ͷͱΓ͏ΔۭؒΛղۭؒͱ͍͍ɺ1ͭͷղ͸্ۭؒͷ1఺ʹͳΓ·͢ɻ ɾ੍໿৚݅͸ɺۭؒͷதͷนʹͳΓ·͢ɻ ɾ໨తؔ਺͸ɺۭؒͷதͷϕΫτϧʢਐߦํ޲ʣʹͳΓ·͢ɻ ͢ͳΘͪɺ࠷దԽͱ͸ นͰғ·Εۭͨؒʢ࣮ߦՄೳྖҬʣΛਐߦํ޲ʹ࠷΋ਐΜͩ఺Λ୳͢͜ͱ

  6. ࣾձͷ࠷దԽ໰୊ ʮORΛ୳ͤʂʯϙελʔΑΓ • ආ೉ࢪઃͷ഑ஔܭը࡞੒ • ΤωϧΪʔϚωʔδϝϯτܭը࡞੒ • ঎඼ͷ഑ஔ࠷దԽ • ళһͷγϑτεέδϡʔϦϯά

    • ঎඼ͷ഑ૹܭըͷ࡞੒ • ྻंͷӡߦεέδϡʔϦϯά • ྻंͷ৐຿һεέδϡʔϦϯά • Ӻͷ৐Γ׵͑ͷ࠷దԽ • ෺ྲྀίϯςφͷύοΩϯά • ੜ࢈ܭըͷ࡞੒ • ࡏݿܭըͷ࡞੒
  7. ਺ཧ࠷దԽͷछྨ Α͘࢖ΘΕΔ࠷దԽ໰୊ʹɺઢܗ࠷దԽ໰୊ͱࠞ߹੔਺࠷దԽ໰୊͕͋Γ·͢ɻ ઢܗ࠷దԽ໰୊͸ɺਐߦํ޲ͷนʹͿ͔ͭͬͨΒɺนʹԊͬͯਐΉ͜ͱͰ࠷దղ͕؆ ୯ʹݟ͔ͭΓ·͢ɻ ࠞ߹੔਺࠷దԽ໰୊͸ɺۭ͕ؒͭͳ͕͍ͬͯͳ͍͜ͱ͕͋ΔͷͰɺ࠷దղΛݟ͚ͭΔ ͜ͱ͕೉͘͠ͳΓ·͢ɻ ͔͠͠ɺ࠷ۙͰ͸ൺֱత؆୯ʹղ͚ΔΑ͏ʹͳ͖ͬͯ·͠ ͨɻ ͨͩ͠ɺน͕ۂ໘ʹͳΔඇઢܗ࠷దԽ໰୊͸ɺղ͚ͳ͍͜ͱ͕ଟ͍Ͱ͢ɻ ࠞ߹੔਺࠷దԽ໰୊ͷྫͱͯ͠͸ɺ८ճηʔϧεϚϯ໰୊͕͋Γ·͢ɻ͜Ε͸ɺʮෳ

    ਺ͷ౎ࢢΛ࠷΋ૣ͘શ౎ࢢΛճΔॱ൪ΛٻΊΔ໰୊ʯͰ͢ɻ
  8. ࢀߟɿ८ճηʔϧεϚϯ໰୊ͷॻ੶ • ڻ͖ͷ਺ֶ ८ճηʔϧεϚϯ໰୊ɿ΢ΟϦΞϜɾJɾΫοΫ (ஶ), দӜढ़ี (຋༁) • ८ճηʔϧεϚϯ໰୊΁ͷট଴ɿࢁຊ ๕࢚

    (ஶ), ٱอ װ༤ (ஶ) • άϥϑཧ࿦ͷັ࿭ͷੈք- ८ճηʔϧεϚϯ໰୊ɺ࢛৭໰୊ɺதࠃਓ༣ศ഑ ୡ໰୊ɿΞʔαʔɾϕϯδϟϛϯ ଞ(ஶʣ
  9. ८ճηʔϧεϚϯ໰୊ͷԠ༻ྫ • ίϯϏχ΍ࣗಈൢചػͳͲͷ঎඼ͷิॆ • ෳ਺୆ͷं྆Λ༻͍ͨ഑ૹ࠷దԽ໰୊ͷ෦෼໰୊ • ͹Β͹ΒͷΞΠςϜΛݩ௨Γʹ໭͢ʢͭͳ͕Γ΍͢͞Λڑ཭ͱߟ͑Δʣ • ࠷୹௒จࣈྻ໰୊ʢޙड़ʣ

  10. ໰୊1ɿ࠷୹௒จࣈྻ໰୊ͱ͸ ೖྗɿจࣈྻͷू߹S ग़ྗɿSதͷ͢΂ͯͷจࣈྻΛ෦෼จࣈྻͱؚͯ͠Ή ࠷୹ͷจࣈྻ S = ['TAG', 'ACTA', 'GTC', 'GAC']

    ͳΒ͹ɺ ࠷୹௒จࣈྻ͸ GACTAGTCɻ ࢀߟɿʮྋٶϋϧώͷ༕ᓔʯͷ͓͔͛Ͱ25೥ղ͚ͳ͔ͬͨ਺ֶͷ೉໰ ͕ղܾ͞ΕΔ͔΋͠Εͳ͍
  11. ߟ͑ํ จࣈྻͷू߹͔Β෦෼จࣈྻͱͳΔ΋ͷΛআ͍ͯɺۭจࣈྻ("")Λ௥Ճ͓͖ͯ͠·͢ɻ จࣈྻؒ ͷڑ཭Λ৳ͼΔ௕͞ͱ͢Ε͹ɺ࠷୹௒จࣈྻ໰୊͸ɺ८ճηʔϧεϚϯ໰୊ͦͷ΋ͷͰ͢ɻ ྫ͑͹ɺGAC͔ΒACTA΁͸ɺ৳ͼΔ௕͞͸2Ͱ͢ɻ৳ͼΔ௕͞͸ʮ2ͭͷจࣈྻͷ௕͞ͷ࿨͔Β ॏͳΔ௕͞ΛҾ͍ͨ΋ͷʯͰ͢ɻ

  12. σϞ def overlap(s,t): """sͱtͷॏͳΓͷ௕͞""" m = len(s) n = max(0,

    m-len(t)) for i in range(n,m): if s[i:] == t[:m-i]: return m-i return 0 overlap('12345' , '3456') overlap('1234' , '12345') overlap('1234' , '2345') from ortoolpy import tsp def shortest_superstring(words): """࠷୹௒จࣈྻ໰୊""" words = [''] + words n = len(words) dist = {(i, j): len(t) - overlap(s, t) for i, s in enumerate(words) for j, t in enumerate(words) if i != j} _, lst = tsp(words, dist) return ''.join(words[j][len(words[j]) - dist[i, j]:] for i, j in zip(lst, lst[1:])) shortest_superstring(['TAG', 'ACTA', 'GTC', 'GAC'])
  13. ໰୊2ɿόϥόϥͷϐʔεΛ໭͢ ೖྗɿϐʔεͷू߹ͱϐʔεؒͷͭͳ͕Γ΍͢͞ ग़ྗɿݩͷॱ൪ σϞ

  14. import io, pickle, requests with requests.get('https://www.dropbox.com/s/' 'rci3cofa7fiz4wr/image.pkl?dl=1') as r: with

    io.BytesIO(r.content) as fp: pieces, dist = pickle.load(fp) plt.imshow(np.concatenate(pieces), cmap='gray');
  15. n = len(pieces) lst = tsp(range(len(pieces)), dist)[1] # ๚໰ॱ res

    = [pieces[i] for i in lst] plt.imshow(np.concatenate(res), cmap='gray'); plt.imshow(np.concatenate( res[21:]+res[:21]), cmap='gray');
  16. ·ͱΊ • ࣾձͷ໰୊ղܾʹ਺ཧ࠷దԽ͕໾ʹཱͪ·͢ɻ • ࣾձʹ͸༷ʑͳ໰୊͕͋Γ·͕͢ɺయܕతͳ໰୊ʹؼணͤͯ͞ߟ͑Δ ͱղ͖΍͘͢ͳΓ·͢ɻ ࠓ೔঺հͨ͠࿩͸ɺԼهॻ੶Ͱ΋આ໌͍ͯ͠·͢ɻ σʔλ෼ੳϥΠϒϥϦʔΛ༻͍ͨ ࠷దԽϞσϧͷ࡞ΓํʢPythonʹΑ Δ

    ໰୊ղܾγϦʔζʣ https://www.kindaikagaku.co.jp/information/kd0580.htm
  17. PyQͰ໰୊ղֶܾ͕΂·͢ • ࿦ཧͱ໰୊ղܾ • ֬཰ͷ໰୊ • άϥϑཧ࿦ॳڃ • άϥϑཧ࿦தڃ •

    άϥϑΛ࢖ͬͨ࠷దԽ • ઢܗ࠷దԽॳڃ • σʔλ෼ੳͱ࠷దԽ • ૊߹ͤ࠷దԽॳڃ • ૊߹ͤ࠷దԽͰղ͘ ύζϧ શ෦Ͱ120໰ ࠓޙ΋૿͍͑ͯ͘༧ఆ
  18. ໰୊ղܾίʔεͰѻ͏ ϥΠϒϥϦʔ • NetworkXɿάϥϑɾωοτϫʔΫͷ෼ੳɾ࠷దԽ • PuLPɿઢܗ࠷దԽͱࠞ߹੔਺࠷దԽ͕ղ͚Δ • pandasɿ࠷దԽͷϞσϧ͕࡞ΕΔ ͳͲͳͲ