モデルの不確実性とサンプル分布

Pythonで学ぶ線形モデリング入門

Jason Vestuto

Data Scientist

母集団が利用不可の場合

日数と気温区間のヒストグラム、8月の日別最高気温

Pythonで学ぶ線形モデリング入門

サンプルを母集団モデルとして使用

2つのヒストグラム(サンプルと母集団)、正規化された日数と気温区間を比較、各区間のバーはほぼ同じ高さ

Pythonで学ぶ線形モデリング入門

サンプル統計量

1つのサンプルのヒストグラム、日数と気温区間の関係

Pythonで学ぶ線形モデリング入門

ブートストラップリサンプリング

3つのサンプルのヒストグラム、それぞれ中心がずれており、日数と気温区間の軸上に表示

Pythonで学ぶ線形モデリング入門

リサンプル分布

平均値のヒストグラム、サンプル数と平均気温区間の軸上に表示

Pythonで学ぶ線形モデリング入門

ブートストラップのコード実装

# Use sample as model for population
population_model = august_daily_highs_for_2017
# Simulate repeated data acquisitions by resampling the "model"
for nr in range(num_resamples):
    bootstrap_sample = np.random.choice(population_model, size=resample_size, replace=True)
    bootstrap_means[nr] = np.mean(bootstrap_sample)
# Compute the mean of the bootstrap resample distribution
estimate_temperature = np.mean(bootstrap_means)
# Compute standard deviation of the bootstrap resample distribution
estimate_uncertainty = np.std(bootstrap_means)
Pythonで学ぶ線形モデリング入門

復元抽出

# Define the sample of notes
sample = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
# Replace = True, repeats are allowed
bootstrap_sample = np.random.choice(sample, size=4, replace=True)
print(bootstrap_sample)
C C F G
Pythonで学ぶ線形モデリング入門

復元抽出

# Replace = False
bootstrap_sample = np.random.choice(sample, size=4, replace=False)
print(bootstrap_sample)
C G A F
# Replace = True, more lengths are allowed
bootstrap_sample = np.random.choice(sample, size=16, replace=True)
print(bootstrap_sample)
C C F G C G A E F D G B B A E C
Pythonで学ぶ線形モデリング入門

練習しましょう!

Pythonで学ぶ線形モデリング入門

Preparing Video For Download...