AI & Machine Learning Cheat Sheet
AI & Machine Learning Cheat Sheet: Concepts, Algorithms & Examples
Artificial Intelligence (AI) and Machine Learning (ML) are technologies that help computers perform tasks such as recognizing patterns, making predictions, understanding language, and supporting decisions.
Although the terms are often used interchangeably, they have different meanings. AI is the broader field, while machine learning is one approach used to develop AI systems.
This cheat sheet explains the fundamentals of AI and ML, learning methods, important algorithms, model evaluation metrics, practical applications, and essential terminology.
1. What Is Artificial Intelligence?
Artificial Intelligence is a field of computer science focused on creating systems that perform tasks commonly associated with human intelligence.
These tasks may include:
Understanding natural language.
Recognizing images and objects.
Identifying patterns in data.
Making predictions.
Planning actions.
Generating text, images, audio, or code.
Supporting decision-making.
Example: A customer support chatbot that interprets a question and generates a response is an example of an AI application.
Types of AI by Capability
Narrow AI: Designed for specific tasks or a limited range of tasks. Most AI systems currently used in business fall into this category.
Artificial General Intelligence (AGI): A hypothetical form of AI capable of performing a broad range of intellectual tasks at a general level comparable to humans.
Artificial Superintelligence (ASI): A hypothetical form of AI that would substantially exceed human capabilities across a broad range of intellectual tasks.
AGI and ASI are conceptual categories, not established capabilities of today's general-purpose AI systems.
2. What Is Machine Learning?
Machine Learning is a branch of AI in which algorithms learn patterns from data to make predictions, classifications, recommendations, or other outputs.
Instead of manually programming every decision rule, developers train a model using data and an appropriate learning method.
Example: Email spam detection
Collect examples of spam and legitimate emails.
Prepare and label the data.
Train a machine learning model.
Evaluate its predictions on unseen examples.
Deploy the model to classify new emails.
Monitor performance as email patterns change.
A model's predictions are not guaranteed to be correct. Performance depends on data quality, model design, evaluation, and the environment in which the model is used.
3. AI vs Machine Learning vs Deep Learning vs Generative AI
These concepts are related but not identical.
Concept | Meaning | Example |
|---|---|---|
Artificial Intelligence | Broad field of intelligent computer systems | A system that plans a route |
Machine Learning | Learning patterns from data | Predicting customer churn |
Deep Learning | ML using multilayer neural networks | Recognizing objects in images |
Generative AI | AI that generates new content | Drafting text or generating images |
A useful way to remember the relationship is that machine learning is a branch of AI, deep learning is a branch of machine learning, and generative AI is a category of AI systems that can use different model architectures.
Generative AI and deep learning overlap extensively, but the terms describe different things.
4. Types of Machine Learning
Machine learning methods are commonly grouped into supervised learning, unsupervised learning, semi-supervised learning, and reinforcement learning.
Supervised Learning
Supervised learning uses training examples that include input data and known target outputs.
The model learns relationships between inputs and targets.
Common tasks:
Classification.
Regression.
Examples:
Predicting house prices.
Classifying emails as spam or legitimate.
Predicting whether a customer may leave a service.
Unsupervised Learning
Unsupervised learning identifies patterns or structures in data without relying on supplied target labels for every training example.
Common tasks:
Clustering.
Dimensionality reduction.
Anomaly exploration.
Examples:
Grouping customers by behavior.
Exploring patterns in purchasing data.
Finding unusual transactions for further investigation.
Semi-Supervised Learning
Semi-supervised learning uses a relatively small labeled dataset alongside a larger amount of unlabeled data.
It can be useful when obtaining accurate labels is expensive or time-consuming.
Example: Training an image classification model with a limited set of manually labeled images and a larger collection of unlabeled images.
Reinforcement Learning
Reinforcement learning trains an agent to select actions through interaction with an environment and feedback expressed through rewards or penalties.
Key concepts:
Agent: The decision-making system.
Environment: The system or world in which it acts.
State: The current situation.
Action: A choice available to the agent.
Reward: Feedback associated with an outcome.
Policy: The strategy used to choose actions.
Examples: Certain robotics tasks, game-playing systems, and sequential decision-making problems.
Quick Comparison
Learning type | Training feedback | Typical use |
|---|---|---|
Supervised | Labeled examples | Classification and prediction |
Unsupervised | Unlabeled data | Clustering and pattern discovery |
Semi-supervised | Labeled and unlabeled data | Learning with limited labels |
Reinforcement | Rewards from interaction | Sequential decision-making |
5. Important Machine Learning Terminology
Dataset: A collection of data used for analysis, training, validation, or testing.
Feature: An input variable used by a model.
Label: The target value associated with a training example in supervised learning.
Model: A learned mathematical representation or system used to generate predictions or outputs.
Algorithm: A procedure used to perform a task or learn a model.
Training: The process through which a model learns from data.
Inference: Using a trained model to produce predictions or outputs.
Epoch: One complete pass through the training dataset in a typical iterative training process.
Batch: A subset of training examples processed together.
Hyperparameter: A setting chosen to control model training or behavior, such as learning rate or tree depth.
Loss function: A function that measures how poorly a model's predictions match the training targets or desired behavior.
Optimization: The process of adjusting model parameters to improve an objective, often by reducing loss.
Overfitting: When a model learns training-specific patterns too closely and performs poorly on new data.
Underfitting: When a model fails to learn the important patterns needed for the task.
Generalization: The ability of a model to perform well on previously unseen data from a relevant distribution.
Inference latency: The time required to produce a model's output.
6. Common Machine Learning Algorithms
Linear Regression
Linear regression models a numerical target as a linear combination of input features.
Typical uses:
Estimating sales.
Predicting prices.
Forecasting numerical outcomes.
A simple linear regression equation is:
[
y = mx + b
]
Where:
(y) = predicted output.
(x) = input.
(m) = slope.
(b) = intercept.
Real-world models may include multiple features and additional terms.
Logistic Regression
Logistic regression is commonly used for classification, particularly binary classification.
Typical uses:
Predicting whether a customer will churn.
Estimating the likelihood of a conversion.
Classifying transactions into two categories.
Despite its name, it is commonly used as a classification model rather than a standard regression model.
Decision Tree
A decision tree makes predictions by following a sequence of feature-based decision rules.
Typical uses:
Customer segmentation.
Risk classification.
Interpretable prediction workflows.
Random Forest
A random forest combines predictions from multiple decision trees trained using randomized data samples and feature selections.
It can improve robustness compared with an individual tree, although performance depends on the dataset and configuration.
Support Vector Machine (SVM)
An SVM seeks a decision boundary that separates classes with a large margin. Kernel methods can support nonlinear boundaries.
Typical uses: Classification and selected regression problems.
K-Nearest Neighbors (KNN)
KNN predicts a class or numerical value using nearby examples in the feature space.
Its performance can depend heavily on feature scaling, distance measures, and the choice of neighbors.
K-Means Clustering
K-means groups observations into a specified number of clusters based on their distance from cluster centers.
Typical uses:
Exploratory customer segmentation.
Grouping similar observations.
Identifying broad patterns in datasets.
Clusters do not automatically represent meaningful business segments; they require interpretation and validation.
Naive Bayes
Naive Bayes uses Bayes' theorem with simplifying conditional independence assumptions.
Typical uses:
Text classification.
Spam filtering.
Certain document categorization tasks.
Neural Networks
Neural networks consist of connected computational units arranged in layers. They can learn complex relationships and are widely used in deep learning.
Typical uses:
Image recognition.
Speech processing.
Natural language processing.
Generative AI.
7. Classification vs Regression vs Clustering
Task | Goal | Example | Common evaluation |
|---|---|---|---|
Classification | Predict a category | Spam or legitimate | Precision, recall, F1 |
Regression | Predict a numerical value | Sales forecast | MAE, RMSE |
Clustering | Discover groups | Customer behavior groups | Silhouette score and domain review |
Remember:
Classification predicts categories.
Regression predicts numerical values.
Clustering discovers groups without requiring predefined class labels.
8. Training, Validation and Test Data
A dataset is often divided into separate portions for model development and evaluation.
Training set: Used to fit the model.
Validation set: Used to compare models, tune hyperparameters, and make development decisions.
Test set: Used for a final evaluation on data not used for model fitting or tuning.
A common illustrative split is 70% training, 15% validation, and 15% testing. This is not a universal rule; appropriate splits depend on the dataset, task, and available data.
Why Data Splitting Matters
Evaluating a model on the same examples used for training can produce an overly optimistic assessment.
A properly separated test set helps estimate how the model performs on unseen data.
For time-dependent problems, chronological splitting may be more appropriate than random splitting. In other situations, grouped or stratified splitting may be needed.
Data Leakage
Data leakage occurs when information unavailable at prediction time improperly influences training or evaluation.
Examples include:
Using future information to predict past outcomes.
Including a variable derived from the target.
Fitting preprocessing steps on the entire dataset before splitting.
Allowing related records to leak between training and testing.
Leakage can make a model appear more accurate than it will be in real-world use.
9. Essential Model Evaluation Metrics
The correct metric depends on the problem, the cost of different errors, and the business objective.
Classification Metrics
Accuracy
[
\text{Accuracy}=\frac{TP+TN}{TP+TN+FP+FN}
]
Accuracy measures the proportion of predictions that are correct.
Precision
[
\text{Precision}=\frac{TP}{TP+FP}
]
Precision measures the proportion of predicted positives that are actually positive.
Recall
[
\text{Recall}=\frac{TP}{TP+FN}
]
Recall measures the proportion of actual positives correctly identified.
F1 Score
[
F1=2\times\frac{\text{Precision}\times\text{Recall}}{\text{Precision}+\text{Recall}}
]
The F1 score combines precision and recall using their harmonic mean.
Where:
TP = True positives.
TN = True negatives.
FP = False positives.
FN = False negatives.
Example: In fraud detection, missing a fraudulent transaction and incorrectly flagging a legitimate transaction can have different costs. Accuracy alone may not capture that trade-off.
Regression Metrics
Mean Absolute Error (MAE): Average absolute difference between actual and predicted values.
Mean Squared Error (MSE): Average squared prediction error.
Root Mean Squared Error (RMSE): Square root of MSE, expressed in the target variable's units.
R-squared ((R^2)): Measures model fit relative to a baseline based on the target mean. Its interpretation depends on the data and evaluation setup.
Model Evaluation Best Practice
Do not select a model based on a single metric without understanding the objective. Consider error costs, class imbalance, generalization, interpretability, latency, and deployment requirements.
10. Overfitting and Underfitting
Overfitting
An overfitted model performs very well on training data but poorly on unseen data.
Possible causes:
Excessive model complexity.
Insufficient training data.
Data leakage.
Training for too long in some settings.
Weak regularization.
Possible solutions:
Collect more representative data.
Use appropriate regularization.
Reduce model complexity.
Apply suitable cross-validation.
Improve feature selection.
Use early stopping where appropriate.
Underfitting
An underfitted model fails to capture important relationships even in the training data.
Possible causes:
Model is too simple.
Important features are missing.
Training is insufficient.
Constraints are too restrictive.
Possible solutions:
Use a more suitable model.
Improve feature engineering.
Train appropriately.
Review preprocessing and optimization.
Reassess whether the model captures the relevant relationships.
The goal is not to maximize training performance. It is to achieve reliable performance on relevant unseen data.
11. Feature Engineering and Data Preparation
Feature engineering involves creating, transforming, selecting, or representing input variables to improve model usefulness.
Common activities include:
Handling missing values.
Identifying duplicate records.
Correcting inconsistent data types.
Encoding categorical variables.
Scaling numerical features where appropriate.
Creating useful derived variables.
Identifying outliers.
Checking data quality and representativeness.
Common Preprocessing Methods
Method | Purpose |
|---|---|
Imputation | Handle missing values |
One-hot encoding | Represent categories using binary indicator variables |
Standardization | Transform values using a mean and standard deviation |
Min-max scaling | Transform values to a specified range |
Feature selection | Choose relevant input variables |
Dimensionality reduction | Represent data with fewer dimensions |
Not every model requires every preprocessing step. For example, scaling is often important for distance-based algorithms but is generally less critical for many tree-based models.
Preprocessing should be fitted on training data and then applied consistently to validation, test, and production data.
12. Deep Learning Fundamentals
Deep learning uses neural networks with multiple layers to learn representations from data.
Key Concepts
Input layer: Receives the model's input representation.
Hidden layers: Transform the input through learned computations.
Output layer: Produces the model's final prediction or output.
Weights: Learned parameters that influence the network's computations.
Activation function: Introduces nonlinear behavior into a neural network.
Backpropagation: Computes gradients used to update model parameters during training.
Gradient descent: An optimization method that updates parameters in the direction intended to reduce the objective function.
Common Neural Network Types
Feedforward neural networks: Process information through successive layers.
Convolutional neural networks (CNNs): Commonly used for image and spatial data.
Recurrent neural networks (RNNs): Designed for sequential processing; used in some sequence-learning applications.
Transformers: Use attention mechanisms and are widely used in language, vision, and multimodal AI.
Different architectures are suited to different data types and objectives.
13. Generative AI and Large Language Models
Generative AI systems can produce new content based on prompts and other supported inputs.
Large language models are trained to process and generate language and can support tasks such as:
Summarization.
Question answering.
Drafting content.
Code assistance.
Classification and extraction.
Conversational interfaces.
Important LLM Concepts
Token: A unit of text processed by a model.
Prompt: Instructions and context supplied to the model.
Context window: The amount of input and conversation context the model can process.
Hallucination: Incorrect or unsupported generated information.
Embedding: A numerical representation of content that can be used for similarity search and other tasks.
Retrieval-Augmented Generation (RAG): Retrieves relevant information from external sources and supplies it to the model as context.
Fine-tuning: Additional training to adapt a model to a task or behavior.
How to Use Generative AI Reliably
Define the task clearly.
Provide relevant context.
Specify the desired output.
Verify important facts and calculations.
Check citations and source documents.
Review privacy, security, and intellectual property considerations.
Apply human judgment before using consequential outputs.
14. Practical Applications of AI and Machine Learning
Marketing
Predicting customer churn.
Segmenting audiences.
Forecasting demand.
Recommending products.
Detecting unusual campaign patterns.
Supporting content generation.
Analyzing customer feedback.
Finance
Fraud detection.
Risk assessment.
Transaction monitoring.
Forecasting and decision support.
Healthcare
Supporting medical image analysis.
Assisting research.
Identifying patterns in clinical data.
Supporting selected administrative workflows.
Healthcare applications require appropriate validation, privacy protections, and qualified professional oversight.
Retail and Ecommerce
Product recommendations.
Demand forecasting.
Inventory planning.
Customer segmentation.
Personalized discovery.
Cybersecurity
Detecting suspicious activity.
Identifying anomalies.
Prioritizing alerts.
Supporting threat analysis.
Software Development
Code assistance.
Automated testing support.
Defect detection.
Documentation generation.
Developer productivity tools.
These applications vary in maturity, reliability, and regulatory requirements.
15. AI Project Workflow
A practical AI or machine learning project typically follows these stages.
Step 1: Define the problem.
Specify the business objective, intended users, constraints, and success criteria.
Step 2: Gather data.
Identify relevant data sources and confirm that the data can be used appropriately.
Step 3: Explore the data.
Examine quality, distributions, missing values, class balance, and potential leakage.
Step 4: Prepare the data.
Clean, transform, and split the data using a suitable methodology.
Step 5: Establish a baseline.
Create a simple benchmark against which more complex approaches can be compared.
Step 6: Train models.
Select appropriate algorithms and fit them using training data.
Step 7: Evaluate performance.
Use metrics aligned with the objective and test on appropriately separated data.
Step 8: Deploy the solution.
Integrate the model into the intended workflow with appropriate security and monitoring.
Step 9: Monitor and maintain.
Track performance, data changes, reliability, cost, and user impact.
Step 10: Improve when justified.
Use observed results to refine the data, model, workflow, or problem definition.
16. Common AI and Machine Learning Mistakes
Mistake 1: Assuming more data always means a better model.
Data quality, relevance, representativeness, and labeling also matter.
Mistake 2: Using accuracy as the only metric.
Accuracy can be misleading on imbalanced datasets or when error costs differ.
Mistake 3: Ignoring data leakage.
Leakage can produce misleadingly strong evaluation results.
Mistake 4: Training on biased or unrepresentative data.
A model may perform poorly for groups or situations underrepresented in the training data.
Mistake 5: Choosing a complex model too early.
Start with a meaningful baseline and justify added complexity through measurable improvements.
Mistake 6: Ignoring deployment constraints.
Latency, cost, interpretability, privacy, and maintenance can matter as much as predictive performance.
Mistake 7: Treating model outputs as guaranteed facts.
Predictions and generated content require appropriate validation.
Mistake 8: Failing to monitor deployed models.
Data distributions and real-world conditions can change after deployment.
17. Quick-Reference Comparison Table
Term | Quick reference |
|---|---|
AI | Broad field of intelligent computer systems |
ML | Learning patterns from data |
Deep learning | Machine learning using multilayer neural networks |
Supervised learning | Learning from labeled examples |
Unsupervised learning | Finding patterns without supplied target labels |
Reinforcement learning | Learning actions through reward-based interaction |
Classification | Predicting categories |
Regression | Predicting numerical values |
Clustering | Grouping similar observations |
Feature | Model input variable |
Label | Target value in supervised learning |
Overfitting | Poor generalization after fitting training-specific patterns |
Underfitting | Failure to learn important patterns |
Precision | Proportion of predicted positives that are correct |
Recall | Proportion of actual positives correctly identified |
MAE | Average absolute prediction error |
RAG | Generating responses with retrieved external context |
18. AI and Machine Learning Revision Checklist
Fundamentals
Explain AI, ML, deep learning, and generative AI.
Describe the main machine learning learning methods.
Distinguish classification, regression, and clustering.
Algorithms
Understand linear and logistic regression.
Explain decision trees and random forests.
Understand KNN, K-means, and neural networks.
Model Development
Explain training, validation, and test datasets.
Identify overfitting and underfitting.
Understand feature engineering and data leakage.
Choose suitable evaluation metrics.
Practical Applications
Describe a realistic AI use case.
Explain the steps in an ML project.
Discuss privacy, bias, and model limitations.
Explain why monitoring is necessary after deployment.
Conclusion
Artificial intelligence is a broad field, and machine learning is one of its most important approaches. Understanding learning methods, algorithms, data preparation, evaluation metrics, and model limitations provides a strong foundation for studying modern AI technologies.
The key is to connect each concept to a practical problem. Choose the appropriate learning method, prepare reliable data, evaluate models using meaningful metrics, and monitor their behavior after deployment.
Use this cheat sheet as a quick reference when learning AI and machine learning, exploring technical concepts, working with data, or preparing for technology interviews.



