AIML Cheatsheet - Coders - Section
AIML Cheatsheet - Coders - Section
CheatSheet
TABLE OF CONTENTS
1. Introduction to AI and ML
What is Artificial Intelligence (AI)?
Types of AI: Narrow AI vs. General AI
What is Machine Learning (ML)?
Supervised vs. Unsupervised vs. Reinforcement Learning
Key Terminologies (Model, Feature, Target, Algorithm)
Applications of AI and ML
Difference Between AI, ML, and Deep Learning (DL)
3. Data Preprocessing
Data Cleaning (Missing Values, Outliers)
Data Normalization and Standardization
Encoding Categorical Variables (One-Hot Encoding, Label Encoding)
Feature Scaling (Min-Max, Z-score)
Feature Engineering (Polynomial Features, Binning)
Handling Imbalanced Data (SMOTE, Undersampling, Oversampling)
Term Description
Artificial Intelligence (AI) The overall field focused on creating intelligent machines
Deep Learning (DL) A specialized type of ML that uses neural networks inspired by the
human brain
Visual analogy:
AI is the broader concept, ML is a part of AI, and DL is a part of ML.
Artificial Intelligence
Machine Learning
Deep Learning
2. MATHEMATICS FOR ML/AI
Mathematics is the foundation of AI and Machine Learning. It helps us
understand how algorithms work under the hood and how to fine-tune
models for better performance.
These are used in algorithms like Principal Component Analysis (PCA) for
dimensionality reduction.
2. MATHEMATICS FOR ML/AI
2.2 Probability and Statistics
Probability helps machines make decisions under uncertainty, and
statistics helps us understand data and model performance.
3.1.2 Outliers
Outliers are data points that are very different from others.
They can distort results and reduce model performance.
Detection methods:
Box plot, Z-score, IQR method
Handling outliers:
Remove them
Transform data (e.g., log scaling)
Cap them (set a maximum/minimum)
One-Hot Encoding:
Creates new binary columns for each category.
Example:
Label encoding is good for ordinal data (ranked), while one-hot encoding
is best for nominal data (non-ranked).
4.2.3 Regularization
L1 and L2 regularization help prevent overfitting in logistic regression as
well.
4. SUPERVISED LEARNING ALGORITHMS
4.3 K-Nearest Neighbors (KNN)
A simple classification (or regression) algorithm that uses proximity.
4.3.2 Choosing K
K is the number of neighbors to consider.
Too low K → sensitive to noise
Too high K → model becomes less flexible
4.6.1 Bootstrapping
Randomly selects subsets of data to train each tree.
4.6.2 Bagging
Combines predictions of multiple trees (majority vote or average).
4.6.3 Feature Importance
Measures which features contribute most to model prediction.
Where:
s: current state
a: action
r: reward
s': next state
α: learning rate
γ: discount factor
Deep Q-Networks (DQN):
When the state/action space is too large, a neural network is used to
approximate Q-values.
Combines Q-Learning with Deep Learning.
Used in Atari games and robotics.
7.1.1 Perceptrons
The perceptron is the simplest type of neural network, with:
Inputs → Weights → Summation → Activation Function → Output
It's like a yes/no decision maker (binary classification).
7.3.3 Applications
Image Classification
Face Recognition
Object Detection
7. NEURAL NETWORKS & DEEP LEARNING
7.4 Recurrent Neural Networks (RNN)
RNNs are designed for sequential data (time series, text, etc.).
7.5.3 Applications
Image Generation (e.g., fake faces)
Art and Style Transfer
Data Augmentation for training other ML models
8. NATURAL LANGUAGE PROCESSING (NLP)
NLP helps computers understand, interpret, and generate human language.
It's widely used in applications like chatbots, translation tools, and voice
assistants.
8.1.1 Tokenization
Breaking text into smaller parts like words or sentences.
Example: "I love AI" → ["I", "love", "AI"]
8.1.2 Stopwords
Removing common words that do not add much meaning (like “is”, “the”,
“and”).
8.1.3 Stemming
Cutting words down to their root form.
Example: “playing”, “played” → “play”
8.1.4 Lemmatization
Similar to stemming but uses grammar to find the proper base word.
Example: “better” → “good”
8.1.6 TF-IDF
Gives importance to words that appear often in one document but not in
others. Helps identify keywords.
8. NATURAL LANGUAGE PROCESSING (NLP)
8.2 Word Embeddings
Word embeddings turn words into vectors (numbers) so that a machine
can understand their meaning and context.
8.2.1 Word2Vec
A model that learns how words are related based on their surrounding
words.
8.2.2 GloVe
Learns word meanings by looking at how often words appear together.
8.2.3 FastText
Similar to Word2Vec but also looks at parts of words, which helps with
unknown words.
8.2.4 Sentence Embeddings (BERT, RoBERTa, GPT)
These models convert full sentences into vectors. They understand context
much better than older models.
9.1.1 Accuracy
How often the model is correct.
Formula: (Correct Predictions) / (Total Predictions)
9.1.2 Precision
Out of all predicted positives, how many were actually positive?
Used when false positives are costly.
Formula: TP / (TP + FP)
9.1.4 F1-Score
Balance between precision and recall.
Formula: 2 * (Precision * Recall) / (Precision + Recall)
9.3 Cross-Validation
Used to test model performance on different splits of the data.
Benefit: Saves training time and works well even with limited data.
Artificial
Intelligence (AI)
Machine
Learning (ML)
Deep Reinforcement
Learning (DL) Learning (RL)
10. ADVANCED TOPICS
10.4 Federated Learning
Model training happens across many devices without collecting data in a
central server. Each device keeps its data private and only sends model
updates.
Distributed Learning Frameworks
Used when data is spread across users, hospitals, or devices. Examples
include Google’s keyboard predictions.
Privacy-Preserving ML
Since data never leaves the device, user privacy is protected. This is useful
in healthcare, banking, and personal mobile applications.
11. TOOLS AND LIBRARIES FOR AI/ML
These tools help you build, train, and deploy AI/ML models more efficiently.
They provide ready-to-use functions so you don’t need to code everything
from scratch.
Google Colab
Free online Jupyter Notebook
Supports GPU/TPU
Great for students and beginners
AWS SageMaker
Amazon’s cloud ML platform
Supports training, tuning, and deploying models at scale
Used in enterprise-level applications
Azure ML
Microsoft’s machine learning platform
Integrates well with other Microsoft tools (e.g., Excel, Power BI)
Provides autoML, drag-and-drop pipelines, and more
12. DEPLOYMENT AND PRODUCTION
12.1 Model Serialization
What it means:
After training your machine learning model, you save (serialize) it to use
later without retraining.
Popular tools:
Pickle – A Python library to serialize and deserialize Python objects.
Joblib – Similar to Pickle but better for large NumPy arrays.
Example:
Linear Regression Predict house prices using a dataset with features like area, rooms,
and location.
Decision Trees Classify if a person will buy a product based on age, income, etc.