Pertemuan 03: Exploratory Data Analysis (EDA)
Setelah mengikuti pertemuan ini, mahasiswa diharapkan mampu:
- Melakukan visualisasi data geofisika menggunakan Matplotlib dan Seaborn
- Menghitung dan menginterpretasi statistik deskriptif dari data well log
- Menganalisis distribusi dan korelasi antar variabel geofisika
- Mengidentifikasi pattern dan anomali dalam data seismik dan well log
- Membuat insight dari exploratory analysis untuk guide modeling decisions
Ringkasan Materi
1. Tujuan EDA dalam Geofisika
EDA adalah langkah krusial untuk memahami karakteristik data geofisika sebelum modeling. Tujuan utama meliputi memahami distribusi dan range nilai setiap fitur, mengidentifikasi outlier dan anomali, menemukan korelasi antar variabel, dan mendeteksi pattern atau trend dalam data.
2. Statistik Deskriptif
Analisis statistik dasar untuk summarize data geofisika mencakup measures of central tendency (mean, median, mode), measures of spread (variance, standard deviation, IQR), dan measures of shape (skewness, kurtosis).
import pandas as pd
import numpy as np
# Load well log data
df = pd.read_csv('well_log.csv')
# Descriptive statistics
print(df.describe())
# Central tendency
print(f"Mean GR: {df['GR'].mean():.2f}")
print(f"Median RHOB: {df['RHOB'].median():.2f}")
print(f"Mode LITHOLOGY: {df['LITHOLOGY'].mode()[0]}")
# Spread
print(f"Std Dev GR: {df['GR'].std():.2f}")
print(f"Variance NPHI: {df['NPHI'].var():.4f}")
print(f"IQR RHOB: {df['RHOB'].quantile(0.75) - df['RHOB'].quantile(0.25):.2f}")
# Shape
print(f"Skewness GR: {df['GR'].skew():.2f}")
print(f"Kurtosis RHOB: {df['RHOB'].kurtosis():.2f}")
3. Visualisasi Data Geofisika
Visualisasi adalah cara paling efektif untuk memahami data. Berbagai jenis plot yang berguna untuk data geofisika:
- Histogram & Distribution plots: Memahami distribusi nilai well log
- Box plots: Identifikasi outlier dan quartile ranges
- Scatter plots: Analisis hubungan antar fitur (crossplot)
- Correlation heatmap: Matrix korelasi antar semua fitur
- Time series plots: Trend sepanjang depth atau time
- Pair plots: Multiple scatter plots untuk quick comparison
import matplotlib.pyplot as plt
import seaborn as sns
# Set style
sns.set_style("whitegrid")
plt.rcParams['figure.figsize'] = (12, 8)
# 1. Histogram
plt.subplot(2, 3, 1)
plt.hist(df['GR'], bins=50, edgecolor='black', alpha=0.7)
plt.xlabel('Gamma Ray (API)')
plt.ylabel('Frequency')
plt.title('GR Distribution')
# 2. Box Plot
plt.subplot(2, 3, 2)
df[['GR', 'RHOB', 'NPHI']].boxplot()
plt.ylabel('Values')
plt.title('Box Plot Comparison')
# 3. Scatter Plot (Crossplot)
plt.subplot(2, 3, 3)
plt.scatter(df['NPHI'], df['RHOB'], alpha=0.5, c=df['PHIT'], cmap='viridis')
plt.xlabel('Neutron Porosity')
plt.ylabel('Bulk Density')
plt.colorbar(label='Total Porosity')
plt.title('NPHI vs RHOB Crossplot')
# 4. Correlation Heatmap
plt.subplot(2, 3, 4)
corr_matrix = df[['GR', 'RHOB', 'NPHI', 'DT', 'PHIT']].corr()
sns.heatmap(corr_matrix, annot=True, fmt='.2f', cmap='coolwarm', center=0)
plt.title('Correlation Matrix')
# 5. Depth Plot (Log Plot)
plt.subplot(2, 3, 5)
plt.plot(df['GR'], df['DEPTH'])
plt.gca().invert_yaxis()
plt.xlabel('GR (API)')
plt.ylabel('Depth (m)')
plt.title('Gamma Ray Log')
# 6. Pair Plot (using seaborn)
# sns.pairplot(df[['GR', 'RHOB', 'NPHI', 'LITHOLOGY']], hue='LITHOLOGY')
plt.tight_layout()
plt.show()
4. Analisis Korelasi
Pemahaman hubungan antar variabel geofisika penting untuk feature selection. Pearson correlation mengukur linear relationship, Spearman correlation untuk monotonic relationship, dan domain knowledge untuk interpretasi fisik korelasi.
from scipy.stats import pearsonr, spearmanr
# Pearson correlation (linear)
corr_pearson, p_value = pearsonr(df['NPHI'], df['PHIT'])
print(f"Pearson correlation NPHI-PHIT: {corr_pearson:.3f} (p={p_value:.4f})")
# Spearman correlation (monotonic)
corr_spearman, p_value = spearmanr(df['GR'], df['VCLAY'])
print(f"Spearman correlation GR-VCLAY: {corr_spearman:.3f} (p={p_value:.4f})")
# Full correlation matrix
features = ['GR', 'RHOB', 'NPHI', 'DT', 'RESDEEP']
corr_matrix = df[features].corr()
# Find highly correlated pairs (>0.7)
high_corr = []
for i in range(len(corr_matrix.columns)):
for j in range(i+1, len(corr_matrix.columns)):
if abs(corr_matrix.iloc[i, j]) > 0.7:
high_corr.append((corr_matrix.columns[i],
corr_matrix.columns[j],
corr_matrix.iloc[i, j]))
print("\nHighly correlated pairs:")
for feat1, feat2, corr in high_corr:
print(f"{feat1} - {feat2}: {corr:.3f}")
Resources Tambahan
Tugas & Latihan
- Download sample LAS file dan load menggunakan lasio
- Identifikasi dan handle missing values dengan minimal 3 metode berbeda
- Detect dan remove outliers, dokumentasikan berapa data yang di-remove
- Lakukan normalization dengan StandardScaler dan MinMaxScaler, bandingkan hasilnya
- Buat visualization sebelum dan sesudah preprocessing (minimum 4 plots)
- Submit Jupyter notebook dengan dokumentasi lengkap
Persiapan Pertemuan Selanjutnya
Pada pertemuan berikutnya, kita akan membahas Exploratory Data Analysis (EDA). Pastikan Anda sudah:
- Familiar dengan plotting library: Matplotlib dan Seaborn
- Memahami statistik deskriptif dasar (mean, median, std, correlation)
- Install library:
seaborn,plotly(untuk visualisasi interaktif) - Data yang sudah di-clean dari tugas minggu ini akan digunakan untuk EDA