NumPy: 基本的な統計

Python 入門

Hugo Bowne-Anderson

Data Scientist at DataCamp

データ分析

  • データを理解する

  • 少量のデータ → そのまま見ればいい

  • 大量のデータ → ?

Python 入門

市内全域の調査

import numpy as np
np_city = ... # Implementation left out
np_city
array([[1.64, 71.78],
       [1.37, 63.35],
       [1.6 , 55.09],
       ...,
       [2.04, 74.85],
       [2.04, 68.72],
       [2.01, 73.57]])
Python 入門

NumPy

np.mean(np_city[:, 0])
1.7472
np.median(np_city[:, 0])
1.75
Python 入門

NumPy

np.corrcoef(np_city[:, 0], np_city[:, 1])
array([[ 1.     , -0.01802],
       [-0.01803,  1.     ]])
np.std(np_city[:, 0])
0.1992
  • sum(), sort()など

  • データ型が1つにそろうため高速!

Python 入門

データ生成

  • np.random.normal(){{1}} の引数
    • 分布の平均
    • 分布の標準偏差
    • サンプル数
height = np.round(np.random.normal(1.75, 0.20, 5000), 2)

weight = np.round(np.random.normal(60.32, 15, 5000), 2)


np_city = np.column_stack((height, weight))
Python 入門

練習しましょう!

Python 入門

Preparing Video For Download...