Jelajahi data

Simulasi Monte Carlo di Python

Izzy Weber

Curriculum Manager, DataCamp

Dataset diabetes

Sepuluh variabel independen:

  • Usia age
  • Jenis kelamin sex
  • Indeks massa tubuh bmi
  • Tekanan darah rata-rata bp
  • Enam pengukuran serum darah: tc, ldl, hdl, tch, ltg, glu
1 Bradley Efron, Trevor Hastie, Iain Johnstone and Robert Tibshirani (2004) "Least Angle Regression," Annals of Statistics (with discussion), 407-499 2 https://www4.stat.ncsu.edu/~boos/var.select/diabetes.html
Simulasi Monte Carlo di Python

Dataset diabetes

Variabel dependen

  • Ukuran kuantitatif progresi penyakit satu tahun setelah baseline, y

 

Ukuran dataset

  • 442 pasien diabetes
Simulasi Monte Carlo di Python

Dataset diabetes

dia.head()
|     | age | sex | bmi  | bp     | tc  | ldl   | hdl  | tch  | ltg    | glu | y   |
|-----|-----|-----|------|--------|-----|-------|------|------|--------|-----|-----|
| 0   | 59  | 2   | 32.1 | 101.00 | 157 | 93.2  | 38.0 | 4.00 | 4.8598 | 87  | 151 |
| 1   | 48  | 1   | 21.6 | 87.00  | 183 | 103.2 | 70.0 | 3.00 | 3.8918 | 69  | 75  |
| 2   | 72  | 2   | 30.5 | 93.00  | 156 | 93.6  | 41.0 | 4.00 | 4.6728 | 85  | 141 |
| 3   | 24  | 1   | 25.3 | 84.00  | 198 | 131.4 | 40.0 | 5.00 | 4.8903 | 89  | 206 |
| 4   | 50  | 1   | 23.0 | 101.00 | 192 | 125.4 | 52.0 | 4.00 | 4.2905 | 80  | 135 |
1 https://www4.stat.ncsu.edu/~boos/var.select/diabetes.html 2 http://statweb.lsu.edu/faculty/li/IIT/diabetes.txt
Simulasi Monte Carlo di Python

Mengapa mengeksplorasi data sebelum simulasi?

  • Inspeksi visual distribusi variabel
    • Intuisi untuk distribusi probabilitas
  • Periksa dan ukur korelasi antar prediktor
    • Dasar untuk memodelkan struktur kovarians
  • Periksa dan ukur korelasi antara prediktor dan respons
    • Pemahaman awal hubungan prediktor–respons
Simulasi Monte Carlo di Python

Pairplot dataset

sns.pairplot(dia)

pairplot variabel pada dataset dia

Simulasi Monte Carlo di Python

Pairplot dataset

sns.pairplot(dia)

Pairplot dengan penyorotan sex

Simulasi Monte Carlo di Python

Pairplot dataset

sns.pairplot(dia)

pairplot dengan tc dan ldl disorot

Simulasi Monte Carlo di Python

Korelasi antar variabel

dia.corr()

Matriks korelasi yang menunjukkan korelasi antar variabel di dia

Simulasi Monte Carlo di Python

Ayo berlatih!

Simulasi Monte Carlo di Python

Preparing Video For Download...