Machine Learning
Machine Learning
An AI technology that learns patterns from data to make predictions. Classified into supervised, unsupervised, and reinforcement learning.
Machine Learning
An AI technology that learns patterns from data to make predictions. Classified into supervised, unsupervised, and reinforcement learning.
Machine Learning is a core field of artificial intelligence that learns patterns from data without being explicitly programmed and makes predictions or decisions. Unlike traditional programming, in which rules are coded directly, in machine learning, when you provide data and correct answers (labels), the algorithm discovers the rules on its own.
Machine learning is broadly classified into three types. Supervised Learning learns from input-output pairs and is used for classification and regression problems. Unsupervised Learning discovers the structure of data without labels and is used for clustering and dimensionality reduction. Reinforcement Learning learns a policy that maximizes rewards by interacting with an environment.
The core processes of machine learning are Training, Validation, and Test. Model parameters are learned with training data, hyperparameters are tuned with validation data, and final performance is evaluated with test data. Techniques such as Cross-Validation, regularization, and dropout are used to prevent Overfitting.
In 2024-2025, the machine learning ecosystem evolved rapidly. Deep Learning has taken over the fields of image, language, and speech, and LLMs have opened a new paradigm. However, for structured data, XGBoost, LightGBM, and Random Forest are still dominant. AutoML tools (H2O, AutoGluon) automate model selection, and MLOps has become the standard for production deployment.
# 머신러닝 기본 워크플로우
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, classification_report
import pandas as pd
import numpy as np
# 1. 데이터 로드 및 탐색
df = pd.read_csv('data.csv')
print(f"데이터 크기: {df.shape}")
print(f"결측치: {df.isnull().sum().sum()}")
# 2. 전처리
X = df.drop('target', axis=1)
y = df['target']
# 훈련/테스트 분할 (80:20)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42, stratify=y
)
# 스케일링 (훈련 데이터로 fit, 테스트에 transform)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
# 3. 모델 훈련
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train_scaled, y_train)
# 4. 교차 검증
cv_scores = cross_val_score(model, X_train_scaled, y_train, cv=5)
print(f"\n📊 교차 검증 결과:")
print(f"평균 정확도: {cv_scores.mean():.4f} (+/- {cv_scores.std()*2:.4f})")
# 5. 테스트 평가
y_pred = model.predict(X_test_scaled)
print(f"\n📋 테스트 성능:")
print(f"정확도: {accuracy_score(y_test, y_pred):.4f}")
print(classification_report(y_test, y_pred))
# 6. 피처 중요도
importance = pd.DataFrame({
'feature': X.columns,
'importance': model.feature_importances_
}).sort_values('importance', ascending=False)
print("\n🔍 상위 피처:")
print(importance.head(10))
"We can approach this problem with supervised learning. We have 100,000 churn records covering three months, so that's enough. Let's run XGBoost as a baseline, and consider deep learning too depending on the performance. A PoC is feasible in two weeks."
"The difference between machine learning and deep learning lies in feature engineering. In traditional ML, feature design based on domain knowledge is important, but deep learning automatically learns features from raw data. For structured data, XGBoost is still strong, and for unstructured data, deep learning has the upper hand."
"Data quality is as important as model performance. You know 'garbage in, garbage out,' right? Performance drops sharply once label noise exceeds just 5%. You should spend 60% of the total time on feature engineering."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
The test set is for final evaluation only. If you look at performance while tuning, data leakage occurs and leads to overfitting. Be sure to use a separate validation set or cross-validation.
If you apply scaling or encoding to the entire dataset, test information leaks into training. Always split first, then fit only on the training data and transform the test data.
Split the data first, and fit the preprocessor only on the training data. Using a Pipeline can automate this process. For time series, the time order must be preserved.