Machine Learning Basics
1. Supervised vs. Unsupervised Learning
Supervised Learning:
- Uses labeled data (input and correct output)
- Goal: predict future outcomes or classify into categories
- Common Tasks: Classification (e.g., spam detection), Regression (e.g., house price prediction)
Unsupervised Learning:
- Uses only input data without labels
- Goal: discover hidden patterns or structures in data
- Common Tasks: Clustering (e.g., customer segmentation), Dimensionality Reduction (e.g., PCA)
2. Common Algorithms (High Level)
Supervised Algorithms:
- Linear Regression: Predicts continuous values.
- Logistic Regression: Binary/multiclass classification.
- Decision Trees / Random Forests: Tree-based models; handle non-linearities well.
- SVM: Finds optimal separating hyperplane.
- KNN: Predicts by finding the nearest neighbors.
Unsupervised Algorithms:
- K-Means Clustering: Groups data into k clusters.
- Hierarchical Clustering: Builds nested clusters.
- PCA: Reduces feature space while preserving data variance.
3. Model Evaluation Metrics
Classification Metrics:
- Accuracy: (TP + TN) / Total samples
- Precision: TP / (TP + FP)
- Recall: TP / (TP + FN)
- F1 Score: Harmonic mean of Precision and Recall
- Confusion Matrix: Tabular layout of TP, TN, FP, FN
Regression Metrics:
- MSE (Mean Squared Error)
- RMSE (Root MSE)
Machine Learning Basics
- MAE (Mean Absolute Error)
- R² Score: Goodness of fit measure
4. Training, Validation, and Test Sets
- Training Set: For learning model parameters (60-80%)
- Validation Set: For tuning hyperparameters (10-20%)
- Test Set: For evaluating model's generalization (10-20%)
Typical split: 70% Train / 15% Validation / 15% Test
5. Overfitting vs. Underfitting
Overfitting:
- Model memorizes training data and performs poorly on unseen data.
- Symptoms: High training accuracy, low test accuracy.
- Solutions: Simpler model, regularization (L1/L2), more data, dropout.
Underfitting:
- Model is too simple to learn patterns in data.
- Symptoms: Low accuracy on both train and test sets.
- Solutions: More complex model, better feature engineering.
6. Deep Learning Overview
- Neural Networks: Layers of neurons to learn representations.
- Activations: ReLU, Sigmoid, Tanh introduce non-linearity.
- Optimizers: SGD, Adam adjust weights using gradients.
- CNNs: Great for images; use filters to capture spatial features.
- RNNs / LSTMs / GRUs: Ideal for sequences (text, time series).
- Techniques: Dropout, Batch Normalization, Data Augmentation.
- Transfer Learning: Use pre-trained models to boost performance with limited data.