SlideShare a Scribd company logo
1 of 59
みんなの
プログラミング勉強会
#01
2019年11月28日
この勉強会のテーマ
コミュニケーション
コミュニケーションとは何か(1)
コミュニケーション 状態遷移
良好な状態
良好でない状態
コンテクスト
変化する環境への適応
=学習
コミュニケーションとは何か(2)
❖ すべての「システム」はコミュニケーシ
ョンによって維持されている
❖ 「システム」とは「状態」を持つ「固体
」の集合体
❖ 社会(人間の集合),自然(生物,無生物
の集合)
❖ システムの状態は常に変化する
❖ コミュニケーションとフィードバックに
よってシステムが適応し,維持される
❖ よりよい適応 = 学習
システム
システム
伝わらない言葉
(シャノンの通信モデル)
オレオレ オレ=あの子
発信者
符号化
受信者
複合化
通信経路
言葉の多義性
コミュニケーション
意味の拘束
コード コードとは
プログラムの
ことです
コンテクストとドメイン
• コンテクスト
• 説明
• 意味を拘束する追加の情報
• ドメイン
• 場
• この「場」でコードと言えばPythonのプログラム
• ドメインは説明を伴わないコンテクスト
プログラミングとは
数字にすると
自動化できるよ
計算
計算?
最近のコンピュータは
どう見ても
計算以上のことを
実行している
ドメインの問題
何をどう
数字
にするのかが
ドメインによって違う
数字
と言えば?
0からはじまる
計算ができる
π整数
数字でないもの
といえば?
言葉
記号 文字
コンピュータ上では
なんでも
数字
プログラマが所属するドメイ
ン
49が好き
素数なのに
素数っぽく
ないから
プログラミングとは
数字にすると
自動化できるよ
いろんなものを
手順と数字
数字と計算による条件分岐
降水
確率
50%を
超える
Yes
No
傘を
持つ
持た
ない
x
x - 50
0超 → 〇
0以下 → ×
if x - 50 > 0:
傘を持つ()
if x > 50:
傘を持つ()
x <= 50なら,手順
を飛ばす(この場合は
1行)。
数字でないものを
数字として扱う
文字を数字にする
対応が
決まっている
(国際規格)
112,121,116,104,111,110
python
a b c
97 98 99
“ “ 文字列
数値列
符号化
なにが嬉しいのか
•数字でできること
•計算
•比較
文字を数字にして計算
“brutus”
98,114,117,116,117,115
+3
101,117,120,119,120,118
“euxwxv”
暗号
(シーザー暗号)鍵 -3
比較(等しいかどうか)
“python”
“python”
等しい
“confirm”
“conform”
異なる
一致する
かどうか
“confirm”
“conform”
「先頭から一文字ずつ比
較」を繰り返す
(ループ)
検索
twinkle, twinkle, little star, how i wonder
what you are! up above the world so high,
Like a diamond in the sky. twinkle, twinkle,
little star, how i wonder what you are!
when the blazing sun is gone, When he
nothing shines upon. then you show your
little light, twinkle, twinkle, all the
night. twinkle, twinkle, little star, how i
wonder what you are!
検索
…up above the world so high, Like a diamond in the sky…
the
先頭から一文字ずつ文字列検
索する
並べ替え
Alice
Bob
Chris
Christle
Alice
Bob
Chris
Christle
符号化した数を比較して並べ
替え
先頭が同じなら,二文字以降
を同様に比較
(ループ)
漢字の並べ替え
吉田
田中
加藤
田中
加藤
吉田
ならない
田中
加藤
吉田
こうなる
吉 田 加
211523000021513
かとう
たなか
よしだ
ユニコード(UTF8)
符号化のいろいろ
a b c
97 98 99
ASCII
吉 田 加
211523000021513
ユニコード(UTF8)
符号化のいろいろ(2)
モールス信号
目的にあわせていろいろな符号化をする
コンピュータの文字列処理
基本 : 文字を符号化した数値データに対する処理
演算(計算) 比較 統計処理
暗号
通信
(エラー補正)
一致
検索
型変換
テキスト
マイニング
機械学習
(自然言語処理)
重要
文字列処理の応用
遺伝子工学
符号化
DNA解析
• ヒトDNAの塩基対は30億
• AGCTの4種類の文字で表される
• 必ずA-T,G-Cの対になる
• タンパク質を作るための設計図と,いつ,どこで作るかを表現した記号でできている
• 皮膚や筋肉だけでなく,ホルモン,酵素,神経伝達物質など様々な「部品」にな
る
• 物質としてのDNAを文字に「符号化」し,特定の文字列(AGCTの組み合わせ)に一致
する部分を探し出すことで,タンパク質を作っている部分を特定できる
• 符号化とコンピュータを組み合わせると,この処理を高速に実行できる
文字データの統計処理
• 文字で構成されたデータはなんでも符号化できる
• 小説,論文,手紙,メール文,etc.
• 文字の符号化データ自体は,計算したり統計処理をし
てもあまり役に立たない
ちなみに,文字の使用頻度に
は「かたより」があることが
知られています。
テキストマイニング
• 文字ごとの統計では面白い結果が出てこない
• 文字を「まとめて」単語レベルでデータ処理すると少し面白くな
る
• 単語を検索して数を数える -> 文章中にどの単語がどのくらい表れ
るか,「頻度」を計算する
Twinkle, twinkle, little star, How I wonder
what you are! Up above the world so high,
Like a diamond in the sky. Twinkle, twinkle,
little star, How I wonder what you are!
When the blazing sun is gone, When he
nothing shines upon. Then you show your
little light, Twinkle, twinkle, all the
night. Twinkle, twinkle, little star, How I
wonder what you are!
“the”が
4つある
テキストマイニング(2)
• 1968年,研究者がシェークスピアの著作について,単語
の出現頻度を調査(88万語,3万種類の単語から)
• 1976年,二人の統計学者が,頻度表を元に彼の語彙数を
推定(約65,000語)
• 1985年,オックスフォード大学でシェークスピアと同年
代,作者不詳の詩が発見される
• 語彙を調べたのと同じ手法を使って,詩がシェークスピ
アのものであることを推定
コンピュータの文字列処理(再)
比較
一致
検索
演算(計算)
暗号
通信
(エラー補正)
型変換
統計処理
テキスト
マイニング
機械学習
(自然言語処理)
大量のデータに対して,とても高速に計算を実
行できる
重要
とても
重要
プログラミングの重要な手法
コンピュータ上で
「同じ」と扱える
2つ以上のもの
を見つける
「符号化」は,そのための常套手段
a b c
97 98 99
エクセルの(Pythonによる)自動化
セルへの入力
ソート
合計,平均
セルの装飾
データのコピペ マクロの実行
セル操作(手動)
エクセルの(Pythonによる)自動化
エクセルの表
エクセルファイル
同じ
Python
openpyxl
'example.xlsx'
get_sheet_by_name
Pythonのプログラムでファイルを読み込む
同じ
自動化のフロー
Python
読み込み
書き出し
入力
出力
セルの操作
列(row)→
行(column)→
sheet row column value
sheet value
または
複数行をまとめて
処理したい 繰り返し
(ループ)
セル結合は悪!
プログラムで処理しづらくなる
セル位置は数字,または
英数と同じ
セル位置の符号化
どう楽になるのか
計算してくれ
計算してくれ
選んでくれ
転記してくれ
面倒くさい
人類の悲願 : 転記と計算からの開放
エクセルのご先祖様
プログラム作るの面倒ですか?
• 日時の売り上げデータが300個のエクセルファイルにある
• これを集計する必要がある
• 毎日10分かかるエクセルの作業がある
• 年間200日勤務として,2000分 = 33時間!
• 自動化して浮いた時間は他の仕事をさせられる?
• こっそりやればいいのです
• 浮いた時間は「学習」に当てて下さい
手作業が好きな人のイメージ
1960年代のテキストマイニング
• シェイクスピア著作から,単語の出現頻度を調べた(統計
調査)
• 彼の著作は88万語あり,基本手作業
• パート(おもに女性)を雇い,人海戦術で単語を調査
• 3万の単語が使われていたことがわかり,頻度も判明
• 時間と人件費が(ものすごく)かかる
令和時代のテキストマイニン
グ
Webによるテキストマイニング
リンクのクリック
本文のコピー
文書ファイルの保存
ワープロへのペースト
手作業
Webブラウザ
インターネットアクセスの自動化
Webサイトを表示
インターネット
通信の仕組み
(プロトコル)
Webを表示する
ためのデータ
(データ)
Python
文字データの抽出
(文字列検索)
同じ
Pythonによるスクレイピング
'https://tenki.jp/lite/forecast/3/16/4410/13112/'
r requests get(url)
範囲の選択
soup = BeautifulSoup(r.content, "html.parser")
today = soup.find(id=“today_weather”)
weather = today.p.string # 今日の天気 = 曇りのち雨
いろんな地域の天気を知りたい
ループ
同じ
スクレイピングとは
• Webサイトから必要なデータを抽出する作業の自動化
• Webサイトのデータを文字データとして扱う
• 文字データから,必要なデータを「検索」して「抽出」
• 必要なデータの近くにある文字列に注目(id, class)
• 文字列を使ってデータを「検索」
• 必要な部分のみを「抽出」
• サイトの構造が同じなら,同じ手順で数多くのデータを一括抽出できる
プログラミングとは
数字にすると
自動化できるよ
いろんな情報を符号化して
比較(大小,一致),計算で
きるようになるから
コピー
も重要
特に重要なのが
コンピュータ上で
「同じ」と扱える
2つ以上のもの
を見つける
そのために
数値化(符号化)
を活用する
AI(機械学習)も一種の符号化
あ
文字認識
猫
寿司音声認識
画像認識/分類
ヤバい数値化
• 自動運転が実用化された近未来
• 自動運転車が死亡事故を起こす
• 保険金で和解 金額
自動運転技術の成熟
自動運転によってもた
らされる利益
事故補償に必要な
保険金額
実用化!
数値化しずらいもの
• 生命(とりわけ人間の)
• 観念的な概念
• 感情,幸福,正義/悪,etc.
• 無理に数値化しようとすると大きな齟齬(そご)が生まれる
ことがある
• ex. 成果主義の功罪
倫理の壁
AとBを同じと考える
何かを数値化する
倫理
文化や時代によっ
て壁の位置が変わ
る

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

みんなのプログラミング勉強会 #01