Machine Learning Cheat Sheets
Quick reference guides for machine learning concepts, algorithms, and implementation details
Category
Type
Difficulty
Python Basics
Beginner
Essential Python syntax and functions for machine learning
5.0
Code Snippet
# Lists
my_list = [1, 2, 3, 4, 5]
my_list.append(6) # Add element
my_list.pop() # Remove last element
my_list[0] # Access element
# Dictionaries
my_dict = {'a': 1, 'b': 2}
my_dict['c'] = 3 # Add key-value pair
my_dict.get('a') # Get value
my_dict.keys() # Get all keys
# NumPy Arrays
import numpy as np
arr = np.array([1, 2, 3])
arr * 2 # Element-wise multiplication
np.mean(arr) # Calculate mean
np.reshape(arr, (3, 1)) # Reshape array
Programming
NumPy Essentials
Intermediate
Key NumPy functions and operations for numerical computing
5.0
Code Snippet
import numpy as np
# Creating arrays
a = np.array([1, 2, 3]) # From list
b = np.zeros((3, 3)) # Array of zeros
c = np.ones((2, 3)) # Array of ones
d = np.eye(3) # Identity matrix
e = np.random.random((2, 2)) # Random values
f = np.arange(10) # Range of values
g = np.linspace(0, 1, 5) # Evenly spaced values
Libraries
Pandas for Data Analysis
Intermediate
Common Pandas operations for data manipulation and analysis
5.0
Code Snippet
import pandas as pd
# Series
s = pd.Series([1, 2, 3], index=['a', 'b', 'c'])
# DataFrame
data = {'A': [1, 2, 3], 'B': [4, 5, 6]}
df = pd.DataFrame(data)
# Reading data
df_csv = pd.read_csv('file.csv')
df_excel = pd.read_excel('file.xlsx')
df_sql = pd.read_sql('query', connection)
Libraries
Matplotlib & Seaborn
Intermediate
Visualization techniques for data exploration and presentation
4.5
Code Snippet
import matplotlib.pyplot as plt
import seaborn as sns
# Basic plots
plt.figure(figsize=(10, 6))
plt.plot(x, y)
plt.scatter(x, y)
plt.bar(x, y)
plt.hist(x, bins=10)
plt.boxplot(x)
plt.pie(x)
# Customization
plt.title('Title')
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.legend(['Label 1', 'Label 2'])
plt.grid(True)
plt.savefig('plot.png')
plt.show()
Visualization
Scikit-Learn
Intermediate
Machine learning algorithms and evaluation metrics
5.0
Code Snippet
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
# Split data
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42)
# Preprocessing
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
# Train models
lr = LogisticRegression()
lr.fit(X_train_scaled, y_train)
rf = RandomForestClassifier(n_estimators=100)
rf.fit(X_train_scaled, y_train)
svm = SVC(kernel='rbf', probability=True)
svm.fit(X_train_scaled, y_train)
Machine Learning
TensorFlow & Keras
Advanced
Deep learning model building and training
4.5
Code Snippet
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, MaxPooling2D, Flatten, Dropout
# Sequential API
model = Sequential([
Dense(128, activation='relu', input_shape=(784,)),
Dropout(0.2),
Dense(64, activation='relu'),
Dense(10, activation='softmax')
])
# CNN model
cnn_model = Sequential([
Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(28, 28, 1)),
MaxPooling2D(pool_size=(2, 2)),
Conv2D(64, kernel_size=(3, 3), activation='relu'),
MaxPooling2D(pool_size=(2, 2)),
Flatten(),
Dense(128, activation='relu'),
Dropout(0.5),
Dense(10, activation='softmax')
])
# Functional API
inputs = tf.keras.Input(shape=(784,))
x = Dense(128, activation='relu')(inputs)
x = Dropout(0.2)(x)
x = Dense(64, activation='relu')(x)
outputs = Dense(10, activation='softmax')(x)
model = tf.keras.Model(inputs=inputs, outputs=outputs)
Deep Learning
Machine Learning Algorithms
Intermediate
Overview of common ML algorithms and their applications
4.5
PDF Preview
# This is a PDF resource with comprehensive information about supervised learning algorithms
# Including decision trees, random forests, SVMs, and neural networks
# With examples, use cases, and implementation guidelines
Machine Learning
Statistics for Data Science
Intermediate
Essential statistical concepts for machine learning
4.0
PDF Preview
# This is a PDF resource covering measures of central tendency and dispersion
# Including mean, median, mode, variance, standard deviation
# With practical examples and interpretations
Mathematics
Linear Algebra for ML
Advanced
Key linear algebra concepts used in machine learning
4.0
PDF Preview
# This is a PDF resource covering vector and matrix operations
# Including addition, multiplication, transposition, and inversion
# With applications in machine learning algorithms
Mathematics
PyTorch Basics
Intermediate
Getting started with PyTorch for deep learning
4.5
Code Snippet
import torch
# Creating tensors
x = torch.tensor([1, 2, 3])
y = torch.zeros(3, 3)
z = torch.ones(2, 2)
w = torch.rand(3, 3)
# Basic operations
a = x + x
b = y * 2
c = torch.matmul(y, w)
d = torch.cat([y, z], dim=0)
# Moving to GPU
if torch.cuda.is_available():
x_gpu = x.to('cuda')
y_gpu = y.cuda()
# Converting to NumPy
x_np = x.numpy()
y_tensor = torch.from_numpy(numpy_array)
Deep Learning
Data Preprocessing
Beginner
Techniques for preparing data for machine learning
4.5
Code Snippet
import pandas as pd
import numpy as np
# Handling missing values
df.isnull().sum() # Count missing values
df.dropna() # Drop rows with missing values
df.fillna(0) # Fill missing values with 0
df.fillna(df.mean()) # Fill with mean
# Handling duplicates
df.duplicated().sum() # Count duplicates
df.drop_duplicates() # Remove duplicates
# Handling outliers
Q1 = df['column'].quantile(0.25)
Q3 = df['column'].quantile(0.75)
IQR = Q3 - Q1
df_filtered = df[(df['column'] >= Q1 - 1.5 * IQR) &
(df['column'] <= Q3 + 1.5 * IQR)]
# Data type conversion
df['column'] = df['column'].astype('int64')
df['date_column'] = pd.to_datetime(df['date_column'])
Data Science
SQL for Data Science
Beginner
Essential SQL queries for data extraction and analysis
4.0
Code Snippet
-- Select all columns
SELECT * FROM table_name;
-- Select specific columns
SELECT column1, column2 FROM table_name;
-- Filter rows
SELECT * FROM table_name WHERE condition;
-- Sort results
SELECT * FROM table_name ORDER BY column_name ASC/DESC;
-- Limit results
SELECT * FROM table_name LIMIT 10;
-- Distinct values
SELECT DISTINCT column_name FROM table_name;
Data Science
Neural Network Architectures
Advanced
Common neural network architectures and their applications
5.0
PDF Preview
# This is a PDF resource covering CNN architectures
# Including LeNet, AlexNet, VGG, ResNet, and Inception
# With applications in computer vision and image processing
Deep Learning
Git for Data Scientists
Beginner
Essential Git commands for version control in data science projects
4.0
Code Snippet
# Initialize a repository
git init
# Clone a repository
git clone https://github.com/username/repository.git
# Check status
git status
# Add files to staging
git add filename
git add . # Add all files
# Commit changes
git commit -m "Commit message"
# Push to remote
git push origin branch_name
# Pull from remote
git pull origin branch_name
Tools
Model Deployment
Advanced
Techniques for deploying machine learning models to production
4.5
PDF Preview
# This is a PDF resource covering Docker and containerization
# Including Dockerfiles, Docker Compose, and Kubernetes
# With examples for packaging ML models
MLOps
How to Use These Cheat Sheets
Our cheat sheets are designed to be quick references when implementing or studying machine learning models. They contain the most important functions, parameters, and implementation tips in a condensed format.
For Learning
- •Use as quick reference during courses or tutorials
- •Review key concepts before exams or interviews
- •Compare different algorithms and their properties
- •Understand the mathematical foundations of ML techniques
For Implementation
- •Copy code snippets directly into your projects
- •Use as templates for common ML workflows
- •Reference API parameters and function signatures
- •Troubleshoot common issues with implementation examples