Submit Search
Upload
九大_DS実践_Python基礎その2
•
0 likes
•
16 views
R
RyomaBise1
Follow
九大で開講しているデータサイエンス実践の講義資料です。
Read less
Read more
Data & Analytics
Report
Share
Report
Share
1 of 44
Download now
Download to read offline
Recommended
chapter6
chapter6
ymk0424
入門機械学習1,2章
入門機械学習1,2章
Kazufumi Ohkawa
Tokyo r28 1
Tokyo r28 1
Takashi Minoda
統計環境R_データ入出力編2016
統計環境R_データ入出力編2016
wada, kazumi
SAS University Editionにおける日本語を含むファイルの取り扱い
SAS University Editionにおける日本語を含むファイルの取り扱い
SAS Institute Japan
九大_DS実践_画像処理応用
九大_DS実践_画像処理応用
RyomaBise1
九大_DS実践_画像処理基礎
九大_DS実践_画像処理基礎
RyomaBise1
九大_DS実践_主成分分析
九大_DS実践_主成分分析
RyomaBise1
Recommended
chapter6
chapter6
ymk0424
入門機械学習1,2章
入門機械学習1,2章
Kazufumi Ohkawa
Tokyo r28 1
Tokyo r28 1
Takashi Minoda
統計環境R_データ入出力編2016
統計環境R_データ入出力編2016
wada, kazumi
SAS University Editionにおける日本語を含むファイルの取り扱い
SAS University Editionにおける日本語を含むファイルの取り扱い
SAS Institute Japan
九大_DS実践_画像処理応用
九大_DS実践_画像処理応用
RyomaBise1
九大_DS実践_画像処理基礎
九大_DS実践_画像処理基礎
RyomaBise1
九大_DS実践_主成分分析
九大_DS実践_主成分分析
RyomaBise1
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
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 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
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
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 Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
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
More Related Content
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
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 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
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
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 Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
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
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How 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.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO 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)
How 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 Insights
Trends 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 summary
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
Google'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
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The 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...
九大_DS実践_Python基礎その2
1.
「Python プログラミング基礎その2」 九州大学 大学院システム情報科学研究院 情報知能工学部門 データサイエンス実践特別講座 備瀬竜馬,
Diego Thomas, 末廣 大貴
2.
復習 2
3.
CSV file format ●CSV
= comma separated values ●File format specifications: ●項目ごとにコンマ “,” で区切られたデータ ●1行が一まとめのデータで、改行で行を識別 ●Example: name, age, weight, height Bob, 40, 80, 175 Taro, 35, 65, 170 ・・・ 3
4.
Excel で csv
ファイル ●Excel 4
5.
Excel で csv
ファイル 5 列 行
6.
Excel で csv
ファイル ●CSV fileとして保存 6 ファイル → “名前を付けて保存” フォルダの選択 ファイルフォーマットの選択 csv(カンマ区切り) 適当に名前をつけて終了
7.
ExelでCSVファイルを作ってみよう! ●Exelを開いて、次の内容を自分で書いてみよう! ●Bob, Taroに加えて、1行分、適当に自分で、データを書 いて、CSVファイルとしてsaveしてみよう! name, age,
weight, height Bob, 40, 80, 175 Taro, 35, 65, 170 (ここに好きなデータを記載) 7
8.
Fileのアップロード 8 クリック クリック 右クリック
9.
Fileのアップロード 9 クリック ファイルを 選択
10.
Fileのアップロード: コマンド from google.colab
import files files.upload() 10 クリック ファイルを 選択
11.
PythonによるCSVファイルの読み込み ●CSVファイル読み込み用の道具をPython上で 呼び出す 11 import pandas as
pd
12.
CSVファイルの読み込み ●CSVファイルを呼び出すおまじない 12 CSVファイルの中身の データが格納 読み込むCSVファイルの名前 読み込むCSVファイルのパス 以下を事前に行うことを忘れないように! (1) import pandas
as pd (2) “some.csv” をコードと同じフォルダに置く 注)他のフォルダにファイルがある場合 pd.read_csv(“path名¥ファイル名”) Windowsでは、¥¥とバックスラッシュ2つ でないと動かない場合もある。
13.
データの見方1 ●好きな行を見る ●好きな列を見る 13 ↑0,1行目をみる ↑0,1,2列目をみる
14.
データの見方2 ●項目(index)を指定してみる ●項目を指定して好きな行を見る 14 ↓項目を指定 行を指定して項目を指定 項目を指定して行を指定 どちらでもO.K.
15.
データの見方2 ●項目(index)を指定してみる ●項目を指定して好きな行を見る 15 ↓項目を指定 行を指定して項目を指定 項目を指定して行を指定 どちらでもO.K. 一個一個見てたらキリがない!
16.
データの可視化(プロット) ●プロットには色んな方法があります ●折れ線グラフ ●ヒストグラム ●散布図 ●etc. 16
17.
はじめに ●今回はサンプルとして次の2つのデータを 使ってみます ●那覇,福岡,札幌の気温データ → temperature_data.csv http://www.data.jma.go.jp/gmd/risk/obsdl/index.php ●体重身長データ(オーストラリア国立スポーツ 研究所の男女202人のアスリートのデータ) → height_weight.csv http://www.statsci.org/data/oz/ais.html 17
18.
おまじないと準備 ●import pandas as
pd ●データの読み込み 18 ファイルの場所は各自置いた場所を 指定しよう
19.
読み込んだデータの中身 19 • 「データフレーム」という 形式で保存 • 行列(縦が行,横が列) •
気温データは • 縦が時間 • 横が地方 • 身長体重データは • 縦が人(サンプル) • 横が項目(性別,身長,体重)
20.
データの見方 ●好きな行をみる ●好きな列をみる 20 ↑0,1,2行目をみる ↑1,2列目をみる
21.
簡単な統計値を出す ●平均値 ●分散 ●標準偏差 21 分散 平均
22.
まとめてみることもできます ●統計量のまとめを表示 データの25%は~以下 データの50%は~以下 データの75%は~以下(上位25%は~以上)
23.
データの可視化(プロット) 23
24.
折れ線グラフ ●折れ線グラフ 24 グラフの横軸が行の番号(index)でわかりにくい
25.
折れ線グラフ ●折れ線グラフ 25 indexを date に変更
26.
折れ線グラフ ●折れ線グラフ 26 右クリックすれば 保存もできます
27.
ヒストグラム ●ヒストグラム ●那覇の気温の分布を見てみる 27
28.
ヒストグラム(発展) ●那覇,福岡,札幌の分布を比較したい 28 binsは棒の数,alpha は透明度 data.plot(kind=‘hist’) data.plot.hist() は同じ処理
29.
Matplotlibを使った可視化 29 ●import matplotlib.pyplot as
plt リストもしくは numpyのarray型 を入力 pandas以外でも 使えます。 csvデータは基本的に pandas の plotでも十分 ですが、より高度な 可視化(自由な可視化) をしたいときには便利 (後ほど紹介)
30.
Numpy array への変換 30 Pandas
の values を使うと numpy の array型として 抽出できる
31.
練習1:データの可視化 ●他の地方の分布も見てみよう ●福岡、札幌、那覇それぞれのヒストグラムを作成 ●bins と alpha
を変えて3地点の分布を比較してみよう ●身長体重データでの統計値も見てみよう 31
32.
散布図 32 ●身長と体重はどんな関係がある?
33.
散布図 33 ●身長と体重はどんな関係があるか? ●性別でどんな違いがあるか?
34.
項目同士の関係性を見るのに便利なプロット ●項目がたくさんあるとき、まとめて関係をプロット ●実際に実行してみましょう ●図は右クリックで保存できます
35.
欠損値について ●csv の中に空白(欠損)があると, NaN (Not
a Number)というものが入る ●サンプルファイルを読み込んでみてみよう 35
36.
欠損値について ●csv の中に空白(欠損)があると, NaN (Not
a Number)というものが入る ●欠損値のあるデータ(行)を取り除く 36
37.
ベクトル表現と ベクトル演算の関数化 37
38.
ベクトル ●データの多くは数字の組,つまりベクトル! ●例:x=[62, 173] ●ベクトルで表現すると, ●データ間の「距離」 ●類似度 などが計算できました 38
39.
ベクトルと python ●np.array を使うと色々な演算が楽 ●まず
「import numpy as np」を実行 ●例: 39
40.
ベクトルの演算:和 ●ベクトルの和(要素同士の和を取る) 40 𝑥𝑥1 𝑥𝑥2 𝑦𝑦1 𝑦𝑦2 𝒙𝒙 𝒚𝒚 𝑥𝑥1 +
𝑦𝑦1 𝑥𝑥2 + 𝑦𝑦2
41.
ベクトルの演算:差 ●ベクトルの差(要素同士の差を取る) 41 𝑥𝑥1 𝑥𝑥2 𝑦𝑦1 𝑦𝑦2 𝒙𝒙 𝒚𝒚 𝑥𝑥1 −
𝑦𝑦1 𝑥𝑥2 − 𝑦𝑦2
42.
ベクトルと数値の積 ●ベクトルと数値の積 42 𝑥𝑥1 𝑥𝑥2 𝒙𝒙 𝑠𝑠 × 𝑥𝑥1 𝑠𝑠
× 𝑥𝑥2 𝑠𝑠 ×
43.
練習2:2つのベクトル間の和と差を 「プログラムで」計算させよう 43 𝒙𝒙 = 3 5 , 𝒚𝒚
= 6 1 のとき 𝒙𝒙+𝒚𝒚 , 𝒙𝒙 − 𝒚𝒚は? 𝒙𝒙 = 3 5 2 , 𝒚𝒚 = 6 1 2 のとき 𝒙𝒙+𝒚𝒚 , 𝒙𝒙 − 𝒚𝒚は?
44.
データ「セット」 ●複数のベクトルを行列で表現 44
Download now