05_Machine_Learning
Tags: #◇CSINTSY #◇Computational Thinking #◇Computer Science #◇Artificial Intelligence #◇Machine Learning #◇Intelligent Systems #◇Probability #◇Data Analysis
◇Overview
Machine Learning (ML) is a field of AI where computers learn from data without being explicitly programmed for specific tasks.
◇Details / Theory
5. Machine Learning Reviewer
◇Overview
Machine Learning (ML) is a field of AI where computers learn from data without being explicitly programmed for specific tasks.
◇Types of Machine Learning
1. Supervised Learning
Data: Labeled dataset. Input () and correct Output () are provided. Goal: Learn a mapping function to predict outputs for new inputs. Examples:
Classification: Predicting a category (e.g., Spam vs. Not Spam, Dog vs. Cat).
Regression: Predicting a continuous value (e.g., House Price, Temperature). Algorithms: Decision Trees, Naive Bayes, Linear Regression, Support Vector Machines.
2. Unsupervised Learning
Data: Unlabeled dataset. Only Input () is provided. Goal: Find hidden structures or patterns in the data. Examples:
Clustering: Grouping similar data points (e.g., Customer Segmentation).
Dimensionality Reduction: Simplifying data while keeping important info. Algorithms: K-Means Clustering, PCA.
3. Reinforcement Learning
Data: Interaction with an environment (States, Actions, Rewards). Goal: Learn a policy to maximize cumulative reward. Examples: Game playing (Chess, Mario), Robot control. Algorithms: Q-Learning.
◇Evaluation Metrics (for Classification)
Confusion Matrix
A table comparing predicted vs. actual labels.
| Predicted Positive (PP) | Predicted Negative (PN) | |
|---|---|---|
| Actual Positive (P) | True Positive (TP) | False Negative (FN) |
| Actual Negative (N) | False Positive (FP) | True Negative (TN) |
| TP: Correctly predicted positive. TN: Correctly predicted negative. FP: Incorrectly predicted positive (Type I Error). FN: Incorrectly predicted negative (Type II Error). |
Formulas
-
Accuracy: Overall correctness.
Warning: Misleading for imbalanced datasets (e.g., 99% benign, 1% cancer). -
Precision: Quality of positive predictions. "Of all the ones I labeled positive, how many were actually positive?"
-
Recall (Sensitivity): Coverage of actual positives. "Of all the actual positives, how many did I find?"
-
F1 Score: Harmonic mean of Precision and Recall. Balances both.
◇Feature Engineering
The process of using domain knowledge to extract features from raw data.
Feature Selection: Choosing the most relevant features (e.g., removing irrelevant columns). Feature Extraction: Creating new features (e.g., calculating BMI from Height and Weight). One-Hot Encoding: Converting categorical data (Red, Blue) into binary vectors (Red=[1,0], Blue=[0,1]). TF-IDF: A statistical measure used in text mining to evaluate how important a word is to a document in a collection.
◇Solved Example: Calculating Metrics
Scenario: A model predicts whether an email is Spam (Positive) or Not Spam (Negative).
Confusion Matrix:
TP (Spam correctly identified): 80 TN (Not Spam correctly identified): 900 FP (Not Spam labeled as Spam): 20 FN (Spam labeled as Not Spam): 10
Calculations:
-
Accuracy:
-
Precision (for Spam):
Interpretation: When the model says "Spam", it is correct 80% of the time. -
Recall (for Spam):
Interpretation: The model catches 89% of all actual spam emails. -
F1 Score:
◇Common Pitfalls
Confusing accuracy (overall correct) with precision (correct among predicted positive) and recall (correct among actual positive). Using accuracy alone on imbalanced datasets — F1 score gives a better picture. Mixing up supervised (labeled data), unsupervised (no labels), and reinforcement (reward signals) learning paradigms.
◇Summary
TL;DR — ML splits into supervised (classification/regression), unsupervised (clustering), and reinforcement learning. Evaluation uses confusion matrices to compute accuracy, precision, recall, and F1 score. Feature engineering and proper train/test splits are essential.
◇Links
Related: Source / Reference:
Made by 2ru17
Please contact me through discord or my the university email for any problems regarding the reviewer. Thanks!
◇References & Navigation
- Previous Topic: ◇Adversarial Games
- Next Topic: ◇Decision Tree
- Related Notes: ◇Machine Learning Models
ACTIVE RECALL VERIFICATION
Select an answer to verify conceptual comprehension and reveal the technical rationale.
In supervised learning, what kind of data is provided to the algorithm?
Which task is an example of regression in supervised learning?
What is the main objective of unsupervised learning?
Which machine learning paradigm involves an agent interacting with an environment to maximize cumulative reward?
In a confusion matrix, what does a False Positive (FP) represent?
Why might "Accuracy" be a misleading metric for evaluating a classification model?
Which metric specifically answers the question: "Of all the actual positives in the dataset, how many did the model successfully find?"
What is the purpose of the F1 Score?
In feature engineering, what does One-Hot Encoding accomplish?
What is TF-IDF primarily used for?